Files
SIA/sia/__main__.py
2024-11-02 11:55:03 +01:00

59 lines
1.7 KiB
Python

import asyncio
from pathlib import Path
from .llm_engine import LlmEngine
from .system_metrics import SystemMetrics
from .web_agent import WebAgent
from .web_io_buffer import WebIOBuffer
from .web_server import WebServer
from .working_memory import WorkingMemory
from .xml_validator import XMLValidator
from .response_parser import ResponseParser
async def run_web_server():
"""Run the web server with default configuration."""
# Load system prompt and action schema
base_dir = Path(__file__).parent.parent
with open(base_dir / "system_prompt.txt", "r") as f:
system_prompt = f.read()
with open(base_dir / "action_schema.xsd", "r") as f:
action_schema = f.read()
# Initialize core components
llm = LlmEngine("/root/model")
working_memory = WorkingMemory()
system_metrics = SystemMetrics()
validator = XMLValidator(action_schema)
io_buffer = WebIOBuffer()
parser = ResponseParser(io_buffer)
# Create web agent
agent = WebAgent(
system_prompt=system_prompt,
action_schema=action_schema,
working_memory=working_memory,
system_metrics=system_metrics,
llm=llm,
validator=validator,
parser=parser
)
# Create and start web server
server = WebServer(agent, io_buffer, "0.0.0.0", 8080)
await server.start()
try:
# Keep running until interrupted
while True:
await asyncio.sleep(1)
except KeyboardInterrupt:
print("\nShutting down...")
finally:
await server.stop()
def main():
"""Main entry point for the SIA application."""
asyncio.run(run_web_server())
if __name__ == "__main__":
main()