forked from universal-tool-calling-protocol/python-utcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
27 lines (21 loc) · 641 Bytes
/
Copy pathserver.py
File metadata and controls
27 lines (21 loc) · 641 Bytes
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
from fastapi import FastAPI
from pydantic import BaseModel
from utcp.shared.provider import HttpProvider
from utcp.shared.tool import utcp_tool
from utcp.shared.utcp_manual import UtcpManual
class TestRequest(BaseModel):
value: str
__version__ = "1.0.0"
BASE_PATH = "http://localhost:8080"
app = FastAPI()
@app.get("/utcp", response_model=UtcpManual)
def get_utcp():
return UtcpManual.create(version=__version__)
@utcp_tool(tool_provider=HttpProvider(
name="test_provider",
url=f"{BASE_PATH}/test",
http_method="POST"
))
@app.post("/test")
def test_endpoint(data: TestRequest):
return {"received": data.value}