|
1 | | -use async_openai::types::chat::Choice; |
2 | 1 | use async_trait::async_trait; |
3 | 2 |
|
4 | 3 | use crate::client::config::{ModelConfig, ModelName}; |
5 | 4 | use crate::provider::{common, provider}; |
6 | | -use crate::types::completions::{CreateCompletionRequest, CreateCompletionResponse}; |
| 5 | +use crate::types::chat; |
7 | 6 | use crate::types::error::OpenAIError; |
8 | 7 | use crate::types::responses::{ |
9 | 8 | AssistantRole, CreateResponse, OutputItem, OutputMessage, OutputMessageContent, OutputStatus, |
@@ -76,22 +75,30 @@ impl provider::Provider for FakerProvider { |
76 | 75 |
|
77 | 76 | async fn create_completion( |
78 | 77 | &self, |
79 | | - _request: CreateCompletionRequest, |
80 | | - ) -> Result<CreateCompletionResponse, OpenAIError> { |
81 | | - common::validate_completion_request(&_request)?; |
82 | | - |
83 | | - Ok(CreateCompletionResponse { |
| 78 | + request: chat::CreateChatCompletionRequest, |
| 79 | + ) -> Result<chat::CreateChatCompletionResponse, OpenAIError> { |
| 80 | + common::validate_completion_request(&request)?; |
| 81 | + Ok(chat::CreateChatCompletionResponse { |
84 | 82 | id: "fake-completion-id".to_string(), |
85 | 83 | object: "text_completion".to_string(), |
86 | 84 | created: 1_600_000_000, |
87 | 85 | model: self.model.clone(), |
88 | | - choices: vec![Choice { |
| 86 | + usage: None, |
| 87 | + service_tier: None, |
| 88 | + choices: vec![chat::ChatChoice { |
89 | 89 | index: 0, |
90 | | - text: "This is a fake completion.".to_string(), |
91 | | - logprobs: None, |
| 90 | + message: chat::ChatCompletionResponseMessage { |
| 91 | + role: chat::Role::Assistant, |
| 92 | + content: Some("This is a fake chat completion.".to_string()), |
| 93 | + refusal: None, |
| 94 | + tool_calls: None, |
| 95 | + annotations: None, |
| 96 | + function_call: None, |
| 97 | + audio: None, |
| 98 | + }, |
92 | 99 | finish_reason: None, |
| 100 | + logprobs: None, |
93 | 101 | }], |
94 | | - usage: None, |
95 | 102 | system_fingerprint: None, |
96 | 103 | }) |
97 | 104 | } |
|
0 commit comments