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
b89f9296
authored
Oct 03, 2025
by
Seefs
Committed by
GitHub
Oct 03, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1959 from RedwindA/feat/silicon-fim
feat: Allow FIM chat requests without messages
parents
ca3304a8
2c669cce
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
+13
-1
relay/channel/siliconflow/adaptor.go
+10
-0
relay/helper/valid_request.go
+3
-1
No files found.
relay/channel/siliconflow/adaptor.go
View file @
b89f9296
...
@@ -61,6 +61,16 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *rel
...
@@ -61,6 +61,16 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *rel
}
}
func
(
a
*
Adaptor
)
ConvertOpenAIRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
*
dto
.
GeneralOpenAIRequest
)
(
any
,
error
)
{
func
(
a
*
Adaptor
)
ConvertOpenAIRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
*
dto
.
GeneralOpenAIRequest
)
(
any
,
error
)
{
// SiliconFlow requires messages array for FIM requests, even if client doesn't send it
if
(
request
.
Prefix
!=
nil
||
request
.
Suffix
!=
nil
)
&&
len
(
request
.
Messages
)
==
0
{
// Add an empty user message to satisfy SiliconFlow's requirement
request
.
Messages
=
[]
dto
.
Message
{
{
Role
:
"user"
,
Content
:
""
,
},
}
}
return
request
,
nil
return
request
,
nil
}
}
...
...
relay/helper/valid_request.go
View file @
b89f9296
...
@@ -275,7 +275,9 @@ func GetAndValidateTextRequest(c *gin.Context, relayMode int) (*dto.GeneralOpenA
...
@@ -275,7 +275,9 @@ func GetAndValidateTextRequest(c *gin.Context, relayMode int) (*dto.GeneralOpenA
return
nil
,
errors
.
New
(
"field prompt is required"
)
return
nil
,
errors
.
New
(
"field prompt is required"
)
}
}
case
relayconstant
.
RelayModeChatCompletions
:
case
relayconstant
.
RelayModeChatCompletions
:
if
len
(
textRequest
.
Messages
)
==
0
{
// For FIM (Fill-in-the-middle) requests with prefix/suffix, messages is optional
// It will be filled by provider-specific adaptors if needed (e.g., SiliconFlow)。Or it is allowed by model vendor(s) (e.g., DeepSeek)
if
len
(
textRequest
.
Messages
)
==
0
&&
textRequest
.
Prefix
==
nil
&&
textRequest
.
Suffix
==
nil
{
return
nil
,
errors
.
New
(
"field messages is required"
)
return
nil
,
errors
.
New
(
"field messages is required"
)
}
}
case
relayconstant
.
RelayModeEmbeddings
:
case
relayconstant
.
RelayModeEmbeddings
:
...
...
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