mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-14 00:53:25 +00:00
feat: configuration
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user