Guiyom commited on
Commit
19a4ef5
·
verified ·
1 Parent(s): ae878bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -40
app.py CHANGED
@@ -642,46 +642,6 @@ class RaindropSearchBot:
642
  logger.error(f"Error preprocessing query: {e}")
643
  return query
644
 
645
- def generate_search_query(self, user_request: str) -> str:
646
- """Convert user request to optimized search terms."""
647
- logger.info(f"Generating search query for: {user_request}")
648
-
649
- prompt = f"""
650
- You are a search expert. Create a search query to find relevant documents about:
651
- {user_request}
652
-
653
- Guidelines:
654
- - Focus on key concepts and synonyms
655
- - Use combination of keywords that would appear in titles or descriptions
656
- - Return only the search terms, no explanation
657
- - Include alternative phrasings
658
- - Keep it concise (max 6-8 key terms/phrases)
659
- - use the formatting authorised in raindrop search:
660
- o use " for exact search (ex: "artificial intelligence")
661
- o use - to exclude some terms (ex: -math) // Do not exclude terms that are potentially relevant
662
- o use match:OR for alternatives (ex: apple match:OR banana )
663
- o use match:AND for inclusion of both cases systematically (ex: apple match:AND banana )
664
- o use parenthesis for combinations ( ex: sugar match:AND (banana match:OR apple) )
665
-
666
- Example elaborate request: ("artificial intelligence" match:OR AI) -"machine learning"
667
- Use your judgement, think step by steps.
668
- Return only the search query terms.
669
- """
670
-
671
- try:
672
- response = self.client.chat.completions.create(
673
- model="gpt-4o-mini",
674
- messages=[{"role": "user", "content": prompt}],
675
- temperature=0.3,
676
- max_tokens=50
677
- )
678
- search_query = response.choices[0].message.content.strip()
679
- logger.info(f"Generated search query: {search_query}")
680
- return search_query
681
- except Exception as e:
682
- logger.error(f"Error generating search query: {e}")
683
- return user_request
684
-
685
  # Initialize bot
686
  bot = RaindropSearchBot()
687
 
 
642
  logger.error(f"Error preprocessing query: {e}")
643
  return query
644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  # Initialize bot
646
  bot = RaindropSearchBot()
647