Basic web loop works
This commit is contained in:
@@ -34,8 +34,10 @@ class TestLLM:
|
||||
yield "</reasoning>"
|
||||
|
||||
class Main:
|
||||
def __init__(self):
|
||||
self._config = Config()
|
||||
@classmethod
|
||||
async def create(cls, config: Config):
|
||||
self = cls()
|
||||
self._config = config
|
||||
|
||||
self._system_prompt = self._config.system_prompt.read_text()
|
||||
self._action_schema = self._config.action_schema.read_text()
|
||||
@@ -62,13 +64,14 @@ class Main:
|
||||
validator=XMLValidator(self._action_schema),
|
||||
parser=ResponseParser(self._io_buffer)
|
||||
)
|
||||
self._ws_manager = WebSocketManager(
|
||||
self._ws_manager = await WebSocketManager.create(
|
||||
self._agent,
|
||||
self._io_buffer
|
||||
)
|
||||
|
||||
self._app = web.Application()
|
||||
self._init_routes()
|
||||
return self
|
||||
|
||||
@property
|
||||
def app(self):
|
||||
@@ -114,6 +117,8 @@ class Main:
|
||||
return response
|
||||
|
||||
if __name__ == "__main__":
|
||||
main = Main()
|
||||
print("Web server started at http://localhost:8080")
|
||||
web.run_app(main.app, port=8080)
|
||||
loop = asyncio.new_event_loop()
|
||||
config = Config()
|
||||
main = loop.run_until_complete(Main.create(config))
|
||||
print(f"Web server started at http://{config.host}:{config.port}")
|
||||
web.run_app(main.app, loop=loop, host=config.host, port=config.port)
|
||||
Reference in New Issue
Block a user