(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("你是谁"))
相关推荐
亚里随笔22 分钟前
小型语言模型:智能体AI的未来?
人工智能·语言模型·自然语言处理·llm·rlhf·agentic
mit6.82423 分钟前
[code-review] AI聊天接口 | 语言模型通信器
人工智能·语言模型·代码复审
Rysxt_1 小时前
Spring Boot 集成 Spring AI OpenAI Starter 教程
java·spring boot·后端·ai
SmartBrain2 小时前
DeerFlow实践:华为LTC流程的评审智能体设计
华为·语言模型
shizidushu3 小时前
Hugging Face NLP课程学习记录 - 3. 微调一个预训练模型
人工智能·学习·自然语言处理·微调·huggingface
盼小辉丶4 小时前
Transformer实战(18)——微调Transformer语言模型进行回归分析
深度学习·语言模型·回归·transformer
程序员ken5 小时前
深入理解大语言模型(5)-关于token
人工智能·语言模型·自然语言处理
前端农民工ws5 小时前
Vue 框架的 markdown 渲染组件,针对 AI 的 markdown 流式传输场景
前端·javascript·vue.js·ai
金井PRATHAMA8 小时前
认知语义学中的象似性对人工智能自然语言处理深层语义分析的影响与启示
人工智能·自然语言处理·知识图谱