1234567891011121314151617181920212223242526272829303132333435 |
- # -*- coding: utf-8 -*-
- from fastapi import Request, APIRouter, Query
- from pydantic import BaseModel
- from core.respone_format import *
- from gpt.article_annotation import Annotation
- router_article_annotation = APIRouter()
- annotation_obj = Annotation()
- class Annotation(BaseModel):
- english_text: str
- @router_article_annotation.post("/article/meaning/annotation")
- def post_annotation(json_data: Annotation, request: Request, ):
- """词义标注的同步接口"""
- json_data = json_data.model_dump()
- english_text = json_data.get("english_text")
- real_ip = request.headers.get("X-Real-IP", "0.0.0.0")
- resp = annotation_obj.submit_task(
- english_text=english_text,
- real_ip=real_ip,
- )
- return resp_200(data=resp)
- @router_article_annotation.get("/article/query_annotation")
- async def query_annotation(task_id: int = Query(...)):
- resp = await annotation_obj.query_result_by_taskid(task_id)
- return resp
|