mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-03-19 08:43:42 +00:00
API: add POST method w/ service; test action
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
"""
|
||||
Usage:
|
||||
$ uvicorn src.api.http_api:app --host 0.0.0.0 --port 9999
|
||||
"""
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pathlib import Path
|
||||
from pydantic import BaseModel
|
||||
from src.llm.llm import Phi3LanguageModel
|
||||
|
||||
|
||||
STATIC_PATH = Path(__file__).parent.absolute() / 'static'
|
||||
|
||||
@@ -19,3 +26,10 @@ class LanguageModelResponse(BaseModel):
|
||||
@app.get('/', response_model=str)
|
||||
async def health_check():
|
||||
return 'success'
|
||||
|
||||
|
||||
@app.post('/api/conversations', response_model=LanguageModelResponse)
|
||||
async def get_llm_conversation_response(request: LanguageModelPrompt):
|
||||
service = Phi3LanguageModel()
|
||||
response = service.invoke(user_input=request.prompt)
|
||||
return LanguageModelResponse(response=response)
|
||||
|
||||
Reference in New Issue
Block a user