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
87ebb647
Unverified
Commit
87ebb647
authored
Jul 08, 2024
by
drbh
Committed by
GitHub
Jul 08, 2024
Browse files
feat: use model name as adapter id in chat endpoints (#2128)
parent
58effe78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
router/src/lib.rs
router/src/lib.rs
+2
-2
router/src/server.rs
router/src/server.rs
+4
-2
No files found.
router/src/lib.rs
View file @
87ebb647
...
@@ -384,7 +384,7 @@ pub struct CompletionRequest {
...
@@ -384,7 +384,7 @@ pub struct CompletionRequest {
/// UNUSED
/// UNUSED
#[schema(example
=
"mistralai/Mistral-7B-Instruct-v0.2"
)]
#[schema(example
=
"mistralai/Mistral-7B-Instruct-v0.2"
)]
/// ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
/// ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
pub
model
:
String
,
pub
model
:
Option
<
String
>
,
/// The prompt to generate completions for.
/// The prompt to generate completions for.
#[schema(example
=
"What is Deep Learning?"
)]
#[schema(example
=
"What is Deep Learning?"
)]
...
@@ -731,7 +731,7 @@ impl ChatCompletionChunk {
...
@@ -731,7 +731,7 @@ impl ChatCompletionChunk {
pub
(
crate
)
struct
ChatRequest
{
pub
(
crate
)
struct
ChatRequest
{
#[schema(example
=
"mistralai/Mistral-7B-Instruct-v0.2"
)]
#[schema(example
=
"mistralai/Mistral-7B-Instruct-v0.2"
)]
/// [UNUSED] ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
/// [UNUSED] ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
pub
model
:
String
,
pub
model
:
Option
<
String
>
,
/// A list of messages comprising the conversation so far.
/// A list of messages comprising the conversation so far.
#[schema(example
=
"[{
\"
role
\"
:
\"
user
\"
,
\"
content
\"
:
\"
What is Deep Learning?
\"
}]"
)]
#[schema(example
=
"[{
\"
role
\"
:
\"
user
\"
,
\"
content
\"
:
\"
What is Deep Learning?
\"
}]"
)]
...
...
router/src/server.rs
View file @
87ebb647
...
@@ -597,6 +597,7 @@ async fn completions(
...
@@ -597,6 +597,7 @@ async fn completions(
metrics
::
counter!
(
"tgi_request_count"
)
.increment
(
1
);
metrics
::
counter!
(
"tgi_request_count"
)
.increment
(
1
);
let
CompletionRequest
{
let
CompletionRequest
{
model
,
max_tokens
,
max_tokens
,
seed
,
seed
,
stop
,
stop
,
...
@@ -665,7 +666,7 @@ async fn completions(
...
@@ -665,7 +666,7 @@ async fn completions(
seed
,
seed
,
top_n_tokens
:
None
,
top_n_tokens
:
None
,
grammar
:
None
,
grammar
:
None
,
..
Default
::
default
()
adapter_id
:
model
.as_ref
()
.filter
(|
m
|
*
m
!=
"tgi"
)
.map
(
String
::
from
),
},
},
})
})
.collect
();
.collect
();
...
@@ -1001,6 +1002,7 @@ async fn chat_completions(
...
@@ -1001,6 +1002,7 @@ async fn chat_completions(
let
span
=
tracing
::
Span
::
current
();
let
span
=
tracing
::
Span
::
current
();
metrics
::
counter!
(
"tgi_request_count"
)
.increment
(
1
);
metrics
::
counter!
(
"tgi_request_count"
)
.increment
(
1
);
let
ChatRequest
{
let
ChatRequest
{
model
,
logprobs
,
logprobs
,
max_tokens
,
max_tokens
,
messages
,
messages
,
...
@@ -1106,7 +1108,7 @@ async fn chat_completions(
...
@@ -1106,7 +1108,7 @@ async fn chat_completions(
seed
,
seed
,
top_n_tokens
:
req
.top_logprobs
,
top_n_tokens
:
req
.top_logprobs
,
grammar
,
grammar
,
..
Default
::
default
()
adapter_id
:
model
.filter
(|
m
|
*
m
!=
"tgi"
)
.map
(
String
::
from
),
},
},
};
};
...
...
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