skill中InputFileNode的输入无法通过api正常访问
keenouter opened this issue · comments
GuoMin commented
api访问参考文档https://dataelem.feishu.cn/wiki/CpXNw6ZTjiKimjkv66Wcw0EWnHc
import requests
from typing import Optional
BASE_API_URL = "https://bisheng.dataelem.com/api/v1/process"
FLOW_ID = "e4917a84-fad7-4d5d-85fd-bf2ec3c42c26"
TWEAKS = {
"CombineDocsChain-Pud2p": {},
"RetrievalQA-qH6Mk": {},
"OpenAIProxyEmbedding-yvld7": {},
"PyPDFLoader-SIeEa": {},
"InputFileNode-jdLkB": {},
"Milvus-T3kRH": {"collection_name": "col_333"},
"ChatOpenAI-qVQL6": {}
}
def upload_file():
server = "https://bisheng.dataelem.com"
url = server + '/api/v1/knowledge/upload'
headers = {}
files = {'file': open('/Users/sara/Desktop/20231201-223053.jpeg', 'rb')}
res = requests.post(url, headers=headers, files=files)
file_path = res.json()['data'].get('file_path', '')
return file_path
def run_flow(inputs: dict, flow_id: str, file_path: str, tweaks: Optional[dict] = None) -> dict:
api_url = f"{BASE_API_URL}/{flow_id}"
payload = {"inputs": inputs}
if tweaks:
payload["tweaks"] = tweaks
payload["inputs"]["file_path"] = file_path # Add the file_path to the inputs
if "InputFileNode-jdLkB" in tweaks:
tweaks["InputFileNode-jdLkB"]["file_path"] = file_path
response = requests.post(api_url, json=payload)
return response.json()
# Get the file path from api_call
file_path = upload_file()
# Setup any tweaks you want to apply to the flow
inputs = {"query": "总结下文档内容", "id": "RetrievalQA-qH6Mk"}
print(run_flow(inputs, flow_id=FLOW_ID, file_path=file_path, tweaks=TWEAKS))
skill示例图如下
整体为一个pdf内容提取的小skill,在使用过程中,前端由于自动关闭了websocket,导致需要在聊天框输入任意内容触发返回
bisheng后端版本:0.2.3
观察日志与网页端的区别为 没有触发pdf的内容解析导致整个流程出错,进而导致api调用失败
GuoMin commented
0.2.6版本已经修复了