mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-19 09:18:38 +00:00
Merge pull request #1998 from seefs001/feature/pplx-channel
feat: pplx channel
This commit is contained in:
@@ -87,6 +87,12 @@ type GeneralOpenAIRequest struct {
|
|||||||
WebSearch json.RawMessage `json:"web_search,omitempty"`
|
WebSearch json.RawMessage `json:"web_search,omitempty"`
|
||||||
// doubao,zhipu_v4
|
// doubao,zhipu_v4
|
||||||
THINKING json.RawMessage `json:"thinking,omitempty"`
|
THINKING json.RawMessage `json:"thinking,omitempty"`
|
||||||
|
// pplx Params
|
||||||
|
SearchDomainFilter json.RawMessage `json:"search_domain_filter,omitempty"`
|
||||||
|
SearchRecencyFilter string `json:"search_recency_filter,omitempty"`
|
||||||
|
ReturnImages bool `json:"return_images,omitempty"`
|
||||||
|
ReturnRelatedQuestions bool `json:"return_related_questions,omitempty"`
|
||||||
|
SearchMode string `json:"search_mode,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
||||||
|
|||||||
@@ -22,10 +22,9 @@ func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dt
|
|||||||
return nil, errors.New("not implemented")
|
return nil, errors.New("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) ConvertClaudeRequest(*gin.Context, *relaycommon.RelayInfo, *dto.ClaudeRequest) (any, error) {
|
func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error) {
|
||||||
//TODO implement me
|
adaptor := openai.Adaptor{}
|
||||||
panic("implement me")
|
return adaptor.ConvertClaudeRequest(c, info, req)
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error) {
|
func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error) {
|
||||||
@@ -80,11 +79,8 @@ func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, request
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.NewAPIError) {
|
func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.NewAPIError) {
|
||||||
if info.IsStream {
|
adaptor := openai.Adaptor{}
|
||||||
usage, err = openai.OaiStreamHandler(c, info, resp)
|
usage, err = adaptor.DoResponse(c, resp, info)
|
||||||
} else {
|
|
||||||
usage, err = openai.OpenaiHandler(c, info, resp)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package perplexity
|
|||||||
|
|
||||||
var ModelList = []string{
|
var ModelList = []string{
|
||||||
"llama-3-sonar-small-32k-chat", "llama-3-sonar-small-32k-online", "llama-3-sonar-large-32k-chat", "llama-3-sonar-large-32k-online", "llama-3-8b-instruct", "llama-3-70b-instruct", "mixtral-8x7b-instruct",
|
"llama-3-sonar-small-32k-chat", "llama-3-sonar-small-32k-online", "llama-3-sonar-large-32k-chat", "llama-3-sonar-large-32k-online", "llama-3-8b-instruct", "llama-3-70b-instruct", "mixtral-8x7b-instruct",
|
||||||
|
"sonar", "sonar-pro", "sonar-reasoning",
|
||||||
}
|
}
|
||||||
|
|
||||||
var ChannelName = "perplexity"
|
var ChannelName = "perplexity"
|
||||||
|
|||||||
@@ -11,11 +11,18 @@ func requestOpenAI2Perplexity(request dto.GeneralOpenAIRequest) *dto.GeneralOpen
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &dto.GeneralOpenAIRequest{
|
return &dto.GeneralOpenAIRequest{
|
||||||
Model: request.Model,
|
Model: request.Model,
|
||||||
Stream: request.Stream,
|
Stream: request.Stream,
|
||||||
Messages: messages,
|
Messages: messages,
|
||||||
Temperature: request.Temperature,
|
Temperature: request.Temperature,
|
||||||
TopP: request.TopP,
|
TopP: request.TopP,
|
||||||
MaxTokens: request.GetMaxTokens(),
|
MaxTokens: request.GetMaxTokens(),
|
||||||
|
FrequencyPenalty: request.FrequencyPenalty,
|
||||||
|
PresencePenalty: request.PresencePenalty,
|
||||||
|
SearchDomainFilter: request.SearchDomainFilter,
|
||||||
|
SearchRecencyFilter: request.SearchRecencyFilter,
|
||||||
|
ReturnImages: request.ReturnImages,
|
||||||
|
ReturnRelatedQuestions: request.ReturnRelatedQuestions,
|
||||||
|
SearchMode: request.SearchMode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ const REGION_EXAMPLE = {
|
|||||||
|
|
||||||
// 支持并且已适配通过接口获取模型列表的渠道类型
|
// 支持并且已适配通过接口获取模型列表的渠道类型
|
||||||
const MODEL_FETCHABLE_TYPES = new Set([
|
const MODEL_FETCHABLE_TYPES = new Set([
|
||||||
1, 4, 14, 34, 17, 26, 24, 47, 25, 20, 23, 31, 35, 40, 42, 48, 43,
|
1, 4, 14, 34, 17, 26, 27, 24, 47, 25, 20, 23, 31, 35, 40, 42, 48, 43,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function type2secretPrompt(type) {
|
function type2secretPrompt(type) {
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ export const CHANNEL_OPTIONS = [
|
|||||||
color: 'purple',
|
color: 'purple',
|
||||||
label: '智谱 GLM-4V',
|
label: '智谱 GLM-4V',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
value: 27,
|
||||||
|
color: 'blue',
|
||||||
|
label: 'Perplexity',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: 24,
|
value: 24,
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import {
|
|||||||
FastGPT,
|
FastGPT,
|
||||||
Kling,
|
Kling,
|
||||||
Jimeng,
|
Jimeng,
|
||||||
|
Perplexity,
|
||||||
} from '@lobehub/icons';
|
} from '@lobehub/icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -309,6 +310,8 @@ export function getChannelIcon(channelType) {
|
|||||||
return <Xinference.Color size={iconSize} />;
|
return <Xinference.Color size={iconSize} />;
|
||||||
case 25: // Moonshot
|
case 25: // Moonshot
|
||||||
return <Moonshot size={iconSize} />;
|
return <Moonshot size={iconSize} />;
|
||||||
|
case 27: // Perplexity
|
||||||
|
return <Perplexity.Color size={iconSize} />;
|
||||||
case 20: // OpenRouter
|
case 20: // OpenRouter
|
||||||
return <OpenRouter size={iconSize} />;
|
return <OpenRouter size={iconSize} />;
|
||||||
case 19: // 360 智脑
|
case 19: // 360 智脑
|
||||||
|
|||||||
Reference in New Issue
Block a user