mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-18 23:25:10 +08:00
feat: Introduce standard request normalization and response building for OpenAI and Claude, enhance tool call streaming, and improve caller identification.
This commit is contained in:
30
internal/util/standard_request.go
Normal file
30
internal/util/standard_request.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package util
|
||||
|
||||
type StandardRequest struct {
|
||||
Surface string
|
||||
RequestedModel string
|
||||
ResolvedModel string
|
||||
ResponseModel string
|
||||
Messages []any
|
||||
FinalPrompt string
|
||||
ToolNames []string
|
||||
Stream bool
|
||||
Thinking bool
|
||||
Search bool
|
||||
PassThrough map[string]any
|
||||
}
|
||||
|
||||
func (r StandardRequest) CompletionPayload(sessionID string) map[string]any {
|
||||
payload := map[string]any{
|
||||
"chat_session_id": sessionID,
|
||||
"parent_message_id": nil,
|
||||
"prompt": r.FinalPrompt,
|
||||
"ref_file_ids": []any{},
|
||||
"thinking_enabled": r.Thinking,
|
||||
"search_enabled": r.Search,
|
||||
}
|
||||
for k, v := range r.PassThrough {
|
||||
payload[k] = v
|
||||
}
|
||||
return payload
|
||||
}
|
||||
Reference in New Issue
Block a user