mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 17:16:38 +08:00
Merge db3de1d80c
into c96895e35b
This commit is contained in:
commit
6ab301b340
@ -7,9 +7,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetRequestURL(meta *meta.Meta) (string, error) {
|
func GetRequestURL(meta *meta.Meta) (string, error) {
|
||||||
|
var context = ""
|
||||||
|
if meta.Cache {
|
||||||
|
context = "context/"
|
||||||
|
}
|
||||||
switch meta.Mode {
|
switch meta.Mode {
|
||||||
case relaymode.ChatCompletions:
|
case relaymode.ChatCompletions:
|
||||||
return fmt.Sprintf("%s/api/v3/chat/completions", meta.BaseURL), nil
|
return fmt.Sprintf("%s/api/v3/%schat/completions", meta.BaseURL, context), nil
|
||||||
case relaymode.Embeddings:
|
case relaymode.Embeddings:
|
||||||
return fmt.Sprintf("%s/api/v3/embeddings", meta.BaseURL), nil
|
return fmt.Sprintf("%s/api/v3/embeddings", meta.BaseURL), nil
|
||||||
default:
|
default:
|
||||||
|
@ -32,6 +32,7 @@ func RelayTextHelper(c *gin.Context) *model.ErrorWithStatusCode {
|
|||||||
return openai.ErrorWrapper(err, "invalid_text_request", http.StatusBadRequest)
|
return openai.ErrorWrapper(err, "invalid_text_request", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
meta.IsStream = textRequest.Stream
|
meta.IsStream = textRequest.Stream
|
||||||
|
meta.Cache = len(textRequest.ContextId) > 0
|
||||||
|
|
||||||
// map model name
|
// map model name
|
||||||
meta.OriginModelName = textRequest.Model
|
meta.OriginModelName = textRequest.Model
|
||||||
|
@ -34,6 +34,7 @@ type Meta struct {
|
|||||||
RequestURLPath string
|
RequestURLPath string
|
||||||
PromptTokens int // only for DoResponse
|
PromptTokens int // only for DoResponse
|
||||||
SystemPrompt string
|
SystemPrompt string
|
||||||
|
Cache bool
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ type GeneralOpenAIRequest struct {
|
|||||||
// Others
|
// Others
|
||||||
Instruction string `json:"instruction,omitempty"`
|
Instruction string `json:"instruction,omitempty"`
|
||||||
NumCtx int `json:"num_ctx,omitempty"`
|
NumCtx int `json:"num_ctx,omitempty"`
|
||||||
|
// SessionCache or PrefixCache context id
|
||||||
|
ContextId string `json:"context_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r GeneralOpenAIRequest) ParseInput() []string {
|
func (r GeneralOpenAIRequest) ParseInput() []string {
|
||||||
|
Loading…
Reference in New Issue
Block a user