use openai standard response in arch-fc and in gradio client (#62)

* use openai standard response in arch-fc and in gradio client

also fix code bug in usage

* fix int test
This commit is contained in:
Adil Hafeez 2024-09-19 12:19:14 -07:00 committed by GitHub
parent ed6a9139e6
commit 2cd5ec5adf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 89 additions and 133 deletions

View file

@ -61,15 +61,6 @@ pub struct ToolsDefinition {
pub parameters: ToolParameters,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BoltFCResponse {
pub model: String,
pub message: open_ai::Message,
pub done_reason: String,
pub done: bool,
pub resolver_name: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum IntOrString {
@ -118,24 +109,34 @@ pub mod open_ai {
#[serde(skip_serializing_if = "Option::is_none")]
pub model: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Choice {
pub finish_reason: String,
pub index: usize,
pub message: Message,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatCompletionsResponse {
pub usage: Usage,
pub choices: Vec<Choice>,
pub model: String
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Usage {
pub completions_tokens: usize,
pub completion_tokens: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChatCompletionChunkResponse {
pub model: String,
pub choices: Vec<Choice>,
pub choices: Vec<ChunkChoice>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Choice {
pub struct ChunkChoice {
pub delta: Delta,
// TODO: could this be an enum?
pub finish_reason: Option<String>,