mirror of
https://github.com/microsoft/autogen.git
synced 2025-07-04 07:26:28 +00:00

* update version, fix component factory bug * add basic structure for deploy * minor fixes, deploy v1 * minor text updated * format fixes * formatting fixes .. webby test samples * update cli command, update views, * packakge.json and other fixes * format fixes
31 lines
812 B
Python
31 lines
812 B
Python
# loads a fast api api endpoint with a single endpoint that takes text query and return a response
|
|
|
|
import json
|
|
import os
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from ..datamodel import Response
|
|
from ..teammanager import TeamManager
|
|
|
|
app = FastAPI()
|
|
team_file_path = os.environ.get("AUTOGENSTUDIO_TEAM_FILE", None)
|
|
|
|
|
|
if team_file_path:
|
|
team_manager = TeamManager()
|
|
else:
|
|
raise ValueError("Team file must be specified")
|
|
|
|
|
|
@app.get("/predict/{task}")
|
|
async def predict(task: str):
|
|
response = Response(message="Task successfully completed", status=True, data=None)
|
|
try:
|
|
result_message = await team_manager.run(task=task, team_config=team_file_path)
|
|
response.data = result_message
|
|
except Exception as e:
|
|
response.message = str(e)
|
|
response.status = False
|
|
return response
|