mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
44 lines
883 B
Python
44 lines
883 B
Python
import os
|
|
import warnings
|
|
from dotenv import load_dotenv
|
|
from fastapi import FastAPI
|
|
import uvicorn
|
|
from src.agent import graph
|
|
from copilotkit import LangGraphAGUIAgent
|
|
from ag_ui_langgraph import add_langgraph_fastapi_endpoint
|
|
|
|
_ = load_dotenv()
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok"}
|
|
|
|
|
|
add_langgraph_fastapi_endpoint(
|
|
app=app,
|
|
agent=LangGraphAGUIAgent(
|
|
name="sample_agent",
|
|
description="An example agent to use as a starting point for your own agent.",
|
|
graph=graph,
|
|
),
|
|
path="/",
|
|
)
|
|
|
|
|
|
def main():
|
|
"""Run the uvicorn server."""
|
|
port = int(os.getenv("PORT", "8123"))
|
|
uvicorn.run(
|
|
"main:app",
|
|
host="0.0.0.0",
|
|
port=port,
|
|
reload=True,
|
|
)
|
|
|
|
|
|
warnings.filterwarnings("ignore", category=UserWarning, module="pydantic")
|
|
if __name__ == "__main__":
|
|
main()
|