Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support 360 ai model #1243

Merged
merged 3 commits into from
Aug 23, 2024
Merged

feat: support 360 ai model #1243

merged 3 commits into from
Aug 23, 2024

Conversation

hackerYHT
Copy link
Contributor

Ⅰ. Describe what this PR did

Support baidu ernie bot ai model. API documentation: https://ai.360.com/platform/docs/overview

Ⅱ. Does this pull request fix one issue?

fixes #951

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

openai协议,非流式

curl -L "http://127.0.0.1:10000/v1/chat/completions" \
--header "Content-Type: application/json" \
--data '{
    "model":"gpt-4o",
    "messages": [
        {
            "role": "system",
            "content": "你是一个专业的开发人员!"
        },
        {
            "role": "user",
            "content": "你好,你是谁?"
        }
    ]
}'

回复

{"choices":[{"message":{"role":"assistant","content":"您好!我是来自中国的一位AI助手。我被设计用来回答各种问题和提供信息。有什么我可以帮助您的吗?"},"finish_reason":"","index":0}],"created":1724326070,"id":"bc938c00-2181-445a-bb78-20431fe270c3","model":"360gpt-turbo-responsibility-8k","object":"","usage":{"completion_tokens":28,"prompt_tokens":24,"total_tokens":52},"messages":[{"role":"system","content":"你是一个专业的开发人员!"},{"role":"user","content":"你好,你是谁?"}],"context":null}

openai协议,流式

curl --location 'http://127.0.0.1:10000/v1/chat/completions' \
--header 'Content-Type:  application/json' \
--data '{
    "model":"gpt-4o",
    "messages":[{
        "role": "user",
        "content": "你好"
    }],
    "stream": true,
    "temperature": 0.9,
    "max_tokens": 2048,
    "top_p": 0.5,
    "top_k": 0,
    "repetition_penalty": 1.05,
    "num_beams": 1,
    "user": "andy"
}'

回复

data: {"choices":[{"delta":{"content":"你好"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":{"completion_tokens":1,"prompt_tokens":20,"total_tokens":21},"messages":[{"role":"user","content":"你好"}],"context":null}

data: {"choices":[{"delta":{"content":"!"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"有什么"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"问题"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"我可以"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"帮助"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"你"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"解答"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"吗"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":null,"messages":null,"context":null}

data: {"choices":[{"delta":{"content":"?"},"finish_reason":"","index":0}],"created":1724326100,"id":"71ea55f1-62ca-4577-863b-6f91bdfe91d2","model":"360gpt-turbo-responsibility-8k","object":"","usage":{"completion_tokens":11,"prompt_tokens":20,"total_tokens":31},"messages":[{"role":"user","content":"你好"}],"context":null}

data: [DONE]

Ⅴ. Special notes for reviews

@CLAassistant
Copy link

CLAassistant commented Aug 22, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@CH3CHO CH3CHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter
Copy link

codecov-commenter commented Aug 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.98%. Comparing base (ef31e09) to head (e6325d4).
Report is 122 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1243      +/-   ##
==========================================
+ Coverage   35.91%   35.98%   +0.07%     
==========================================
  Files          69       69              
  Lines       11576     9500    -2076     
==========================================
- Hits         4157     3419     -738     
+ Misses       7104     5766    -1338     
  Partials      315      315              

see 67 files with indirect coverage changes

@CH3CHO CH3CHO merged commit 1c10f36 into alibaba:main Aug 23, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI 代理 Wasm 插件对接 360 智脑
4 participants