mirror of
https://github.com/songquanpeng/one-api.git
synced 2026-04-30 21:34:24 +08:00
Compare commits
5 Commits
v0.6.11-al
...
c71a3586bd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c71a3586bd | ||
|
|
8b8cd03e85 | ||
|
|
dabaa795b9 | ||
|
|
3e17184c1e | ||
|
|
d7e1b2a231 |
@@ -32,16 +32,24 @@ 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) {
|
||||||
switch meta.ChannelType {
|
switch meta.ChannelType {
|
||||||
case channeltype.Azure:
|
case channeltype.Azure:
|
||||||
|
defaultVersion := meta.Config.APIVersion
|
||||||
|
|
||||||
|
// https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/reasoning?tabs=python#api--feature-support
|
||||||
|
if strings.HasPrefix(meta.ActualModelName, "o1") ||
|
||||||
|
strings.HasPrefix(meta.ActualModelName, "o3") {
|
||||||
|
defaultVersion = "2024-12-01-preview"
|
||||||
|
}
|
||||||
|
|
||||||
if meta.Mode == relaymode.ImagesGenerations {
|
if meta.Mode == relaymode.ImagesGenerations {
|
||||||
// https://learn.microsoft.com/en-us/azure/ai-services/openai/dall-e-quickstart?tabs=dalle3%2Ccommand-line&pivots=rest-api
|
// https://learn.microsoft.com/en-us/azure/ai-services/openai/dall-e-quickstart?tabs=dalle3%2Ccommand-line&pivots=rest-api
|
||||||
// https://{resource_name}.openai.azure.com/openai/deployments/dall-e-3/images/generations?api-version=2024-03-01-preview
|
// https://{resource_name}.openai.azure.com/openai/deployments/dall-e-3/images/generations?api-version=2024-03-01-preview
|
||||||
fullRequestURL := fmt.Sprintf("%s/openai/deployments/%s/images/generations?api-version=%s", meta.BaseURL, meta.ActualModelName, meta.Config.APIVersion)
|
fullRequestURL := fmt.Sprintf("%s/openai/deployments/%s/images/generations?api-version=%s", meta.BaseURL, meta.ActualModelName, defaultVersion)
|
||||||
return fullRequestURL, nil
|
return fullRequestURL, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
|
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
|
||||||
requestURL := strings.Split(meta.RequestURLPath, "?")[0]
|
requestURL := strings.Split(meta.RequestURLPath, "?")[0]
|
||||||
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, meta.Config.APIVersion)
|
requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, defaultVersion)
|
||||||
task := strings.TrimPrefix(requestURL, "/v1/")
|
task := strings.TrimPrefix(requestURL, "/v1/")
|
||||||
model_ := meta.ActualModelName
|
model_ := meta.ActualModelName
|
||||||
model_ = strings.Replace(model_, ".", "", -1)
|
model_ = strings.Replace(model_, ".", "", -1)
|
||||||
@@ -89,6 +97,23 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.G
|
|||||||
}
|
}
|
||||||
request.StreamOptions.IncludeUsage = true
|
request.StreamOptions.IncludeUsage = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// o1/o1-mini/o1-preview do not support system prompt/max_tokens/temperature
|
||||||
|
if strings.HasPrefix(request.Model, "o1") {
|
||||||
|
temperature := float64(1)
|
||||||
|
request.Temperature = &temperature // Only the default (1) value is supported
|
||||||
|
request.MaxTokens = 0
|
||||||
|
request.Messages = func(raw []model.Message) (filtered []model.Message) {
|
||||||
|
for i := range raw {
|
||||||
|
if raw[i].Role != "system" {
|
||||||
|
filtered = append(filtered, raw[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}(request.Messages)
|
||||||
|
}
|
||||||
|
|
||||||
return request, nil
|
return request, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ func GetCompletionRatio(name string, channelType int) float64 {
|
|||||||
}
|
}
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
// including o1, o1-preview, o1-mini
|
// including o1/o1-preview/o1-mini
|
||||||
if strings.HasPrefix(name, "o1") {
|
if strings.HasPrefix(name, "o1") {
|
||||||
return 4
|
return 4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import {useTranslation} from 'react-i18next';
|
||||||
import {
|
import {Button, Dropdown, Form, Input, Label, Message, Pagination, Popup, Table,} from 'semantic-ui-react';
|
||||||
Button,
|
import {Link} from 'react-router-dom';
|
||||||
Dropdown,
|
|
||||||
Form,
|
|
||||||
Input,
|
|
||||||
Label,
|
|
||||||
Message,
|
|
||||||
Pagination,
|
|
||||||
Popup,
|
|
||||||
Table,
|
|
||||||
} from 'semantic-ui-react';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import {
|
import {
|
||||||
API,
|
API,
|
||||||
loadChannelModels,
|
loadChannelModels,
|
||||||
@@ -23,8 +13,8 @@ import {
|
|||||||
timestamp2string,
|
timestamp2string,
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
|
|
||||||
import { CHANNEL_OPTIONS, ITEMS_PER_PAGE } from '../constants';
|
import {CHANNEL_OPTIONS, ITEMS_PER_PAGE} from '../constants';
|
||||||
import { renderGroup, renderNumber } from '../helpers/render';
|
import {renderGroup, renderNumber} from '../helpers/render';
|
||||||
|
|
||||||
function renderTimestamp(timestamp) {
|
function renderTimestamp(timestamp) {
|
||||||
return <>{timestamp2string(timestamp)}</>;
|
return <>{timestamp2string(timestamp)}</>;
|
||||||
@@ -54,6 +44,9 @@ function renderType(type, t) {
|
|||||||
function renderBalance(type, balance, t) {
|
function renderBalance(type, balance, t) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 1: // OpenAI
|
case 1: // OpenAI
|
||||||
|
if (balance === 0) {
|
||||||
|
return <span>{t('channel.table.balance_not_supported')}</span>;
|
||||||
|
}
|
||||||
return <span>${balance.toFixed(2)}</span>;
|
return <span>${balance.toFixed(2)}</span>;
|
||||||
case 4: // CloseAI
|
case 4: // CloseAI
|
||||||
return <span>¥{balance.toFixed(2)}</span>;
|
return <span>¥{balance.toFixed(2)}</span>;
|
||||||
|
|||||||
Reference in New Issue
Block a user