mirror of
https://github.com/Sosokker/plain-rag.git
synced 2025-12-19 14:54:05 +01:00
feat: add system prompt configuration and update model usage in RAG service
This commit is contained in:
parent
ddabaed1c4
commit
2ac2162c28
@ -78,6 +78,8 @@ class Settings(BaseSettings):
|
|||||||
|
|
||||||
GEMINI_API_KEY: str = "secret"
|
GEMINI_API_KEY: str = "secret"
|
||||||
|
|
||||||
|
SYSTEM_PROMPT: str = "You are a helpful assistant that answers questions based on the provided context."
|
||||||
|
|
||||||
model_config = SettingsConfigDict(
|
model_config = SettingsConfigDict(
|
||||||
env_file=ENV_FILE,
|
env_file=ENV_FILE,
|
||||||
env_file_encoding="utf-8",
|
env_file_encoding="utf-8",
|
||||||
|
|||||||
@ -8,8 +8,10 @@ from PyPDF2 import PdfReader
|
|||||||
from PyPDF2.errors import PyPdfError
|
from PyPDF2.errors import PyPdfError
|
||||||
from structlog import get_logger
|
from structlog import get_logger
|
||||||
|
|
||||||
|
from app.core.config import settings
|
||||||
from app.core.interfaces import EmbeddingModel, Reranker, VectorDB
|
from app.core.interfaces import EmbeddingModel, Reranker, VectorDB
|
||||||
from app.core.utils import RecursiveCharacterTextSplitter
|
from app.core.utils import RecursiveCharacterTextSplitter
|
||||||
|
from app.schemas.enums import LLMModelName
|
||||||
|
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
|
|
||||||
@ -108,11 +110,11 @@ Answer:"""
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
response = litellm.completion(
|
response = litellm.completion(
|
||||||
model="gemini/gemini-2.0-flash",
|
model=LLMModelName.GeminiFlash.value,
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": "You are a helpful assistant that answers questions based on the provided context.",
|
"content": settings.SYSTEM_PROMPT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
@ -157,11 +159,11 @@ Answer:"""
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
response = litellm.completion(
|
response = litellm.completion(
|
||||||
model="gemini/gemini-2.0-flash",
|
model=LLMModelName.GeminiFlash.value,
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": "You are a helpful assistant that answers questions based on the provided context.",
|
"content": settings.SYSTEM_PROMPT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
|
|||||||
@ -23,7 +23,6 @@ structlog.configure(
|
|||||||
structlog.processors.StackInfoRenderer(),
|
structlog.processors.StackInfoRenderer(),
|
||||||
structlog.dev.ConsoleRenderer(),
|
structlog.dev.ConsoleRenderer(),
|
||||||
],
|
],
|
||||||
wrapper_class=structlog.make_filtering_bound_logger(structlog.INFO),
|
|
||||||
context_class=dict,
|
context_class=dict,
|
||||||
logger_factory=structlog.PrintLoggerFactory(),
|
logger_factory=structlog.PrintLoggerFactory(),
|
||||||
cache_logger_on_first_use=False,
|
cache_logger_on_first_use=False,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user