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
1768c00b
Unverified
Commit
1768c00b
authored
Aug 06, 2024
by
drbh
Committed by
GitHub
Aug 06, 2024
Browse files
feat: return the generated text when parsing fails (#2353)
parent
f8a5b381
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
router/src/server.rs
router/src/server.rs
+7
-3
No files found.
router/src/server.rs
View file @
1768c00b
...
@@ -1246,9 +1246,13 @@ async fn chat_completions(
...
@@ -1246,9 +1246,13 @@ async fn chat_completions(
.as_secs
();
.as_secs
();
let
(
tool_calls
,
output
)
=
if
tool_grammar
.is_some
()
{
let
(
tool_calls
,
output
)
=
if
tool_grammar
.is_some
()
{
let
gen_text_value
:
Value
=
serde_json
::
from_str
(
&
generation
.generated_text
)
let
gen_text_value
:
Value
=
.map_err
(|
e
|
InferError
::
ToolError
(
e
.to_string
()))
?
;
serde_json
::
from_str
(
&
generation
.generated_text
)
.map_err
(|
e
|
{
InferError
::
ToolError
(
format!
(
"Failed to parse generated text: {} {:?}"
,
e
,
generation
.generated_text
))
})
?
;
let
function
=
gen_text_value
.get
(
"function"
)
.ok_or
(
InferError
::
ToolError
(
let
function
=
gen_text_value
.get
(
"function"
)
.ok_or
(
InferError
::
ToolError
(
"No function found in generated text"
.to_string
(),
"No function found in generated text"
.to_string
(),
))
?
;
))
?
;
...
...
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