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://fastgpt.in
Other
16.93k stars 4.52k forks source link

Conversation prompt Chat API is error or undefined #397

Closed fskz closed 10 months ago

fskz commented 11 months ago

例行检查

你的版本

问题描述 1.部署方式为docker compose 2.在fastgpt简单对话应用中,选择自己在one-api中配置的智谱chatglm_std保存后,对话发送任意内容时,提示Chat API is error or undefined. 其他信息说明: 1.部署方式为docker compose 2.用curl测试api和sk-key都可用,测试结果输出如下:

curl http://127.0.0.1:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-3GxsVkLNIaMndYid3874Ab91F08b4fC186DaDe989b661364" \
  -d '{
    "model": "chatglm_std",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
{"id":"8023313541090021474","object":"chat.completion","created":1697186606,"choices":[{"index":0,"message":{"role":"assistant","content":" Hello 👋! I'm ZhiPuQingYan(智谱清言), you can call me Xiaozhi🤖, the artificial intelligence assistant, nice to meet you. Feel free to ask me any questions."},"finish_reason":"stop"}],"usage":{"prompt_tokens":509,"completion_tokens":48,"total_tokens":557}}

docker-compose.yml内容如下

# 非 host 版本, 不使用本机代理
version: '3.3'
services:
  pg:
    image: ankane/pgvector:v0.4.2 # git
    # image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.4.2 # 阿里云
    container_name: pg
    restart: always
    ports: # 生产环境建议不要暴露
      - 5432:5432
    networks:
      - fastgpt
    environment:
      # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
      - POSTGRES_USER=username
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=postgres
    volumes:
      - ./pg/data:/var/lib/postgresql/data
  mongo:
    image: mongo:5.0.18
    # image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
    container_name: mongo
    restart: always
    ports: # 生产环境建议不要暴露
      - 27017:27017
    networks:
      - fastgpt
    environment:
      # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
      - MONGO_INITDB_ROOT_USERNAME=username
      - MONGO_INITDB_ROOT_PASSWORD=password
    volumes:
      - ./mongo/data:/data/db
  fastgpt:
    container_name: fastgpt
    image: ghcr.io/labring/fastgpt:v4.4.7 # git
    # image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
    ports:
      - 3001:3000
    extra_hosts:
      - "host.docker.internal:host-gateway"
    networks:
      - fastgpt
    depends_on:
      - mongo
      - pg
    restart: always
    environment:
      # root 密码,用户名为: root
      - DEFAULT_ROOT_PSW=1234
      # 中转地址,如果是用官方号,不需要管
      - OPENAI_BASE_URL=http://host.docker.internal:3000/v1
      - CHAT_API_KEY=sk-3GxsVkLNIaMndYid3874Ab91F08b4fC186DaDe989b661364
      - DB_MAX_LINK=5 # database max link
      - TOKEN_KEY=any
      - ROOT_KEY=root_key
      - FILE_TOKEN_KEY=filetoken
      # mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin
      - MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
      # pg配置. 不需要改
      - PG_URL=postgresql://username:password@pg:5432/postgres
    volumes:
      - ./config.json:/app/data/config.json
networks:
  fastgpt:

config.json配置如下:

{
  "SystemParams": {
    "vectorMaxProcess": 15,
    "qaMaxProcess": 15,
    "pgIvfflatProbe": 20
  },
  "ChatModels": [
    {
      "model": "gpt-3.5-turbo",
      "name": "GPT35-4k",
      "contextMaxToken": 4000,
      "quoteMaxToken": 2000,
      "maxTemperature": 1.2,
      "price": 0,
      "defaultSystem": ""
    },
    {
      "model": "gpt-3.5-turbo-16k",
      "name": "GPT35-16k",
      "contextMaxToken": 16000,
      "quoteMaxToken": 8000,
      "maxTemperature": 1.2,
      "price": 0,
      "defaultSystem": ""
    },
    {
      "model": "gpt-4",
      "name": "GPT4-8k",
      "contextMaxToken": 8000,
      "quoteMaxToken": 4000,
      "maxTemperature": 1.2,
      "price": 0,
      "defaultSystem": ""
    },
    {
      "model": "chatglm_std",
      "name": "chatglm_std-智谱",
      "contextMaxToken": 8000,
      "quoteMaxToken": 4000,
      "maxTemperature": 1.2,
      "price": 0,
      "defaultSystem": ""
    }
  ],
  "VectorModels": [
    {
      "model": "text-embedding-ada-002",
      "name": "Embedding-2",
      "price": 0,
      "defaultToken": 500,
      "maxToken": 3000
    },
    {
      "model": "m3e",
      "name": "M3E(测试使用)",
      "price": 0,
      "defaultToken": 500,
      "maxToken": 1800
    }
  ],
  "QAModel": {
    "model": "gpt-3.5-turbo-16k",
    "name": "GPT35-16k",
    "maxToken": 16000,
    "price": 0
  },
  "ExtractModel": {
    "model": "gpt-3.5-turbo-16k",
    "functionCall": true,
    "name": "GPT35-16k",
    "maxToken": 16000,
    "price": 0,
    "prompt": ""
  },
  "CQModel": {
    "model": "gpt-3.5-turbo-16k",
    "functionCall": true,
    "name": "GPT35-16k",
    "maxToken": 16000,
    "price": 0,
    "prompt": ""
  },
  "QGModel": {
    "model": "gpt-3.5-turbo",
    "name": "GPT35-4k",
    "maxToken": 4000,
    "price": 0,
    "prompt": "",
    "functionCall": false
  }
}

复现步骤

预期结果 正常返回对话结果

相关截图

jakejrc commented 11 months ago

我的也是这样,退回到上个版本4.4.6就可以

c121914yu commented 11 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Mine is the same, just go back to the previous version 4.4.6

c121914yu commented 11 months ago

4.4.7升级了openai的包,似乎就是 chatglm 这个渠道有问题,其他国内的包括自定义都可以,但是看请求参数看不出问题。。。待排查

fskz commented 11 months ago

我的也是这样,退回到上个版本4.4.6就可以

确实,我退回4.4.6能用了,感谢

c121914yu commented 11 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Mine is the same, just go back to the previous version 4.4.6

Indeed, I returned it to 4.4.6 and it works, thank you

jakejrc commented 11 months ago

我发现在4.4.7版本下SparkDesk不受影响,其他的不行~

c121914yu commented 11 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I found that SparkDesk is not affected under version 4.4.7, but not others~

c121914yu commented 11 months ago

我发现在4.4.7版本下SparkDesk不受影响,其他的不行~

我是除了chatglm都可以

jakejrc commented 11 months ago

在4.5中此问题仍然未解决!

c121914yu commented 11 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


This issue is still unresolved in 4.5!

c121914yu commented 11 months ago

在4.5中此问题仍然未解决!

不打算解决,等oneapi解决

c121914yu commented 10 months ago

已修复,由于 openai sdk4.x 与 oneapi 的 headers 没有完全相同。 https://github.com/labring/FastGPT/pull/421

ccyyhh2024 commented 3 months ago

V4.8 也有这个问题 2024-05-22 00:07:18 { 2024-05-22 00:07:18 message: 'core.chat.Chat API is error or undefined', 2024-05-22 00:07:18 stack: undefined 2024-05-22 00:07:18 } 2024-05-22 00:07:18 [ERROR] 2024-05-21 16:07:18 sse error: core.chat.Chat API is error or undefined

c121914yu commented 3 months ago

headers

你的api问题

ccyyhh2024 commented 3 months ago

headers

你的api问题

怎么能搞定那?

c121914yu commented 3 months ago

headers

你的api问题

怎么能搞定那?

搞定你的api,让它能用