Ani14 commited on
Commit
7495b00
·
verified ·
1 Parent(s): 37d3962

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -33,12 +33,17 @@ def call_llm(messages, model="deepseek/deepseek-chat-v3-0324:free", max_tokens=2
33
  return result["choices"][0]["message"]["content"]
34
 
35
  def get_sources(topic, domains):
 
 
 
 
 
36
  with DDGS() as ddgs:
37
  return [{
38
  "title": r.get("title", "Untitled"),
39
  "snippet": r.get("body", ""),
40
  "url": r.get("href", "")
41
- } for r in ddgs.text(topic + " site:" + domains if domains else topic, max_results=5)]
42
 
43
  def get_arxiv_papers(query):
44
  from urllib.parse import quote_plus
 
33
  return result["choices"][0]["message"]["content"]
34
 
35
  def get_sources(topic, domains):
36
+ query = topic
37
+ if domains and isinstance(domains, str):
38
+ domain_list = [d.strip() for d in domains.split(",") if d.strip()]
39
+ if domain_list:
40
+ query = " OR ".join([f"site:{d} {topic}" for d in domain_list])
41
  with DDGS() as ddgs:
42
  return [{
43
  "title": r.get("title", "Untitled"),
44
  "snippet": r.get("body", ""),
45
  "url": r.get("href", "")
46
+ } for r in ddgs.text(query, max_results=5)]
47
 
48
  def get_arxiv_papers(query):
49
  from urllib.parse import quote_plus