feat: AI patient onboarding backend and documentation

This commit is contained in:
2026-08-27 12:15:09 +05:30
parent b9440772d1
commit 59c1372fe3
49 changed files with 4012 additions and 0 deletions
@@ -0,0 +1,39 @@
from openai import AsyncOpenAI
from app.config import OPENAI_API_KEY, OPENAI_MODEL
class OpenAIClient:
_client = None
def __init__(self):
self.api_key = OPENAI_API_KEY
self.model = OPENAI_MODEL
if OpenAIClient._client is None and self.api_key:
OpenAIClient._client = AsyncOpenAI(
api_key=self.api_key,
timeout=12.0,
max_retries=1,
)
async def generate_response(
self,
system_prompt: str,
user_message: str,
) -> str:
client = OpenAIClient._client or AsyncOpenAI(
api_key=self.api_key or "sk-dummy-key-placeholder",
timeout=12.0,
)
response = await client.chat.completions.create(
model=self.model or "gpt-4o-mini",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_message},
],
response_format={"type": "json_object"},
temperature=0.35,
max_completion_tokens=140,
)
return response.choices[0].message.content