(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("你是谁"))
相关推荐
七夜zippoe1 天前
SoduWork 源码解读:从源码启动到验收签字的运行追踪
人工智能·ai·源码解读·soduwork
如夏倾城1 天前
大模型(Large Model)解析:从数据类型、模型架构到任务选型
服务器·网络·数据库·语言模型·架构·audiolm
秋饼1 天前
Spring Framework 7 内置弹性实战:@Retryable 语义翻转、虚拟线程流量放大与 LLM 网关治理
java·ai·技术分享·后端开发
秋饼1 天前
Spring AI 2.0 渐进式工具披露实战:ToolSearchToolCallingAdvisor 源码机制、四种 ToolIndex 选型与多租户踩坑
java·ai·技术分享·后端开发
富贵儿9981 天前
NL2SQL 实践手记 04:多表查询为什么更难——让模型找对表、连对关系
数据库·sql·ai·自然语言处理·langchain
fly-iot1 天前
【摩尔线程S4000卡】执行Qwen3-14B-W8A8 量化、启动与接口性能测试报告,结果更慢了13 tok/s
人工智能·语言模型
Mininglamp_27181 天前
贡献者工具链设计:从 Issue 到合并的自动化支撑
ai·开源·自动化·社区运营
Dawson Zhu1 天前
Agent记忆架构深度解析:为什么摘要会丢信息?如何构建“无损优先“的记忆系统
人工智能·语言模型·架构·aigc·agi
武雄(小星Ai)1 天前
大模型API逆向实战:用延迟指纹判断后端是不是换皮Qwen
ai·性能优化·大模型
LMYH11232 天前
企业数字化实战 Day 2:理解项目、需求、任务之间的关系
ai·项目管理·飞书多维表格·fde