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
ollama
Commits
41ba3017
Unverified
Commit
41ba3017
authored
May 11, 2024
by
Jeffrey Morgan
Committed by
GitHub
May 11, 2024
Browse files
Fix OpenAI `finish_reason` values when empty (#4368)
parent
8080fbce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
openai/openai.go
openai/openai.go
+18
-10
No files found.
openai/openai.go
View file @
41ba3017
...
...
@@ -109,7 +109,12 @@ func toChatCompletion(id string, r api.ChatResponse) ChatCompletion {
Choices
:
[]
Choice
{{
Index
:
0
,
Message
:
Message
{
Role
:
r
.
Message
.
Role
,
Content
:
r
.
Message
.
Content
},
FinishReason
:
&
r
.
DoneReason
,
FinishReason
:
func
(
reason
string
)
*
string
{
if
len
(
reason
)
>
0
{
return
&
reason
}
return
nil
}(
r
.
DoneReason
),
}},
Usage
:
Usage
{
// TODO: ollama returns 0 for prompt eval if the prompt was cached, but openai returns the actual count
...
...
@@ -127,13 +132,16 @@ func toChunk(id string, r api.ChatResponse) ChatCompletionChunk {
Created
:
time
.
Now
()
.
Unix
(),
Model
:
r
.
Model
,
SystemFingerprint
:
"fp_ollama"
,
Choices
:
[]
ChunkChoice
{
{
Choices
:
[]
ChunkChoice
{{
Index
:
0
,
Delta
:
Message
{
Role
:
"assistant"
,
Content
:
r
.
Message
.
Content
},
FinishReason
:
&
r
.
DoneReason
,
},
},
FinishReason
:
func
(
reason
string
)
*
string
{
if
len
(
reason
)
>
0
{
return
&
reason
}
return
nil
}(
r
.
DoneReason
),
}},
}
}
...
...
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