use crate::
{
Client,
error ::{ Result, OpenAIError },
environment ::{ OpenaiEnvironment, EnvironmentInterface },
components ::chat_shared::{ ChatCompletionRequest, CreateChatCompletionResponse },
};
use super::
{
SearchGroundingConfig, GroundedResponse,
CodeExecutionConfig, CodeExecutionResult,
WebBrowsingConfig, BrowsingResult,
ImageGenerationConfig, ImageResult,
};
#[ async_trait::async_trait ]
pub trait PlatformSpecificClient< E >
where
E: OpenaiEnvironment + EnvironmentInterface + Send + Sync + 'static,
{
async fn create_chat_completion_with_search(
&self,
request : ChatCompletionRequest,
search_config : SearchGroundingConfig
) -> Result< CreateChatCompletionResponse >;
async fn search_and_ground(
&self,
query : &str,
context : Option< &str >,
config : SearchGroundingConfig
) -> Result< GroundedResponse >;
async fn execute_code(
&self,
code : &str,
config : CodeExecutionConfig
) -> Result< CodeExecutionResult >;
async fn create_chat_completion_with_code_execution(
&self,
request : ChatCompletionRequest,
execution_config : CodeExecutionConfig
) -> Result< CreateChatCompletionResponse >;
async fn browse_url(
&self,
url : &str,
config : WebBrowsingConfig
) -> Result< BrowsingResult >;
async fn create_chat_completion_with_browsing(
&self,
request : ChatCompletionRequest,
browsing_config : WebBrowsingConfig
) -> Result< CreateChatCompletionResponse >;
async fn generate_image(
&self,
prompt : &str,
config : ImageGenerationConfig
) -> Result< ImageResult >;
}
#[ async_trait::async_trait ]
impl< E > PlatformSpecificClient< E > for Client< E >
where
E: OpenaiEnvironment + EnvironmentInterface + Send + Sync + 'static,
{
#[ inline ]
async fn create_chat_completion_with_search(
&self,
_request : ChatCompletionRequest,
_search_config : SearchGroundingConfig
) -> Result< CreateChatCompletionResponse >
{
Err( OpenAIError::Internal( "Search grounding not yet implemented".to_string() ).into() )
}
#[ inline ]
async fn search_and_ground(
&self,
_query : &str,
_context : Option< &str >,
_config : SearchGroundingConfig
) -> Result< GroundedResponse >
{
Err( OpenAIError::Internal( "Search grounding not yet implemented".to_string() ).into() )
}
#[ inline ]
async fn execute_code(
&self,
_code : &str,
_config : CodeExecutionConfig
) -> Result< CodeExecutionResult >
{
Err( OpenAIError::Internal( "Code execution not yet implemented".to_string() ).into() )
}
#[ inline ]
async fn create_chat_completion_with_code_execution(
&self,
_request : ChatCompletionRequest,
_execution_config : CodeExecutionConfig
) -> Result< CreateChatCompletionResponse >
{
Err( OpenAIError::Internal( "Code execution integration not yet implemented".to_string() ).into() )
}
#[ inline ]
async fn browse_url(
&self,
_url : &str,
_config : WebBrowsingConfig
) -> Result< BrowsingResult >
{
Err( OpenAIError::Internal( "Web browsing not yet implemented".to_string() ).into() )
}
#[ inline ]
async fn create_chat_completion_with_browsing(
&self,
_request : ChatCompletionRequest,
_browsing_config : WebBrowsingConfig
) -> Result< CreateChatCompletionResponse >
{
Err( OpenAIError::Internal( "Browsing integration not yet implemented".to_string() ).into() )
}
#[ inline ]
async fn generate_image(
&self,
_prompt : &str,
_config : ImageGenerationConfig
) -> Result< ImageResult >
{
Err( OpenAIError::Internal( "Image generation not yet implemented".to_string() ).into() )
}
}