fix data connector readfile
This commit is contained in:
parent
f766219d4b
commit
76753f6037
1 changed files with 4 additions and 6 deletions
|
|
@ -61,13 +61,11 @@ def _registerConnectionTools(registry: ToolRegistry, services):
|
||||||
)
|
)
|
||||||
adapter = await resolver.resolveService(connectionId, service)
|
adapter = await resolver.resolveService(connectionId, service)
|
||||||
chatService = services.chat
|
chatService = services.chat
|
||||||
fileContent = chatService.getFileContent(fileId)
|
fileData = chatService.getFileData(fileId)
|
||||||
if not fileContent:
|
if not fileData:
|
||||||
return ToolResult(toolCallId="", toolName="uploadToExternal", success=False, error="File not found")
|
return ToolResult(toolCallId="", toolName="uploadToExternal", success=False, error="File not found")
|
||||||
fileData = fileContent.get("data", b"") if isinstance(fileContent, dict) else b""
|
fileInfo = chatService.getFileInfo(fileId)
|
||||||
if isinstance(fileData, str):
|
fileName = (fileInfo or {}).get("fileName", "file")
|
||||||
fileData = fileData.encode("utf-8")
|
|
||||||
fileName = fileContent.get("fileName", "file") if isinstance(fileContent, dict) else "file"
|
|
||||||
result = await adapter.upload(path, fileData, fileName)
|
result = await adapter.upload(path, fileData, fileName)
|
||||||
return ToolResult(toolCallId="", toolName="uploadToExternal", success=True, data=str(result))
|
return ToolResult(toolCallId="", toolName="uploadToExternal", success=True, data=str(result))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue