-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (24 loc) · 823 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio
import uvicorn
from app.agent.dynamic_agent import DynamicAgent
from app.server import app
import os
from dotenv import load_dotenv
async def initialize_agent():
load_dotenv()
uri = os.getenv('NEO4J_URI')
user = os.getenv('NEO4J_USER')
password = os.getenv('NEO4J_PASSWORD')
base_path = os.getenv('VIRTUAL_ENV_BASE_PATH', './virtual_env')
agent = DynamicAgent(uri, user, password, base_path)
await agent.setup()
return agent
async def main():
agent = await initialize_agent()
app.state.agent = agent # Store the agent in the FastAPI app state
# Run the FastAPI server
config = uvicorn.Config(app, host="0.0.0.0", port=8000, log_level="info")
server = uvicorn.Server(config)
await server.serve()
if __name__ == "__main__":
asyncio.run(main())