ManTea commited on
Commit
131c078
·
1 Parent(s): e481068

add keyword list and remove some logs

Browse files
Files changed (1) hide show
  1. app/api/rag_routes.py +7 -2
app/api/rag_routes.py CHANGED
@@ -59,6 +59,7 @@ logger = logging.getLogger(__name__)
59
  # Configure Google Gemini API
60
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
61
  genai.configure(api_key=GOOGLE_API_KEY)
 
62
 
63
  # Create router
64
  router = APIRouter(
@@ -70,7 +71,7 @@ fix_request = PromptTemplate(
70
  template = """Goal:
71
  Your task is to extract important keywords from the user's current request, optionally using chat history if relevant.
72
  You will receive a conversation history and the user's current message.
73
- Generate a **list of concise keywords** that best represent the user's intent.
74
 
75
  Return Format:
76
  Only return keywords (comma-separated, no extra explanation).
@@ -80,6 +81,9 @@ If the current message IS related to the chat history: Return a refined set of k
80
  Warning:
81
  Only use chat history if the current message is clearly related to the prior context.
82
 
 
 
 
83
  Conversation History:
84
  {chat_history}
85
 
@@ -238,6 +242,7 @@ async def chat(request: ChatRequest, background_tasks: BackgroundTasks):
238
  )
239
 
240
  prompt_request = fix_request.format(
 
241
  question=request.question,
242
  chat_history=chat_history
243
  )
@@ -282,7 +287,7 @@ async def chat(request: ChatRequest, background_tasks: BackgroundTasks):
282
  question=request.question,
283
  chat_history=chat_history
284
  )
285
- logger.info(f"Full prompt with history and context: {prompt_text}")
286
 
287
  # Generate response
288
  response = model.generate_content(prompt_text)
 
59
  # Configure Google Gemini API
60
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
61
  genai.configure(api_key=GOOGLE_API_KEY)
62
+ KEYWORD_LIST = os.getenv("KEYWORDS")
63
 
64
  # Create router
65
  router = APIRouter(
 
71
  template = """Goal:
72
  Your task is to extract important keywords from the user's current request, optionally using chat history if relevant.
73
  You will receive a conversation history and the user's current message.
74
+ Pick 2-3 keywords from "keyword list" that best represent the user's intent.
75
 
76
  Return Format:
77
  Only return keywords (comma-separated, no extra explanation).
 
81
  Warning:
82
  Only use chat history if the current message is clearly related to the prior context.
83
 
84
+ Keyword list:
85
+ {keyword_list}
86
+
87
  Conversation History:
88
  {chat_history}
89
 
 
242
  )
243
 
244
  prompt_request = fix_request.format(
245
+ keyword_list=KEYWORD_LIST,
246
  question=request.question,
247
  chat_history=chat_history
248
  )
 
287
  question=request.question,
288
  chat_history=chat_history
289
  )
290
+ logger.info(f"Context: {context}")
291
 
292
  # Generate response
293
  response = model.generate_content(prompt_text)