mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-10 02:23:43 +08:00
feat: support gemini-2.0-flash
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -24,13 +25,9 @@ func (a *Adaptor) Init(meta *meta.Meta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
||||||
var defaultVersion string
|
defaultVersion := config.GeminiVersion
|
||||||
switch meta.ActualModelName {
|
if strings.Contains(meta.ActualModelName, "-2.0") {
|
||||||
case "gemini-2.0-flash-exp",
|
|
||||||
"gemini-2.0-flash-thinking-exp-01-21":
|
|
||||||
defaultVersion = "v1beta"
|
defaultVersion = "v1beta"
|
||||||
default:
|
|
||||||
defaultVersion = config.GeminiVersion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version := helper.AssignOrDefault(meta.Config.APIVersion, defaultVersion)
|
version := helper.AssignOrDefault(meta.Config.APIVersion, defaultVersion)
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ package gemini
|
|||||||
|
|
||||||
var ModelList = []string{
|
var ModelList = []string{
|
||||||
"gemini-pro", "gemini-1.0-pro",
|
"gemini-pro", "gemini-1.0-pro",
|
||||||
"gemini-1.5-flash", "gemini-1.5-pro",
|
// "gemma-2-2b-it", "gemma-2-9b-it", "gemma-2-27b-it",
|
||||||
|
"gemini-1.5-flash", "gemini-1.5-flash-8b",
|
||||||
|
"gemini-1.5-pro", "gemini-1.5-pro-experimental",
|
||||||
"text-embedding-004", "aqa",
|
"text-embedding-004", "aqa",
|
||||||
"gemini-2.0-flash-exp",
|
"gemini-2.0-pro-exp-02-05",
|
||||||
|
"gemini-2.0-flash", "gemini-2.0-flash-exp",
|
||||||
|
"gemini-2.0-flash-lite-preview-02-05",
|
||||||
"gemini-2.0-flash-thinking-exp-01-21",
|
"gemini-2.0-flash-thinking-exp-01-21",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,6 +160,15 @@ func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest {
|
|||||||
geminiRequest.Contents = append(geminiRequest.Contents, content)
|
geminiRequest.Contents = append(geminiRequest.Contents, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As of 2025-02-06, the newly released gemini 2.0 models do not support system_instruction,
|
||||||
|
// which can reasonably be considered a bug. Google may fix this issue in the future.
|
||||||
|
if geminiRequest.SystemInstruction != nil &&
|
||||||
|
strings.Contains(textRequest.Model, "-2.0") &&
|
||||||
|
textRequest.Model != "gemini-2.0-flash-exp" &&
|
||||||
|
textRequest.Model != "gemini-2.0-flash-thinking-exp-01-21" {
|
||||||
|
geminiRequest.SystemInstruction = nil
|
||||||
|
}
|
||||||
|
|
||||||
return &geminiRequest
|
return &geminiRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,14 +122,23 @@ var ModelRatio = map[string]float64{
|
|||||||
"bge-large-en": 0.002 * RMB,
|
"bge-large-en": 0.002 * RMB,
|
||||||
"tao-8k": 0.002 * RMB,
|
"tao-8k": 0.002 * RMB,
|
||||||
// https://ai.google.dev/pricing
|
// https://ai.google.dev/pricing
|
||||||
|
// https://cloud.google.com/vertex-ai/generative-ai/pricing
|
||||||
|
// "gemma-2-2b-it": 0,
|
||||||
|
// "gemma-2-9b-it": 0,
|
||||||
|
// "gemma-2-27b-it": 0,
|
||||||
"gemini-pro": 0.25 * MILLI_USD, // $0.00025 / 1k characters -> $0.001 / 1k tokens
|
"gemini-pro": 0.25 * MILLI_USD, // $0.00025 / 1k characters -> $0.001 / 1k tokens
|
||||||
"gemini-1.0-pro": 0.125 * MILLI_USD,
|
"gemini-1.0-pro": 0.125 * MILLI_USD,
|
||||||
"gemini-1.5-pro": 1.25 * MILLI_USD,
|
"gemini-1.5-pro": 1.25 * MILLI_USD,
|
||||||
"gemini-1.5-pro-001": 1.25 * MILLI_USD,
|
"gemini-1.5-pro-001": 1.25 * MILLI_USD,
|
||||||
|
"gemini-1.5-pro-experimental": 1.25 * MILLI_USD,
|
||||||
"gemini-1.5-flash": 0.075 * MILLI_USD,
|
"gemini-1.5-flash": 0.075 * MILLI_USD,
|
||||||
"gemini-1.5-flash-001": 0.075 * MILLI_USD,
|
"gemini-1.5-flash-001": 0.075 * MILLI_USD,
|
||||||
|
"gemini-1.5-flash-8b": 0.0375 * MILLI_USD,
|
||||||
"gemini-2.0-flash-exp": 0.075 * MILLI_USD,
|
"gemini-2.0-flash-exp": 0.075 * MILLI_USD,
|
||||||
|
"gemini-2.0-flash": 0.15 * MILLI_USD,
|
||||||
|
"gemini-2.0-flash-lite-preview-02-05": 0.075 * MILLI_USD,
|
||||||
"gemini-2.0-flash-thinking-exp-01-21": 0.075 * MILLI_USD,
|
"gemini-2.0-flash-thinking-exp-01-21": 0.075 * MILLI_USD,
|
||||||
|
"gemini-2.0-pro-exp-02-05": 1.25 * MILLI_USD,
|
||||||
"aqa": 1,
|
"aqa": 1,
|
||||||
// https://open.bigmodel.cn/pricing
|
// https://open.bigmodel.cn/pricing
|
||||||
"glm-zero-preview": 0.01 * RMB,
|
"glm-zero-preview": 0.01 * RMB,
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function renderType(type) {
|
|||||||
case 2:
|
case 2:
|
||||||
return (
|
return (
|
||||||
<Label basic color='olive'>
|
<Label basic color='olive'>
|
||||||
Consumption
|
Consumed
|
||||||
</Label>
|
</Label>
|
||||||
);
|
);
|
||||||
case 3:
|
case 3:
|
||||||
@@ -564,7 +564,7 @@ const LogsTable = () => {
|
|||||||
{log.completion_tokens ? log.completion_tokens : ''}
|
{log.completion_tokens ? log.completion_tokens : ''}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
{log.quota ? renderQuota(log.quota, t, 6) : ''}
|
{log.quota ? renderQuota(log.quota, t, 6) : 'free'}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user