Revert "Fixing missing `object` field for regular completions."
This reverts commit 2bbb7fa4b2
.
This commit is contained in:
parent
2bbb7fa4b2
commit
be4a4c47f9
|
@ -946,38 +946,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Chunk": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"created",
|
|
||||||
"choices",
|
|
||||||
"model",
|
|
||||||
"system_fingerprint"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"choices": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/CompletionComplete"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"created": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "int64",
|
|
||||||
"minimum": 0
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"model": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"system_fingerprint": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CompatGenerateRequest": {
|
"CompatGenerateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -997,55 +965,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Completion": {
|
|
||||||
"oneOf": [
|
|
||||||
{
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/components/schemas/Chunk"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"object"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"object": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"text_completion"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/components/schemas/CompletionFinal"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"object"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"object": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"text_completion"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"discriminator": {
|
|
||||||
"propertyName": "object"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CompletionComplete": {
|
"CompletionComplete": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -1075,15 +994,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CompletionFinal": {
|
"CompletionCompleteChunk": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
"created",
|
"created",
|
||||||
"model",
|
|
||||||
"system_fingerprint",
|
|
||||||
"choices",
|
"choices",
|
||||||
"usage"
|
"model",
|
||||||
|
"system_fingerprint"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"choices": {
|
"choices": {
|
||||||
|
@ -1095,21 +1013,16 @@
|
||||||
"created": {
|
"created": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64",
|
"format": "int64",
|
||||||
"example": "1706270835",
|
|
||||||
"minimum": 0
|
"minimum": 0
|
||||||
},
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"model": {
|
"model": {
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"example": "mistralai/Mistral-7B-Instruct-v0.2"
|
|
||||||
},
|
},
|
||||||
"system_fingerprint": {
|
"system_fingerprint": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
|
||||||
"usage": {
|
|
||||||
"$ref": "#/components/schemas/Usage"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -433,17 +433,8 @@ pub struct CompletionRequest {
|
||||||
pub stop: Option<Vec<String>>,
|
pub stop: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, ToSchema)]
|
|
||||||
#[serde(tag = "object")]
|
|
||||||
enum Completion {
|
|
||||||
#[serde(rename = "text_completion")]
|
|
||||||
Chunk(Chunk),
|
|
||||||
#[serde(rename = "text_completion")]
|
|
||||||
Final(CompletionFinal),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize, ToSchema, Default)]
|
#[derive(Clone, Deserialize, Serialize, ToSchema, Default)]
|
||||||
pub(crate) struct CompletionFinal {
|
pub(crate) struct Completion {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
#[schema(example = "1706270835")]
|
#[schema(example = "1706270835")]
|
||||||
pub created: u64,
|
pub created: u64,
|
||||||
|
@ -462,15 +453,6 @@ pub(crate) struct CompletionComplete {
|
||||||
pub finish_reason: String,
|
pub finish_reason: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize, ToSchema)]
|
|
||||||
pub(crate) struct Chunk {
|
|
||||||
pub id: String,
|
|
||||||
pub created: u64,
|
|
||||||
pub choices: Vec<CompletionComplete>,
|
|
||||||
pub model: String,
|
|
||||||
pub system_fingerprint: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize, ToSchema)]
|
#[derive(Clone, Deserialize, Serialize, ToSchema)]
|
||||||
pub(crate) struct ChatCompletion {
|
pub(crate) struct ChatCompletion {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
@ -632,6 +614,15 @@ impl ChatCompletion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[derive(Clone, Deserialize, Serialize, ToSchema)]
|
||||||
|
pub(crate) struct CompletionCompleteChunk {
|
||||||
|
pub id: String,
|
||||||
|
pub created: u64,
|
||||||
|
pub choices: Vec<CompletionComplete>,
|
||||||
|
pub model: String,
|
||||||
|
pub system_fingerprint: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, ToSchema)]
|
#[derive(Clone, Serialize, ToSchema)]
|
||||||
pub(crate) struct ChatCompletionChunk {
|
pub(crate) struct ChatCompletionChunk {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::{
|
||||||
use crate::{
|
use crate::{
|
||||||
ChatCompletion, ChatCompletionChoice, ChatCompletionChunk, ChatCompletionComplete,
|
ChatCompletion, ChatCompletionChoice, ChatCompletionChunk, ChatCompletionComplete,
|
||||||
ChatCompletionDelta, ChatCompletionLogprob, ChatCompletionLogprobs, ChatCompletionTopLogprob,
|
ChatCompletionDelta, ChatCompletionLogprob, ChatCompletionLogprobs, ChatCompletionTopLogprob,
|
||||||
ChatRequest, Chunk, CompatGenerateRequest, Completion, CompletionComplete, CompletionFinal,
|
ChatRequest, CompatGenerateRequest, Completion, CompletionComplete, CompletionCompleteChunk,
|
||||||
CompletionRequest, CompletionType, DeltaToolCall, Function, Tool, VertexRequest,
|
CompletionRequest, CompletionType, DeltaToolCall, Function, Tool, VertexRequest,
|
||||||
VertexResponse,
|
VertexResponse,
|
||||||
};
|
};
|
||||||
|
@ -705,7 +705,7 @@ async fn completions(
|
||||||
.as_secs();
|
.as_secs();
|
||||||
|
|
||||||
event
|
event
|
||||||
.json_data(Completion::Chunk(Chunk {
|
.json_data(CompletionCompleteChunk {
|
||||||
id: "".to_string(),
|
id: "".to_string(),
|
||||||
created: current_time,
|
created: current_time,
|
||||||
|
|
||||||
|
@ -718,7 +718,7 @@ async fn completions(
|
||||||
|
|
||||||
model: model_id.clone(),
|
model: model_id.clone(),
|
||||||
system_fingerprint: system_fingerprint.clone(),
|
system_fingerprint: system_fingerprint.clone(),
|
||||||
}))
|
})
|
||||||
.unwrap_or_else(|_e| Event::default())
|
.unwrap_or_else(|_e| Event::default())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -931,7 +931,7 @@ async fn completions(
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
.map_err(|(status, Json(err))| (status, Json(err)))?;
|
.map_err(|(status, Json(err))| (status, Json(err)))?;
|
||||||
|
|
||||||
let response = Completion::Final(CompletionFinal {
|
let response = Completion {
|
||||||
id: "".to_string(),
|
id: "".to_string(),
|
||||||
created: current_time,
|
created: current_time,
|
||||||
model: info.model_id.clone(),
|
model: info.model_id.clone(),
|
||||||
|
@ -946,7 +946,7 @@ async fn completions(
|
||||||
completion_tokens,
|
completion_tokens,
|
||||||
total_tokens,
|
total_tokens,
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
// headers similar to `generate` but aggregated
|
// headers similar to `generate` but aggregated
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
|
@ -1464,9 +1464,7 @@ pub async fn run(
|
||||||
ChatCompletion,
|
ChatCompletion,
|
||||||
CompletionRequest,
|
CompletionRequest,
|
||||||
CompletionComplete,
|
CompletionComplete,
|
||||||
Chunk,
|
CompletionCompleteChunk,
|
||||||
Completion,
|
|
||||||
CompletionFinal,
|
|
||||||
GenerateParameters,
|
GenerateParameters,
|
||||||
PrefillToken,
|
PrefillToken,
|
||||||
Token,
|
Token,
|
||||||
|
|
Loading…
Reference in New Issue