up
This commit is contained in:
@@ -107,20 +107,20 @@ type ToolCall struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ChatCompletionResponse struct {
|
type ChatCompletionResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id,omitempty"`
|
||||||
Object string `json:"object"`
|
Object string `json:"object,omitempty"`
|
||||||
Created int `json:"created"`
|
Created int `json:"created,omitempty"`
|
||||||
Model string `json:"model"`
|
Model string `json:"model,omitempty"`
|
||||||
Choices []struct {
|
Choices []struct {
|
||||||
Index int `json:"index"`
|
Index int `json:"index,omitempty"`
|
||||||
Message struct {
|
Message struct {
|
||||||
Role string `json:"role"`
|
Role string `json:"role,omitempty"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content,omitempty"`
|
||||||
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
||||||
} `json:"message"`
|
} `json:"message,omitempty"`
|
||||||
Logprobs string `json:"logprobs"`
|
Logprobs string `json:"logprobs,omitempty"`
|
||||||
FinishReason string `json:"finish_reason"`
|
FinishReason string `json:"finish_reason,omitempty"`
|
||||||
} `json:"choices"`
|
} `json:"choices,omitempty"`
|
||||||
Usage struct {
|
Usage struct {
|
||||||
PromptTokens int `json:"prompt_tokens,omitempty"`
|
PromptTokens int `json:"prompt_tokens,omitempty"`
|
||||||
CompletionTokens int `json:"completion_tokens,omitempty"`
|
CompletionTokens int `json:"completion_tokens,omitempty"`
|
||||||
@@ -346,16 +346,10 @@ func ChatProxy(c *gin.Context, chatReq *ChatCompletionRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
resp.Body = io.NopCloser(bytes.NewBuffer(body))
|
|
||||||
|
|
||||||
for k, v := range resp.Header {
|
for k, v := range resp.Header {
|
||||||
c.Writer.Header().Set(k, v[0])
|
c.Writer.Header().Set(k, v[0])
|
||||||
}
|
}
|
||||||
c.Writer.WriteHeader(resp.StatusCode)
|
c.JSON(http.StatusOK, opiResp)
|
||||||
_, err = io.Copy(c.Writer, resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
usagelog.CompletionCount = tokenizer.NumTokensFromStr(result, chatReq.Model)
|
usagelog.CompletionCount = tokenizer.NumTokensFromStr(result, chatReq.Model)
|
||||||
usagelog.Cost = fmt.Sprintf("%.6f", tokenizer.Cost(usagelog.Model, usagelog.PromptCount, usagelog.CompletionCount))
|
usagelog.Cost = fmt.Sprintf("%.6f", tokenizer.Cost(usagelog.Model, usagelog.PromptCount, usagelog.CompletionCount))
|
||||||
|
|||||||
Reference in New Issue
Block a user