mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-20 05:08:00 +00:00
enhanced management
This commit is contained in:
parent
ab64cda254
commit
b1682f8ea6
@ -6,6 +6,7 @@
|
||||
# Description :
|
||||
# This is an interface class for lollms bindings.
|
||||
######
|
||||
from fastapi import Request
|
||||
from typing import Dict, Any
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
@ -388,7 +389,7 @@ class LLMBinding:
|
||||
"""
|
||||
pass
|
||||
|
||||
def handle_request(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
async def handle_request(self, request: Request) -> Dict[str, Any]:
|
||||
"""
|
||||
Handle client requests.
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
# Description :
|
||||
# This is an interface class for lollms personalities.
|
||||
######
|
||||
from fastapi import Request
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from lollms.config import InstallOption, TypedConfig, BaseConfig
|
||||
@ -1687,9 +1688,13 @@ class APScript(StateMachine):
|
||||
parameters: A list of the command parameters
|
||||
|
||||
"""
|
||||
self.process_state(command, "", self.callback)
|
||||
try:
|
||||
self.process_state(command, "", self.callback)
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
self.warning(f"Couldn't execute command {command}")
|
||||
|
||||
def handle_request(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
async def handle_request(self, request: Request) -> Dict[str, Any]:
|
||||
"""
|
||||
Handle client requests.
|
||||
|
||||
@ -1705,7 +1710,7 @@ class APScript(StateMachine):
|
||||
```
|
||||
handler = YourHandlerClass()
|
||||
request_data = {"command": "some_command", "parameters": {...}}
|
||||
response = handler.handle_request(request_data)
|
||||
response = await handler.handle_request(request_data)
|
||||
```
|
||||
"""
|
||||
return {"status":True}
|
||||
|
@ -233,3 +233,4 @@ async def serve_uploads(path: str):
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
|
||||
return FileResponse(str(file_path))
|
||||
|
||||
|
@ -504,9 +504,8 @@ async def post_to_personality(request: Request):
|
||||
"""Post data to a personality"""
|
||||
|
||||
try:
|
||||
config_data = (await request.json())
|
||||
if hasattr(lollmsElfServer.personality.processor,'handle_request'):
|
||||
return lollmsElfServer.personality.processor.handle_request(config_data)
|
||||
return await lollmsElfServer.personality.processor.handle_request(request)
|
||||
else:
|
||||
return {}
|
||||
except Exception as ex:
|
||||
|
Loading…
Reference in New Issue
Block a user