labring / FastGPT

FastGPT is a knowledge-based platform built on the LLMs, offers a comprehensive suite of out-of-the-box capabilities such as data processing, RAG retrieval, and visual AI workflow orchestration, letting you easily develop and deploy complex question-answering systems without the need for extensive setup or configuration.
https://tryfastgpt.ai
Other
17.02k stars 4.55k forks source link

基于工具调用的智能体API非流式请求得到非期望的字符串“0: ” #2340

Closed monk-after-90s closed 3 weeks ago

monk-after-90s commented 1 month ago

例行检查

你的版本

问题描述, 日志截图

使用fastgpt制作一个智能体,并且其中使用了工具调用,且模型选择的是不支持函数调用的qwen2。发布这个智能体的API,使用Python的openai库进行非流式请求,响应内容会以“0: ”开始。 image

复现步骤

我使用的代码是

import asyncio

from openai import AsyncOpenAI

client = AsyncOpenAI()

async def main():
    chat_completion = await client.chat.completions.create(
        messages=[
            {
                "role": "user",
                "content": "Say this is a test",
            }
        ],
        model="Qwen/Qwen2-72B-Instruct-GPTQ-Int4",
    )
    print(chat_completion)

if __name__ == '__main__':
    asyncio.run(main())

使用环境变量OPENAI_BASE_URL、OPENAI_API_KEY传入BaseURL和apikey。

预期结果

响应结果不是以“0: ”开头,就正常文本。

相关截图

c121914yu commented 3 weeks ago

忘记关闭。 4.8.9 解决了。非 stream 模式下,prompt 模式工具调用问题。