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
288f2793
authored
Jun 16, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔧
refactor(relay): replace UUID generation with helper function for response IDs
parent
abceadcc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
7 deletions
+6
-7
relay/channel/cohere/relay-cohere.go
+1
-2
relay/channel/gemini/relay-gemini.go
+4
-4
relay/channel/palm/relay-palm.go
+1
-1
No files found.
relay/channel/cohere/relay-cohere.go
View file @
288f2793
...
...
@@ -3,7 +3,6 @@ package cohere
import
(
"bufio"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"io"
"net/http"
...
...
@@ -78,7 +77,7 @@ func stopReasonCohere2OpenAI(reason string) string {
}
func
cohereStreamHandler
(
c
*
gin
.
Context
,
resp
*
http
.
Response
,
info
*
relaycommon
.
RelayInfo
)
(
*
dto
.
OpenAIErrorWithStatusCode
,
*
dto
.
Usage
)
{
responseId
:=
fmt
.
Sprintf
(
"chatcmpl-%s"
,
common
.
GetUUID
()
)
responseId
:=
helper
.
GetResponseID
(
c
)
createdTime
:=
common
.
GetTimestamp
()
usage
:=
&
dto
.
Usage
{}
responseText
:=
""
...
...
relay/channel/gemini/relay-gemini.go
View file @
288f2793
...
...
@@ -611,9 +611,9 @@ func getResponseToolCall(item *GeminiPart) *dto.ToolCallResponse {
}
}
func
responseGeminiChat2OpenAI
(
response
*
GeminiChatResponse
)
*
dto
.
OpenAITextResponse
{
func
responseGeminiChat2OpenAI
(
c
*
gin
.
Context
,
response
*
GeminiChatResponse
)
*
dto
.
OpenAITextResponse
{
fullTextResponse
:=
dto
.
OpenAITextResponse
{
Id
:
fmt
.
Sprintf
(
"chatcmpl-%s"
,
common
.
GetUUID
()
),
Id
:
helper
.
GetResponseID
(
c
),
Object
:
"chat.completion"
,
Created
:
common
.
GetTimestamp
(),
Choices
:
make
([]
dto
.
OpenAITextResponseChoice
,
0
,
len
(
response
.
Candidates
)),
...
...
@@ -754,7 +754,7 @@ func streamResponseGeminiChat2OpenAI(geminiResponse *GeminiChatResponse) (*dto.C
func
GeminiChatStreamHandler
(
c
*
gin
.
Context
,
resp
*
http
.
Response
,
info
*
relaycommon
.
RelayInfo
)
(
*
dto
.
OpenAIErrorWithStatusCode
,
*
dto
.
Usage
)
{
// responseText := ""
id
:=
fmt
.
Sprintf
(
"chatcmpl-%s"
,
common
.
GetUUID
()
)
id
:=
helper
.
GetResponseID
(
c
)
createAt
:=
common
.
GetTimestamp
()
var
usage
=
&
dto
.
Usage
{}
var
imageCount
int
...
...
@@ -849,7 +849,7 @@ func GeminiChatHandler(c *gin.Context, resp *http.Response, info *relaycommon.Re
StatusCode
:
resp
.
StatusCode
,
},
nil
}
fullTextResponse
:=
responseGeminiChat2OpenAI
(
&
geminiResponse
)
fullTextResponse
:=
responseGeminiChat2OpenAI
(
c
,
&
geminiResponse
)
fullTextResponse
.
Model
=
info
.
UpstreamModelName
usage
:=
dto
.
Usage
{
PromptTokens
:
geminiResponse
.
UsageMetadata
.
PromptTokenCount
,
...
...
relay/channel/palm/relay-palm.go
View file @
288f2793
...
...
@@ -73,7 +73,7 @@ func streamResponsePaLM2OpenAI(palmResponse *PaLMChatResponse) *dto.ChatCompleti
func
palmStreamHandler
(
c
*
gin
.
Context
,
resp
*
http
.
Response
)
(
*
dto
.
OpenAIErrorWithStatusCode
,
string
)
{
responseText
:=
""
responseId
:=
fmt
.
Sprintf
(
"chatcmpl-%s"
,
common
.
GetUUID
()
)
responseId
:=
helper
.
GetResponseID
(
c
)
createdTime
:=
common
.
GetTimestamp
()
dataChan
:=
make
(
chan
string
)
stopChan
:=
make
(
chan
bool
)
...
...
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