(RAG系列) FastGPT通过API调用工作流问答

FastGPT通过API调用工作流问答

版本

fastgpt v4.8.10

使用说明

注意两个参数

  • stream 是否流式输出

  • detail 是否体现工作流过程细节

代码模板

复制代码
import requests
import pandas as pd

def get_completion(question):
    # Define the URL and headers
    url = "http://xxxx:3000/api/v1/chat/completions"
    headers = {
        "Authorization": "Bearer ",
        "Content-Type": "application/json"
    }

  
    data = {
        "chatId": "lizhihiui",
        "stream": False,
        "detail": False,
        "responseChatItemId": "my_responseChatItemId",
        "variables": {
            "uid": "asdfadsfasfd2323",
            "name": "张三"
        },
        "messages": [
            {
                "role": "user",
                "content": question
            }
        ]
    }

    response = requests.post(url, json=data, headers=headers)

    api_response = response.json()
    if 'code' in api_response and api_response['code'] == 500:
        return "报错"
    content = api_response["choices"][0]["message"]["content"]

    return content

print(get_completion("你是谁"))
相关推荐
哥布林学者39 分钟前
吴恩达深度学习课程二: 改善深层神经网络 第二周:优化算法(四)RMSprop
深度学习·ai
不叫猫先生40 分钟前
基于华为昇腾CANN的自定义算子开发
华为·语言模型·大模型·cann
CoderJia程序员甲1 小时前
GitHub 热榜项目 - 日榜(2025-11-07)
ai·开源·大模型·github·ai教程
程序员 小明2 小时前
xpert AI工作流工具本地部署
ai·ai工作流
郁大锤4 小时前
OpenAI responses使用教程(三) ——Responses create python SDK 介绍
人工智能·python·ai·openai
知了一笑4 小时前
AI是风口还是泡沫?一个独立开发者的冷思考
ai·ai产品
我是苏苏4 小时前
一步步实现 AI 模型调用:DeepSeek 深度对接实战全解析
ai·.net
paopao_wu4 小时前
DeepSeek-OCR实战(02):DeepSeek-OCR模型介绍
ai·ocr·deepseek
AI 研究所5 小时前
1024开发者节:开源发布,引领生态繁荣
人工智能·语言模型·开源·大模型·交互·agent
CoderJia程序员甲5 小时前
GitHub 热榜项目 - 日榜(2025-11-08)
ai·开源·github·1024程序员节·ai教程