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
604a5b1a
authored
Feb 19, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Enhance Ollama channel support with additional request parameters #771
parent
cc61f85b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
15 deletions
+21
-15
relay/channel/ollama/dto.go
+17
-14
relay/channel/ollama/relay-ollama.go
+3
-0
relay/common/relay_info.go
+1
-1
No files found.
relay/channel/ollama/dto.go
View file @
604a5b1a
...
@@ -3,18 +3,21 @@ package ollama
...
@@ -3,18 +3,21 @@ package ollama
import
"one-api/dto"
import
"one-api/dto"
type
OllamaRequest
struct
{
type
OllamaRequest
struct
{
Model
string
`json:"model,omitempty"`
Model
string
`json:"model,omitempty"`
Messages
[]
dto
.
Message
`json:"messages,omitempty"`
Messages
[]
dto
.
Message
`json:"messages,omitempty"`
Stream
bool
`json:"stream,omitempty"`
Stream
bool
`json:"stream,omitempty"`
Temperature
*
float64
`json:"temperature,omitempty"`
Temperature
*
float64
`json:"temperature,omitempty"`
Seed
float64
`json:"seed,omitempty"`
Seed
float64
`json:"seed,omitempty"`
Topp
float64
`json:"top_p,omitempty"`
Topp
float64
`json:"top_p,omitempty"`
TopK
int
`json:"top_k,omitempty"`
TopK
int
`json:"top_k,omitempty"`
Stop
any
`json:"stop,omitempty"`
Stop
any
`json:"stop,omitempty"`
Tools
[]
dto
.
ToolCall
`json:"tools,omitempty"`
Tools
[]
dto
.
ToolCall
`json:"tools,omitempty"`
ResponseFormat
any
`json:"response_format,omitempty"`
ResponseFormat
any
`json:"response_format,omitempty"`
FrequencyPenalty
float64
`json:"frequency_penalty,omitempty"`
FrequencyPenalty
float64
`json:"frequency_penalty,omitempty"`
PresencePenalty
float64
`json:"presence_penalty,omitempty"`
PresencePenalty
float64
`json:"presence_penalty,omitempty"`
Suffix
any
`json:"suffix,omitempty"`
StreamOptions
*
dto
.
StreamOptions
`json:"stream_options,omitempty"`
Prompt
any
`json:"prompt,omitempty"`
}
}
type
Options
struct
{
type
Options
struct
{
...
@@ -35,7 +38,7 @@ type OllamaEmbeddingRequest struct {
...
@@ -35,7 +38,7 @@ type OllamaEmbeddingRequest struct {
}
}
type
OllamaEmbeddingResponse
struct
{
type
OllamaEmbeddingResponse
struct
{
Error
string
`json:"error,omitempty"`
Error
string
`json:"error,omitempty"`
Model
string
`json:"model"`
Model
string
`json:"model"`
Embedding
[][]
float64
`json:"embeddings,omitempty"`
Embedding
[][]
float64
`json:"embeddings,omitempty"`
}
}
relay/channel/ollama/relay-ollama.go
View file @
604a5b1a
...
@@ -39,6 +39,9 @@ func requestOpenAI2Ollama(request dto.GeneralOpenAIRequest) *OllamaRequest {
...
@@ -39,6 +39,9 @@ func requestOpenAI2Ollama(request dto.GeneralOpenAIRequest) *OllamaRequest {
ResponseFormat
:
request
.
ResponseFormat
,
ResponseFormat
:
request
.
ResponseFormat
,
FrequencyPenalty
:
request
.
FrequencyPenalty
,
FrequencyPenalty
:
request
.
FrequencyPenalty
,
PresencePenalty
:
request
.
PresencePenalty
,
PresencePenalty
:
request
.
PresencePenalty
,
Prompt
:
request
.
Prompt
,
StreamOptions
:
request
.
StreamOptions
,
Suffix
:
request
.
Suffix
,
}
}
}
}
...
...
relay/common/relay_info.go
View file @
604a5b1a
...
@@ -113,7 +113,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
...
@@ -113,7 +113,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
if
info
.
ChannelType
==
common
.
ChannelTypeOpenAI
||
info
.
ChannelType
==
common
.
ChannelTypeAnthropic
||
if
info
.
ChannelType
==
common
.
ChannelTypeOpenAI
||
info
.
ChannelType
==
common
.
ChannelTypeAnthropic
||
info
.
ChannelType
==
common
.
ChannelTypeAws
||
info
.
ChannelType
==
common
.
ChannelTypeGemini
||
info
.
ChannelType
==
common
.
ChannelTypeAws
||
info
.
ChannelType
==
common
.
ChannelTypeGemini
||
info
.
ChannelType
==
common
.
ChannelCloudflare
||
info
.
ChannelType
==
common
.
ChannelTypeAzure
||
info
.
ChannelType
==
common
.
ChannelCloudflare
||
info
.
ChannelType
==
common
.
ChannelTypeAzure
||
info
.
ChannelType
==
common
.
ChannelTypeVolcEngine
{
info
.
ChannelType
==
common
.
ChannelTypeVolcEngine
||
info
.
ChannelType
==
common
.
ChannelTypeOllama
{
info
.
SupportStreamOptions
=
true
info
.
SupportStreamOptions
=
true
}
}
return
info
return
info
...
...
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