(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("你是谁"))
相关推荐
最后冰吻free2 小时前
【无标题】
ai
Fighting04292 小时前
怎么写一个规范标准的skill
ai
zhangjin11202 小时前
NLP自然语言处理
人工智能·自然语言处理
weixin_431600442 小时前
为什么 Agent REPL 要上 Ink:好处、用法与内部设计
前端·学习·ai·agent·ai编程
VIP_CQCRE3 小时前
用 Ace Data Cloud 自动发布 CSDN 技术博客:把 AI 内容变成可持续获客入口
ai·自动化·csdn·ace data cloud·技术营销
蒲公英eric3 小时前
从直接拼接到参数化查询:DVWA SQL 注入模块完整漏洞分析教程
ai·dvwa·ai安全·sql 注入模块·sql injection
大模型任我行3 小时前
Meta:动态批大小提升训练效率
人工智能·语言模型·自然语言处理·论文笔记
安_3 小时前
hazelcast langchain4j 持久化
ai·vertx
天天有money3 小时前
Claude 中转站用于报告生成:会议纪要、周报和项目复盘怎么提效
gpt·ai·chatgpt