feat: implement third party agent sub stage and refactor provider management
- Added `ThirdPartyAgentSubStage` to handle interactions with third-party agent runners (Dify, Coze, Dashscope). - Refactored `star_request.py` to ensure consistent return types in the `process` method. - Updated `stage.py` to initialize and utilize the new `AgentRequestSubStage`. - Modified `ProviderManager` to skip loading agent runner providers. - Removed `Dify` source implementation as it is now handled by the new agent runner structure. - Enhanced `DifyAPIClient` to support file uploads via both file path and file data. - Cleaned up shared preferences handling to simplify session preference retrieval. - Updated dashboard configuration to reflect changes in agent runner provider selection. - Refactored conversation commands to accommodate the new agent runner structure and remove direct dependencies on Dify. - Adjusted main application logic to ensure compatibility with the new conversation management approach.
This commit is contained in:
@@ -101,14 +101,16 @@ class DifyAPIClient:
|
||||
|
||||
async def file_upload(
|
||||
self,
|
||||
file_path: str,
|
||||
user: str,
|
||||
file_path: str | None = None,
|
||||
file_data: bytes | None = None,
|
||||
) -> dict[str, Any]:
|
||||
url = f"{self.api_base}/files/upload"
|
||||
with open(file_path, "rb") as f:
|
||||
|
||||
if file_data is not None:
|
||||
payload = {
|
||||
"user": user,
|
||||
"file": f,
|
||||
"file": file_data,
|
||||
}
|
||||
async with self.session.post(
|
||||
url,
|
||||
@@ -116,6 +118,20 @@ class DifyAPIClient:
|
||||
headers=self.headers,
|
||||
) as resp:
|
||||
return await resp.json() # {"id": "xxx", ...}
|
||||
elif file_path is not None:
|
||||
with open(file_path, "rb") as f:
|
||||
payload = {
|
||||
"user": user,
|
||||
"file": f,
|
||||
}
|
||||
async with self.session.post(
|
||||
url,
|
||||
data=payload,
|
||||
headers=self.headers,
|
||||
) as resp:
|
||||
return await resp.json() # {"id": "xxx", ...}
|
||||
else:
|
||||
raise ValueError("file_path 和 file_data 不能同时为 None")
|
||||
|
||||
async def close(self):
|
||||
await self.session.close()
|
||||
|
||||
Reference in New Issue
Block a user