feat: configuration

This commit is contained in:
superobk
2024-04-26 10:51:10 +08:00
parent f8f75e11ff
commit d493bd221f
4 changed files with 99 additions and 3 deletions

View File

@ -2,11 +2,18 @@ from typing import Any, Coroutine
from fastapi import Request, Response, status
from fastapi.responses import JSONResponse
from injector import inject
from ..configuration import TesouConf
from .blackbox import Blackbox
import requests
class Tesou(Blackbox):
url: str
@inject
def __init__(self, tesou_config: TesouConf):
self.url = tesou_config.url
def __call__(self, *args, **kwargs):
return self.processing(*args, **kwargs)
@ -17,12 +24,11 @@ class Tesou(Blackbox):
# 用户输入的数据格式为:[{"id": "123", "prompt": "叉烧饭,帮我查询叉烧饭的介绍"}]
def processing(self, id, prompt) -> str:
url = 'http://120.196.116.194:48891/chat/'
message = {
"user_id": id,
"prompt": prompt,
}
response = requests.post(url, json=message)
response = requests.post(self.url, json=message)
return response.json()
async def fast_api_handler(self, request: Request) -> Response: