Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cdcf2184
authored
Nov 06, 2024
by
Calcium-Ion
Committed by
GitHub
Nov 06, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #555 from utopeadia/main
Continue fixing Ollama embedding return issue
parents
0c6ed775
0788a6c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
relay/channel/ollama/dto.go
+1
-1
relay/channel/ollama/relay-ollama.go
+11
-1
No files found.
relay/channel/ollama/dto.go
View file @
cdcf2184
...
...
@@ -37,5 +37,5 @@ type OllamaEmbeddingRequest struct {
type
OllamaEmbeddingResponse
struct
{
Error
string
`json:"error,omitempty"`
Model
string
`json:"model"`
Embedding
[]
float64
`json:"embeddings,omitempty"`
Embedding
[]
[]
float64
`json:"embeddings,omitempty"`
}
relay/channel/ollama/relay-ollama.go
View file @
cdcf2184
...
...
@@ -73,9 +73,10 @@ func ollamaEmbeddingHandler(c *gin.Context, resp *http.Response, promptTokens in
if
ollamaEmbeddingResponse
.
Error
!=
""
{
return
service
.
OpenAIErrorWrapper
(
err
,
"ollama_error"
,
resp
.
StatusCode
),
nil
}
flattenedEmbeddings
:=
flattenEmbeddings
(
ollamaEmbeddingResponse
.
Embedding
)
data
:=
make
([]
dto
.
OpenAIEmbeddingResponseItem
,
0
,
1
)
data
=
append
(
data
,
dto
.
OpenAIEmbeddingResponseItem
{
Embedding
:
ollamaEmbeddingResponse
.
Embedding
,
Embedding
:
flattenedEmbeddings
,
Object
:
"embedding"
,
})
usage
:=
&
dto
.
Usage
{
...
...
@@ -120,3 +121,11 @@ func ollamaEmbeddingHandler(c *gin.Context, resp *http.Response, promptTokens in
}
return
nil
,
usage
}
func
flattenEmbeddings
(
embeddings
[][]
float64
)
[]
float64
{
flattened
:=
[]
float64
{}
for
_
,
row
:=
range
embeddings
{
flattened
=
append
(
flattened
,
row
...
)
}
return
flattened
}
\ No newline at end of file
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