mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-09-30 21:39:52 +02:00
API: add POST method w/ service; test action
This commit is contained in:
1 parent
9281bbd2f0
commit
eef8d73f7f
2 files changed
+14
-1
No files matched your search
@@ -60,7 +60,6 @@ jobs:
|
|||||||
|
|
||||||
- name: 'Run test API request'
|
- name: 'Run test API request'
|
||||||
run: ${{ github.workspace }}/.github/scripts/test_api.sh
|
run: ${{ github.workspace }}/.github/scripts/test_api.sh
|
||||||
if: false
|
|
||||||
|
|
||||||
- name: 'Start system monitoring'
|
- name: 'Start system monitoring'
|
||||||
run: ${{ github.workspace }}/.github/scripts/start_monitoring.sh &
|
run: ${{ github.workspace }}/.github/scripts/start_monitoring.sh &
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
|
"""
|
||||||
|
Usage:
|
||||||
|
$ uvicorn src.api.http_api:app --host 0.0.0.0 --port 9999
|
||||||
|
"""
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from src.llm.llm import Phi3LanguageModel
|
||||||
|
|
||||||
|
|
||||||
STATIC_PATH = Path(__file__).parent.absolute() / 'static'
|
STATIC_PATH = Path(__file__).parent.absolute() / 'static'
|
||||||
|
|
||||||
@@ -19,3 +26,10 @@ class LanguageModelResponse(BaseModel):
|
|||||||
@app.get('/', response_model=str)
|
@app.get('/', response_model=str)
|
||||||
async def health_check():
|
async def health_check():
|
||||||
return 'success'
|
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