调整结构合并
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
pub mod queue;
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub struct ChatCompletionRequestBody {
|
||||||
|
pub model: String,
|
||||||
|
pub messages: Vec<ChatCompletionRequestMessage>,
|
||||||
|
pub stream: bool,
|
||||||
|
pub tools: Vec<serde_json::Value>,
|
||||||
|
pub extra_body: Option<ChatCompletionRequestExtra>,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub struct ChatCompletionRequestExtra {
|
||||||
|
pub thinking: ChatCompletionRequestThinking,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub struct ChatCompletionRequestThinking {
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub thinking_type: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
pub struct ChatCompletionRequestMessage {
|
||||||
|
pub role: String,
|
||||||
|
pub content: String,
|
||||||
|
pub tool_call_id: Option<String>,
|
||||||
|
pub tool_calls: Option<Vec<ChatCompletionToolCall>>,
|
||||||
|
}
|
||||||
|
impl ChatCompletionRequestMessage {
|
||||||
|
pub fn new(role: String, content: String) -> Self {
|
||||||
|
Self {
|
||||||
|
role,
|
||||||
|
content,
|
||||||
|
tool_call_id: None,
|
||||||
|
tool_calls: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn assistant(
|
||||||
|
role: String,
|
||||||
|
content: String,
|
||||||
|
tool_calls: Option<Vec<ChatCompletionToolCall>>,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
role,
|
||||||
|
content,
|
||||||
|
tool_call_id: None,
|
||||||
|
tool_calls: tool_calls,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn tool(role: String, content: String, tool_call_id: String) -> Self {
|
||||||
|
Self {
|
||||||
|
role,
|
||||||
|
content,
|
||||||
|
tool_call_id: Some(tool_call_id),
|
||||||
|
tool_calls: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// {"choices":[{"finish_reason":"stop","index":0,"logprobs":null,"message":{"content":"你好!😊 有什么我可以帮你的吗?","role":"assistant"}}],"created":1782208455,"id":"02178220845277286f296e4c58ddf650991f54d763d292af8529b","model":"deepseek-v4-flash-260425","service_tier":"default","object":"chat.completion","usage":{"prompt_tokens":2005,"completion_tokens":125,"total_tokens":2130,"prompt_tokens_details":{"cached_tokens":0},"completion_tokens_details":{"reasoning_tokens":114}}}
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatCompletionResponseBody {
|
||||||
|
id: String,
|
||||||
|
object: String,
|
||||||
|
created: i64,
|
||||||
|
model: String,
|
||||||
|
service_tier: String,
|
||||||
|
pub choices: Vec<ChatCompletionResponseChoice>,
|
||||||
|
pub usage: ChatCompletionUsage,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatCompletionResponseChoice {
|
||||||
|
index: u32,
|
||||||
|
pub message: ChatCompletionResponseMessage,
|
||||||
|
logprobs: Option<serde_json::Value>,
|
||||||
|
finish_reason: String,
|
||||||
|
}
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatCompletionResponseMessage {
|
||||||
|
pub role: String,
|
||||||
|
pub content: String,
|
||||||
|
pub reasoning_content: Option<String>,
|
||||||
|
pub tool_calls: Option<Vec<ChatCompletionToolCall>>,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct ChatCompletionToolCall {
|
||||||
|
pub function: Option<ChatCompletionFunction>,
|
||||||
|
pub id: String,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub call_type: String,
|
||||||
|
}
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct ChatCompletionFunction {
|
||||||
|
pub arguments: String,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatCompletionUsage {
|
||||||
|
pub prompt_tokens: u32,
|
||||||
|
pub completion_tokens: u32,
|
||||||
|
pub total_tokens: u32,
|
||||||
|
pub prompt_tokens_details: ChatCompletionUsagePrompt,
|
||||||
|
pub completion_tokens_details: ChatCompletionUsageCompletion,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatCompletionUsagePrompt {
|
||||||
|
pub cached_tokens: u32,
|
||||||
|
}
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatCompletionUsageCompletion {
|
||||||
|
pub reasoning_tokens: u32,
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
pub mod ai;
|
||||||
Reference in New Issue
Block a user