| from fastapi import FastAPI,Request,HTTPException,Response |
| from pydantic import BaseModel |
| from typing import Optional |
| from fastapi.responses import JSONResponse |
| from fastapi.middleware.cors import CORSMiddleware |
| import json |
| import base64 |
| from engine import UCGEngine,TOOLS |
| from components.ucg_g1 import UGC_GRAPH_1 |
| from app_layer_agent import UCGBRIDGE |
|
|
|
|
|
|
| app=FastAPI() |
| runner = UCGEngine(UGC_GRAPH_1,TOOLS) |
| origins=["*"] |
|
|
|
|
|
|
|
|
| app.add_middleware( |
| |
| CORSMiddleware, |
| allow_origins=origins, |
| allow_credentials=True, |
| allow_methods=["*"], |
| allow_headers=["*"], |
| ) |
|
|
|
|
|
|
| class UGCState(BaseModel): |
| address: str |
| to: Optional[str] = None |
| amount: Optional[str] = None |
| payload: Optional[str] = None |
|
|
| class Ugcinput(BaseModel): |
| operation:str |
| state:UGCState |
|
|
|
|
| class Prompt(BaseModel): |
| prompt:str |
|
|
| |
|
|
|
|
| @app.post("/ucg") |
| async def UCG(request:Prompt): |
|
|
| |
| |
| |
| ucb=UCGBRIDGE() |
| out=ucb.run_conversation(request.prompt) |
| |
| return JSONResponse(content={"response":out}) |
| |
|
|
|
|
|
|