Compare commits

..

3 Commits

Author SHA1 Message Date
Laisky.Cai
54b9d7b0e2 Merge 5e3f853fa8 into 8b8cd03e85 2025-02-12 08:13:46 +08:00
JustSong
8b8cd03e85 feat: add balance not supported message in ChannelsTable
Some checks failed
CI / Unit tests (push) Has been cancelled
CI / commit_lint (push) Has been cancelled
2025-02-12 01:20:28 +08:00
Laisky.Cai
5e3f853fa8 fix: update Prompt type in GeneralOpenAIRequest and adjust related logic in ConvertCompletionsRequest 2025-02-10 02:12:17 +00:00
5 changed files with 17 additions and 24 deletions

View File

@@ -19,9 +19,8 @@ import (
)
func ConvertCompletionsRequest(textRequest model.GeneralOpenAIRequest) *Request {
p, _ := textRequest.Prompt.(string)
return &Request{
Prompt: p,
Prompt: textRequest.Prompt,
MaxTokens: textRequest.MaxTokens,
Stream: textRequest.Stream,
Temperature: textRequest.Temperature,

View File

@@ -319,7 +319,7 @@ var ModelRatio = map[string]float64{
"command-r": 0.5 / 1000 * USD,
"command-r-plus": 3.0 / 1000 * USD,
// https://platform.deepseek.com/api-docs/pricing/
"deepseek-chat": 0.14 * MILLI_USD,
"deepseek-chat": 0.27 * MILLI_USD,
"deepseek-reasoner": 0.55 * MILLI_USD,
// https://www.deepl.com/pro?cta=header-prices
"deepl-zh": 25.0 / 1000 * USD,
@@ -380,7 +380,7 @@ var CompletionRatio = map[string]float64{
// whisper
"whisper-1": 0, // only count input tokens
// deepseek
"deepseek-chat": 0.28 / 0.14,
"deepseek-chat": 1.1 / 0.27,
"deepseek-reasoner": 2.19 / 0.55,
}
@@ -534,9 +534,6 @@ func GetCompletionRatio(name string, channelType int) float64 {
if strings.HasPrefix(name, "gemini-") {
return 3
}
if strings.HasPrefix(name, "deepseek-") {
return 2
}
switch name {
case "llama2-70b-4096":

View File

@@ -33,6 +33,10 @@ func RelayTextHelper(c *gin.Context) *model.ErrorWithStatusCode {
}
meta.IsStream = textRequest.Stream
if reqBody, ok := c.Get(ctxkey.KeyRequestBody); ok {
logger.Debugf(c.Request.Context(), "get text request: %s\n", string(reqBody.([]byte)))
}
// map model name
meta.OriginModelName = textRequest.Model
textRequest.Model, _ = getMappedModelName(textRequest.Model, meta.ModelMapping)

View File

@@ -59,7 +59,7 @@ type GeneralOpenAIRequest struct {
EncodingFormat string `json:"encoding_format,omitempty"`
Dimensions int `json:"dimensions,omitempty"`
// https://platform.openai.com/docs/api-reference/images/create
Prompt any `json:"prompt,omitempty"`
Prompt string `json:"prompt,omitempty"`
Quality *string `json:"quality,omitempty"`
Size string `json:"size,omitempty"`
Style *string `json:"style,omitempty"`

View File

@@ -1,17 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
Button,
Dropdown,
Form,
Input,
Label,
Message,
Pagination,
Popup,
Table,
} from 'semantic-ui-react';
import { Link } from 'react-router-dom';
import React, {useEffect, useState} from 'react';
import {useTranslation} from 'react-i18next';
import {Button, Dropdown, Form, Input, Label, Message, Pagination, Popup, Table,} from 'semantic-ui-react';
import {Link} from 'react-router-dom';
import {
API,
loadChannelModels,
@@ -23,8 +13,8 @@ import {
timestamp2string,
} from '../helpers';
import { CHANNEL_OPTIONS, ITEMS_PER_PAGE } from '../constants';
import { renderGroup, renderNumber } from '../helpers/render';
import {CHANNEL_OPTIONS, ITEMS_PER_PAGE} from '../constants';
import {renderGroup, renderNumber} from '../helpers/render';
function renderTimestamp(timestamp) {
return <>{timestamp2string(timestamp)}</>;
@@ -54,6 +44,9 @@ function renderType(type, t) {
function renderBalance(type, balance, t) {
switch (type) {
case 1: // OpenAI
if (balance === 0) {
return <span>{t('channel.table.balance_not_supported')}</span>;
}
return <span>${balance.toFixed(2)}</span>;
case 4: // CloseAI
return <span>¥{balance.toFixed(2)}</span>;