(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("你是谁"))
相关推荐
零基础12339 分钟前
DeepSeek V4.1 Flash (Batch) 的性能测试与应用
经验分享·python·语言模型·vllm
Jo乔戈里2 小时前
免费本地搜图软件
图像处理·python·搜索引擎·ai
零基础1233 小时前
Agent 的 Memory 怎么做科研:以中医诊断场景为例
人工智能·经验分享·python·语言模型
tomlone5 小时前
AI 实践:OpenClaw + 本地 Ollama + Qwen3.5
人工智能·自然语言处理·ai写作
东方佑6 小时前
v24 (Hybrid2Fast) 架构与实验报告
人工智能·深度学习·语言模型·自然语言处理·架构
全栈练习生8 小时前
大模型原理之 Softmax
python·ai
唯鹿8 小时前
Jev初体验记录
人工智能·ai·jev
Martina_03219 小时前
同一片森林换个镜头就忽冷忽暖?用6步统一曝光、LUT与相机后处理
人工智能·游戏·数学建模·3d·自然语言处理·aigc·游戏策划
网络毒刘9 小时前
MCP 资源与提示(resources/prompts)实战:不只 tools,把只读上下文结构化喂给 Agent
人工智能·ai·cursor
数商思语行10 小时前
从BA、产品、实施或开发转做FDE,先补哪种能力
人工智能·ai·供应链·商业分析·ontology·本体·fde