Skip to content

Commit

Permalink
feat: 添加三个新模型的信息到 Py & Go (#599)
Browse files Browse the repository at this point in the history
* 添加三个新模型

* 格式化

* Java + Js
  • Loading branch information
Dobiichi-Origami authored Jun 20, 2024
1 parent 23858c5 commit e96efe9
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/qianfan/chat_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ type ChatCompletionRequest struct {

// 内置 chat 模型的 endpoint
var ChatModelEndpoint = map[string]string{
"ERNIE-4.0-8K-Latest": "/chat/ernie-4.0-8k-latest",
"ERNIE-4.0-8K-0613": "/chat/ernie-4.0-8k-0613",
"ERNIE-3.5-8K-0613": "/chat/ernie-3.5-8k-0613",
"ERNIE-Bot-turbo": "/chat/eb-instant",
"ERNIE-Lite-8K-0922": "/chat/eb-instant",
"ERNIE-Lite-8K": "/chat/ernie-lite-8k",
Expand Down Expand Up @@ -139,6 +142,9 @@ type inputLimitInfo struct {

// 定义包含所需信息的 map
var limitMapInModelName = map[string]inputLimitInfo{
"ERNIE-4.0-8K-Latest": {MaxInputChars: 20000, MaxInputTokens: 5120},
"ERNIE-4.0-8K-0613": {MaxInputChars: 20000, MaxInputTokens: 5120},
"ERNIE-3.5-8K-0613": {MaxInputChars: 20000, MaxInputTokens: 5120},
"ERNIE-Lite-8K-0922": {MaxInputChars: 11200, MaxInputTokens: 7168},
"ERNIE-Lite-8K": {MaxInputChars: 11200, MaxInputTokens: 7168},
"ERNIE-Lite-8K-0308": {MaxInputChars: 11200, MaxInputTokens: 7168},
Expand Down Expand Up @@ -184,6 +190,9 @@ var limitMapInModelName = map[string]inputLimitInfo{
}

var limitMapInEndpoint = map[string]inputLimitInfo{
"/chat/ernie-4.0-8k-latest": {MaxInputChars: 20000, MaxInputTokens: 5120},
"/chat/ernie-4.0-8k-0613": {MaxInputChars: 20000, MaxInputTokens: 5120},
"/chat/ernie-3.5-8k-0613": {MaxInputChars: 20000, MaxInputTokens: 5120},
"/chat/eb-instant": {MaxInputChars: 11200, MaxInputTokens: 7168},
"/chat/ernie-lite-8k": {MaxInputChars: 11200, MaxInputTokens: 7168},
"/chat/completions": {MaxInputChars: 20000, MaxInputTokens: 5120},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public ModelEndpointRetriever(IAuth auth) {
dynamicTypeModelEndpointMap.put(type, new HashMap<>());
}

typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-latest", "ernie-4.0-8k-latest");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-0613", "ernie-4.0-8k-0613");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-3.5-8k-0613", "ernie-3.5-8k-0613");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k", "completions_pro");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-preemptible", "completions_pro_preemptible");
typeModelEndpointMap.get(ModelType.CHAT).put("ernie-4.0-8k-preview", "ernie-4.0-8k-preview");
Expand Down
65 changes: 65 additions & 0 deletions javascript/src/ChatCompletion/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {QfLLMInfoMap} from '../interface';
* 对话请求公共服务模型列表
*/
export type ChatModel =
| 'ERNIE-4.0-8K-Latest'
| 'ERNIE-4.0-8K-0613'
| 'ERNIE-3.5-8K-0613'
| 'ERNIE-4.0-8K'
| 'ERNIE-3.5-8K'
| 'ERNIE-3.5-8K-0205'
Expand Down Expand Up @@ -51,6 +54,68 @@ export type ChatModel =
| 'Yi-34B-Chat'

export const modelInfoMap: QfLLMInfoMap = {
"ERNIE-4.0-8K-Latest": {
endpoint: "/chat/ernie-4.0-8k-latest",
required_keys: ["messages"],
optional_keys: [
"stream",
"temperature",
"top_p",
"penalty_score",
"user_id",
"system",
"stop",
"enable_system_memory",
"system_memory_id",
"disable_search",
"enable_citation",
"enable_trace",
"max_output_tokens",
"response_format",
],
},
"ERNIE-4.0-8K-0613": {
endpoint: "/chat/ernie-4.0-8k-0613",
required_keys: ["messages"],
optional_keys: [
"stream",
"temperature",
"top_p",
"penalty_score",
"user_id",
"system",
"stop",
"enable_system_memory",
"system_memory_id",
"disable_search",
"enable_citation",
"enable_trace",
"max_output_tokens",
"response_format",
],
},
"ERNIE-3.5-8K-0613": {
endpoint: "/chat/ernie-3.5-8k-0613",
required_keys: ["messages"],
optional_keys: [
"stream",
"temperature",
"top_p",
"penalty_score",
"user_id",
"system",
"stop",
"enable_system_memory",
"system_memory_id",
"disable_search",
"enable_citation",
"enable_trace",
"max_output_tokens",
"response_format",
"functions",
"tool_choice",
],
},
'ERNIE-4.0-8K': {
endpoint: '/chat/completions_pro',
required_keys: ['messages'],
Expand Down
3 changes: 3 additions & 0 deletions javascript/src/DynamicModelEndpoint/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const typeModelEndpointMap: ModelEndpointMap = new Map();

// 定义 "CHAT" 类型的模型及其 endpoints
const chatModelEndpoints = new Map<string, string>([
['ernie-4.0-8k-latest', 'ernie-4.0-8k-latest'],
['ernie-4.0-8k-0613', 'ernie-4.0-8k-0613'],
['ernie-3.5-8k-0613', 'ernie-3.5-8k-0613'],
['ernie-4.0-8k', 'completions_pro'],
['ernie-4.0-8k-preemptible', 'completions_pro_preemptible'],
['ernie-4.0-8k-preview', 'ernie-4.0-8k-preview'],
Expand Down
74 changes: 74 additions & 0 deletions python/qianfan/resources/llm/chat_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,80 @@ def _supported_models(cls) -> Dict[str, QfLLMInfo]:
"""
info_list = {
"ERNIE-4.0-8K-Latest": QfLLMInfo(
endpoint="/chat/ernie-4.0-8k-latest",
required_keys={"messages"},
optional_keys={
"stream",
"temperature",
"top_p",
"penalty_score",
"user_id",
"system",
"stop",
"enable_system_memory",
"system_memory_id",
"disable_search",
"enable_citation",
"enable_trace",
"max_output_tokens",
"response_format",
},
max_input_chars=20000,
max_input_tokens=5120,
input_price_per_1k_tokens=0.12,
output_price_per_1k_tokens=0.12,
),
"ERNIE-4.0-8K-0613": QfLLMInfo(
endpoint="/chat/ernie-4.0-8k-0613",
required_keys={"messages"},
optional_keys={
"stream",
"temperature",
"top_p",
"penalty_score",
"user_id",
"system",
"stop",
"enable_system_memory",
"system_memory_id",
"disable_search",
"enable_citation",
"enable_trace",
"max_output_tokens",
"response_format",
},
max_input_chars=20000,
max_input_tokens=5120,
input_price_per_1k_tokens=0.12,
output_price_per_1k_tokens=0.12,
),
"ERNIE-3.5-8K-0613": QfLLMInfo(
endpoint="/chat/ernie-3.5-8k-0613",
required_keys={"messages"},
optional_keys={
"stream",
"temperature",
"top_p",
"penalty_score",
"user_id",
"system",
"stop",
"enable_system_memory",
"system_memory_id",
"disable_search",
"enable_citation",
"enable_trace",
"max_output_tokens",
"response_format",
"functions",
"tool_choice",
},
max_input_chars=20000,
max_input_tokens=5120,
input_price_per_1k_tokens=0.012,
output_price_per_1k_tokens=0.012,
),
"ERNIE-Lite-8K-0922": QfLLMInfo(
endpoint="/chat/eb-instant",
required_keys={"messages"},
Expand Down

0 comments on commit e96efe9

Please sign in to comment.