This commit is contained in:
xds
2025-09-30 23:43:51 +04:00
commit 6f744b8066
7 changed files with 2327 additions and 0 deletions

44
api.py Normal file
View File

@@ -0,0 +1,44 @@
import asyncio
import json
import pickle
from fastapi import FastAPI
import deepseek_module
import nlp_processor
import nlp_teacher
app = FastAPI(title="NLP API", version="1.0")
# Загрузить сохраненную модель
@app.get('/predict')
async def predict(req, cloud:int=0, async_op: int=0):
print('here')
# Получить входные данные из запроса
if cloud==1:
if async_op==1:
response_msg = await deepseek_module.nlp_yandex(req)
else:
response_msg = deepseek_module.fast_nlp_yandex(req)
print(response_msg)
return json.loads(response_msg.encode('latin1').decode('utf-8'))
else:
# Сделать предсказание модели
prediction = nlp_processor.predict_category(req)
# Вернуть предсказание в виде JSON
return prediction
@app.get('/reteach')
async def reteach():
print(nlp_teacher.reteach())
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, port=8000)