mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 17:16:38 +08:00
Compare commits
No commits in common. "974331a028335118d9b1d0384315533f008d4ebe" and "cf0ce425e608ed1a698f3cff5b655bacff0b6f1e" have entirely different histories.
974331a028
...
cf0ce425e6
14
Dockerfile
14
Dockerfile
@ -4,15 +4,13 @@ WORKDIR /web
|
|||||||
COPY ./VERSION .
|
COPY ./VERSION .
|
||||||
COPY ./web .
|
COPY ./web .
|
||||||
|
|
||||||
RUN npm install --prefix /web/default & \
|
RUN npm install --prefix /web/default && \
|
||||||
npm install --prefix /web/berry & \
|
npm install --prefix /web/berry && \
|
||||||
npm install --prefix /web/air & \
|
npm install --prefix /web/air
|
||||||
wait
|
|
||||||
|
|
||||||
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default & \
|
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default && \
|
||||||
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry & \
|
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry && \
|
||||||
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air & \
|
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air
|
||||||
wait
|
|
||||||
|
|
||||||
FROM golang:alpine AS builder2
|
FROM golang:alpine AS builder2
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package file
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/base64"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetFileFromUrl(url string) (mimeType string, data string, err error) {
|
|
||||||
resp, err := http.Get(url)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
buffer := bytes.NewBuffer(nil)
|
|
||||||
_, err = buffer.ReadFrom(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mimeType = resp.Header.Get("Content-Type")
|
|
||||||
data = base64.StdEncoding.EncodeToString(buffer.Bytes())
|
|
||||||
return
|
|
||||||
}
|
|
@ -36,12 +36,6 @@ func ConvertRequest(request model.GeneralOpenAIRequest) *ChatRequest {
|
|||||||
enableSearch = true
|
enableSearch = true
|
||||||
aliModel = strings.TrimSuffix(aliModel, EnableSearchModelSuffix)
|
aliModel = strings.TrimSuffix(aliModel, EnableSearchModelSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
enableThinking := false
|
|
||||||
if request.ReasoningEffort != nil {
|
|
||||||
enableThinking = true
|
|
||||||
}
|
|
||||||
|
|
||||||
request.TopP = helper.Float64PtrMax(request.TopP, 0.9999)
|
request.TopP = helper.Float64PtrMax(request.TopP, 0.9999)
|
||||||
return &ChatRequest{
|
return &ChatRequest{
|
||||||
Model: aliModel,
|
Model: aliModel,
|
||||||
@ -58,7 +52,6 @@ func ConvertRequest(request model.GeneralOpenAIRequest) *ChatRequest {
|
|||||||
TopK: request.TopK,
|
TopK: request.TopK,
|
||||||
ResultFormat: "message",
|
ResultFormat: "message",
|
||||||
Tools: request.Tools,
|
Tools: request.Tools,
|
||||||
EnableThinking: enableThinking,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ type Parameters struct {
|
|||||||
Temperature *float64 `json:"temperature,omitempty"`
|
Temperature *float64 `json:"temperature,omitempty"`
|
||||||
ResultFormat string `json:"result_format,omitempty"`
|
ResultFormat string `json:"result_format,omitempty"`
|
||||||
Tools []model.Tool `json:"tools,omitempty"`
|
Tools []model.Tool `json:"tools,omitempty"`
|
||||||
EnableThinking bool `json:"enable_thinking,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatRequest struct {
|
type ChatRequest struct {
|
||||||
|
@ -17,5 +17,4 @@ var ModelList = []string{
|
|||||||
|
|
||||||
"deepseek-r1",
|
"deepseek-r1",
|
||||||
"deepseek-v3",
|
"deepseek-v3",
|
||||||
"deepseek-v3.1",
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
"github.com/songquanpeng/one-api/common"
|
"github.com/songquanpeng/one-api/common"
|
||||||
"github.com/songquanpeng/one-api/common/config"
|
"github.com/songquanpeng/one-api/common/config"
|
||||||
"github.com/songquanpeng/one-api/common/file"
|
|
||||||
"github.com/songquanpeng/one-api/common/helper"
|
"github.com/songquanpeng/one-api/common/helper"
|
||||||
"github.com/songquanpeng/one-api/common/image"
|
"github.com/songquanpeng/one-api/common/image"
|
||||||
"github.com/songquanpeng/one-api/common/logger"
|
"github.com/songquanpeng/one-api/common/logger"
|
||||||
@ -119,14 +118,6 @@ func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest {
|
|||||||
parts = append(parts, Part{
|
parts = append(parts, Part{
|
||||||
Text: part.Text,
|
Text: part.Text,
|
||||||
})
|
})
|
||||||
} else if part.Type == model.ContentTypeInputFile {
|
|
||||||
mimeType, data, _ := file.GetFileFromUrl(part.File.FileData)
|
|
||||||
parts = append(parts, Part{
|
|
||||||
InlineData: &InlineData{
|
|
||||||
MimeType: mimeType,
|
|
||||||
Data: data,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else if part.Type == model.ContentTypeImageURL {
|
} else if part.Type == model.ContentTypeImageURL {
|
||||||
imageNum += 1
|
imageNum += 1
|
||||||
if imageNum > VisionMaxImageNum {
|
if imageNum > VisionMaxImageNum {
|
||||||
|
@ -40,11 +40,6 @@ type InlineData struct {
|
|||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileData struct {
|
|
||||||
MimeType string `json:"mime_type"`
|
|
||||||
FileUri string `json:"file_uri"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type FunctionCall struct {
|
type FunctionCall struct {
|
||||||
FunctionName string `json:"name"`
|
FunctionName string `json:"name"`
|
||||||
Arguments any `json:"args"`
|
Arguments any `json:"args"`
|
||||||
@ -55,7 +50,6 @@ type Part struct {
|
|||||||
InlineData *InlineData `json:"inlineData,omitempty"`
|
InlineData *InlineData `json:"inlineData,omitempty"`
|
||||||
FunctionCall *FunctionCall `json:"functionCall,omitempty"`
|
FunctionCall *FunctionCall `json:"functionCall,omitempty"`
|
||||||
Thought bool `json:"thought,omitempty"`
|
Thought bool `json:"thought,omitempty"`
|
||||||
FileData *FileData `json:"fileData,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatContent struct {
|
type ChatContent struct {
|
||||||
|
@ -4,5 +4,4 @@ const (
|
|||||||
ContentTypeText = "text"
|
ContentTypeText = "text"
|
||||||
ContentTypeImageURL = "image_url"
|
ContentTypeImageURL = "image_url"
|
||||||
ContentTypeInputAudio = "input_audio"
|
ContentTypeInputAudio = "input_audio"
|
||||||
ContentTypeInputFile = "file"
|
|
||||||
)
|
)
|
||||||
|
@ -121,15 +121,6 @@ func (m Message) ParseContent() []MessageContent {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
case ContentTypeInputFile:
|
|
||||||
if subObj, ok := contentMap["file"].(map[string]any); ok {
|
|
||||||
contentList = append(contentList, MessageContent{
|
|
||||||
Type: ContentTypeInputFile,
|
|
||||||
File: &File{
|
|
||||||
FileData: subObj["file_data"].(string),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contentList
|
return contentList
|
||||||
@ -146,10 +137,4 @@ type MessageContent struct {
|
|||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
ImageURL *ImageURL `json:"image_url,omitempty"`
|
ImageURL *ImageURL `json:"image_url,omitempty"`
|
||||||
File *File `json:"file,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type File struct {
|
|
||||||
FileData string `json:"file_data,omitempty"`
|
|
||||||
FileName string `json:"filename,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user