Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
text-generation-inference
Commits
2bbb7fa4
"git@developer.sourcefind.cn:OpenDAS/mmcv.git" did not exist on "d28aa8a9cced3158e724585d5e6839947ca5c449"
Unverified
Commit
2bbb7fa4
authored
Jul 03, 2024
by
Nicolas Patry
Browse files
Fixing missing `object` field for regular completions.
parent
571530dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
20 deletions
+118
-20
docs/openapi.json
docs/openapi.json
+91
-4
router/src/lib.rs
router/src/lib.rs
+19
-10
router/src/server.rs
router/src/server.rs
+8
-6
No files found.
docs/openapi.json
View file @
2bbb7fa4
...
...
@@ -946,6 +946,38 @@
}
}
},
"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"
:
{
"type"
:
"object"
,
"required"
:
[
...
...
@@ -965,6 +997,55 @@
}
}
},
"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"
:
{
"type"
:
"object"
,
"required"
:
[
...
...
@@ -994,14 +1075,15 @@
}
}
},
"Completion
CompleteChunk
"
:
{
"Completion
Final
"
:
{
"type"
:
"object"
,
"required"
:
[
"id"
,
"created"
,
"choices"
,
"model"
,
"system_fingerprint"
"system_fingerprint"
,
"choices"
,
"usage"
],
"properties"
:
{
"choices"
:
{
...
...
@@ -1013,16 +1095,21 @@
"created"
:
{
"type"
:
"integer"
,
"format"
:
"int64"
,
"example"
:
"1706270835"
,
"minimum"
:
0
},
"id"
:
{
"type"
:
"string"
},
"model"
:
{
"type"
:
"string"
"type"
:
"string"
,
"example"
:
"mistralai/Mistral-7B-Instruct-v0.2"
},
"system_fingerprint"
:
{
"type"
:
"string"
},
"usage"
:
{
"$ref"
:
"#/components/schemas/Usage"
}
}
},
...
...
router/src/lib.rs
View file @
2bbb7fa4
...
...
@@ -433,8 +433,17 @@ pub struct CompletionRequest {
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)]
pub
(
crate
)
struct
Completion
{
pub
(
crate
)
struct
Completion
Final
{
pub
id
:
String
,
#[schema(example
=
"1706270835"
)]
pub
created
:
u64
,
...
...
@@ -453,6 +462,15 @@ pub(crate) struct CompletionComplete {
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)]
pub
(
crate
)
struct
ChatCompletion
{
pub
id
:
String
,
...
...
@@ -614,15 +632,6 @@ 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)]
pub
(
crate
)
struct
ChatCompletionChunk
{
pub
id
:
String
,
...
...
router/src/server.rs
View file @
2bbb7fa4
...
...
@@ -19,7 +19,7 @@ use crate::{
use
crate
::{
ChatCompletion
,
ChatCompletionChoice
,
ChatCompletionChunk
,
ChatCompletionComplete
,
ChatCompletionDelta
,
ChatCompletionLogprob
,
ChatCompletionLogprobs
,
ChatCompletionTopLogprob
,
ChatRequest
,
CompatGenerateRequest
,
Completion
,
CompletionComplete
,
Completion
CompleteChunk
,
ChatRequest
,
Chunk
,
CompatGenerateRequest
,
Completion
,
CompletionComplete
,
Completion
Final
,
CompletionRequest
,
CompletionType
,
DeltaToolCall
,
Function
,
Tool
,
VertexRequest
,
VertexResponse
,
};
...
...
@@ -705,7 +705,7 @@ async fn completions(
.as_secs
();
event
.json_data
(
Completion
Complete
Chunk
{
.json_data
(
Completion
::
Chunk
(
Chunk
{
id
:
""
.to_string
(),
created
:
current_time
,
...
...
@@ -718,7 +718,7 @@ async fn completions(
model
:
model_id
.clone
(),
system_fingerprint
:
system_fingerprint
.clone
(),
})
})
)
.unwrap_or_else
(|
_
e
|
Event
::
default
())
};
...
...
@@ -931,7 +931,7 @@ async fn completions(
.collect
::
<
Result
<
Vec
<
_
>
,
_
>>
()
.map_err
(|(
status
,
Json
(
err
))|
(
status
,
Json
(
err
)))
?
;
let
response
=
Completion
{
let
response
=
Completion
::
Final
(
CompletionFinal
{
id
:
""
.to_string
(),
created
:
current_time
,
model
:
info
.model_id
.clone
(),
...
...
@@ -946,7 +946,7 @@ async fn completions(
completion_tokens
,
total_tokens
,
},
};
}
)
;
// headers similar to `generate` but aggregated
let
mut
headers
=
HeaderMap
::
new
();
...
...
@@ -1464,7 +1464,9 @@ pub async fn run(
ChatCompletion,
CompletionRequest,
CompletionComplete,
CompletionCompleteChunk,
Chunk,
Completion,
CompletionFinal,
GenerateParameters,
PrefillToken,
Token,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment