feat: add system prompt configuration and update model usage in RAG service

This commit is contained in:
Sosokker 2025-06-27 22:34:24 +07:00
parent ddabaed1c4
commit 2ac2162c28
3 changed files with 8 additions and 5 deletions

View File

@ -78,6 +78,8 @@ class Settings(BaseSettings):
GEMINI_API_KEY: str = "secret"
SYSTEM_PROMPT: str = "You are a helpful assistant that answers questions based on the provided context."
model_config = SettingsConfigDict(
env_file=ENV_FILE,
env_file_encoding="utf-8",

View File

@ -8,8 +8,10 @@ from PyPDF2 import PdfReader
from PyPDF2.errors import PyPdfError
from structlog import get_logger
from app.core.config import settings
from app.core.interfaces import EmbeddingModel, Reranker, VectorDB
from app.core.utils import RecursiveCharacterTextSplitter
from app.schemas.enums import LLMModelName
logger = get_logger()
@ -108,11 +110,11 @@ Answer:"""
try:
response = litellm.completion(
model="gemini/gemini-2.0-flash",
model=LLMModelName.GeminiFlash.value,
messages=[
{
"role": "system",
"content": "You are a helpful assistant that answers questions based on the provided context.",
"content": settings.SYSTEM_PROMPT,
},
{
"role": "user",
@ -157,11 +159,11 @@ Answer:"""
try:
response = litellm.completion(
model="gemini/gemini-2.0-flash",
model=LLMModelName.GeminiFlash.value,
messages=[
{
"role": "system",
"content": "You are a helpful assistant that answers questions based on the provided context.",
"content": settings.SYSTEM_PROMPT,
},
{
"role": "user",

View File

@ -23,7 +23,6 @@ structlog.configure(
structlog.processors.StackInfoRenderer(),
structlog.dev.ConsoleRenderer(),
],
wrapper_class=structlog.make_filtering_bound_logger(structlog.INFO),
context_class=dict,
logger_factory=structlog.PrintLoggerFactory(),
cache_logger_on_first_use=False,