news 2026/5/7 23:40:38

dify API访问工作流/聊天

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
dify API访问工作流/聊天
chatflow
import requests import json # API 配置 api_key = "app-xxx" # 替换为你的 API Key base_url = "http://192.168.1.100:8080/v1" endpoint = "/chat-messages" # 请求头 headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } # 请求体 data = { "inputs": {}, "query": "What are the specs of the iPhone 13 Pro Max?", "response_mode": "streaming", "conversation_id": "", "user": "ywxx" } # 发送请求 response = requests.post( url=f"{base_url}{endpoint}", headers=headers, data=json.dumps(data), stream=True # 启用流式响应 ) # 处理流式响应 if response.status_code == 200: for line in response.iter_lines(): if line: line = line.decode('utf-8') if line.startswith('data: '): try: data = json.loads(line[6:]) # 移除 'data: ' 前缀 print(data) except json.JSONDecodeError: continue else: print(f"Error: {response.status_code}") print(response.text)
工作流(workflows)
import requests # API 配置 api_key = "app-zzzz" base_url = "http://192.168.1.110:8080/v1" # 请求头 headers = { "Authorization": f"Bearer {api_key}" } # 发送请求 response = requests.get( url=f"{base_url}/workflows/logs", headers=headers ) # response = requests.get( # url=f"{base_url}/info", # headers=headers # ) # 检查响应 if response.status_code == 200: logs_data = response.json() print("工作流日志获取成功:") print(logs_data) else: print(f"请求失败:{response.status_code}") print(response.text)
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/7 0:35:04

我做了100道入门题

题目列表 - 入门与面试 (https://www.luogu.com.cn/problem/list?typeB).I print(sum(map(int, input().split())))II print("Hello,World!")III print(input().split()[1])IV a, b, c map(int, input().split()) print(f"{a:8d} {b:8d} {c:8d}")V c in…

作者头像 李华
网站建设 2026/5/7 2:33:47

Honey Select 2 HF Patch终极指南:从安装到精通

Honey Select 2 HF Patch终极指南:从安装到精通 【免费下载链接】HS2-HF_Patch Automatically translate, uncensor and update HoneySelect2! 项目地址: https://gitcode.com/gh_mirrors/hs/HS2-HF_Patch 还在为Honey Select 2游戏体验不佳而困扰吗&#xf…

作者头像 李华
网站建设 2026/5/2 7:30:50

阿里云盘Refresh Token扫码神器:3分钟轻松获取API密钥

阿里云盘Refresh Token扫码神器:3分钟轻松获取API密钥 【免费下载链接】aliyundriver-refresh-token QR Code扫码获取阿里云盘refresh token For Web 项目地址: https://gitcode.com/gh_mirrors/al/aliyundriver-refresh-token 想要实现阿里云盘自动化管理却…

作者头像 李华
网站建设 2026/5/1 9:47:57

Predis故障恢复终极指南:Redis连接自动修复与高可用性保障

Predis故障恢复终极指南:Redis连接自动修复与高可用性保障 【免费下载链接】predis 项目地址: https://gitcode.com/gh_mirrors/pre/predis 在当今高并发的互联网应用中,Redis作为高性能的内存数据库已成为不可或缺的基础设施。而Predis作为PHP领…

作者头像 李华
网站建设 2026/5/3 13:46:08

Running a Natural Cosmetics Store Calmly with Ofeianht

Ofeianht Site Notes: Product Flow, Trust Cues, and Upkeep I rebuilt a small natural-cosmetics WordPress store recently and anchored the structure around Ofeianht – Natural Cosmetics WordPress Theme because the previous site had a problem that’s easy to …

作者头像 李华