This commit is contained in:
@@ -16,6 +16,7 @@ from sqlalchemy import update
|
||||
from sqlalchemy import func
|
||||
import logging
|
||||
import httpx
|
||||
import json
|
||||
from . import schema
|
||||
from . import model
|
||||
from . import config
|
||||
@@ -103,17 +104,27 @@ def search_persons() -> model.PersonSearchResult:
|
||||
return model.PersonSearchResult(persons=persons)
|
||||
|
||||
def generate_person_bio() -> str:
|
||||
search_result = search_persons()
|
||||
if not search_result.persons:
|
||||
return "No person found."
|
||||
|
||||
person = search_result.persons[0]
|
||||
person_json = json.dumps(person.model_dump())
|
||||
|
||||
system_prompt = "Erstelle eine Beschreibung der Person in 3-5 Sätzen. Gebe nur die Beschreibung zurück, ohne Einleitung oder Schluss."
|
||||
user_prompt = f"Daten zur Person:\n{person_json}"
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {config.settings.llm_api_token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
payload = {
|
||||
"model": config.settings.llm_model,
|
||||
"prompt": "Hallo, wie ist dein Name?",
|
||||
"prompt": f"{system_prompt}\n{user_prompt}",
|
||||
"stream": False
|
||||
}
|
||||
|
||||
with httpx.Client() as client:
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
response = client.post(config.settings.llm_api_url, json=payload, headers=headers)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
|
||||
Reference in New Issue
Block a user