mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-12-05 03:58:18 +00:00
Add assistant api
This commit is contained in:
@@ -6,35 +6,14 @@ use std::collections::HashMap;
|
||||
use crate::impl_builder_methods;
|
||||
use crate::v1::common;
|
||||
|
||||
// https://platform.openai.com/docs/models/gpt-3-5
|
||||
pub const GPT3_5_TURBO_1106: &str = "gpt-3.5-turbo-1106";
|
||||
pub const GPT3_5_TURBO: &str = "gpt-3.5-turbo";
|
||||
pub const GPT3_5_TURBO_16K: &str = "gpt-3.5-turbo-16k";
|
||||
pub const GPT3_5_TURBO_INSTRUCT: &str = "gpt-3.5-turbo-instruct";
|
||||
// - legacy
|
||||
pub const GPT3_5_TURBO_0613: &str = "gpt-3.5-turbo-0613";
|
||||
pub const GPT3_5_TURBO_16K_0613: &str = "gpt-3.5-turbo-16k-0613";
|
||||
pub const GPT3_5_TURBO_0301: &str = "gpt-3.5-turbo-0301";
|
||||
|
||||
// https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
|
||||
pub const GPT4_1106_PREVIEW: &str = "gpt-4-1106-preview";
|
||||
pub const GPT4_VISION_PREVIEW: &str = "gpt-4-vision-preview";
|
||||
pub const GPT4: &str = "gpt-4";
|
||||
pub const GPT4_32K: &str = "gpt-4-32k";
|
||||
pub const GPT4_0613: &str = "gpt-4-0613";
|
||||
pub const GPT4_32K_0613: &str = "gpt-4-32k-0613";
|
||||
// - legacy
|
||||
pub const GPT4_0314: &str = "gpt-4-0314";
|
||||
pub const GPT4_32K_0314: &str = "gpt-4-32k-0314";
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
pub enum FunctionCallType {
|
||||
None,
|
||||
Auto,
|
||||
Function { name: String },
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
pub struct ChatCompletionRequest {
|
||||
pub model: String,
|
||||
pub messages: Vec<ChatCompletionMessage>,
|
||||
@@ -153,7 +132,7 @@ pub struct ChatCompletionResponse {
|
||||
pub usage: common::Usage,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Function {
|
||||
pub name: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -161,7 +140,7 @@ pub struct Function {
|
||||
pub parameters: FunctionParameters,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum JSONSchemaType {
|
||||
Object,
|
||||
@@ -172,7 +151,7 @@ pub enum JSONSchemaType {
|
||||
Boolean,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct JSONSchemaDefine {
|
||||
#[serde(rename = "type")]
|
||||
pub schema_type: Option<JSONSchemaType>,
|
||||
@@ -188,7 +167,7 @@ pub struct JSONSchemaDefine {
|
||||
pub items: Option<Box<JSONSchemaDefine>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct FunctionParameters {
|
||||
#[serde(rename = "type")]
|
||||
pub schema_type: JSONSchemaType,
|
||||
|
||||
Reference in New Issue
Block a user