ahmadgenus commited on
Commit
5fcdfe8
·
1 Parent(s): e552ac2

new_chatbot_minor_chnages

Browse files
Files changed (1) hide show
  1. chatbot.py +1 -3
chatbot.py CHANGED
@@ -73,8 +73,6 @@ def keyword_in_post_or_comments(post, keyword):
73
 
74
  # Fetch and process Reddit data
75
  def fetch_reddit_data(keyword, days=7, limit=None):
76
- print("Reddit Keys Check:", os.getenv("REDDIT_CLIENT_ID"), os.getenv("REDDIT_CLIENT_SECRET"))
77
-
78
  end_time = datetime.utcnow()
79
  start_time = end_time - timedelta(days=days)
80
  subreddit = reddit.subreddit("all")
@@ -195,7 +193,7 @@ def get_chatbot_response(question, keyword, reddit_id=None):
195
  context_posts = retrieve_context(question, keyword, reddit_id)
196
  context = "\n\n".join([f"{p[0]}:\n{p[1]}" for p in context_posts])
197
  if len(context) > 3000:
198
- context = summarize_chain.run({"context": context})
199
  combined_input = f"Context:\n{context}\n\nUser Question: {question}"
200
  response = chat_chain.invoke({"input": combined_input})
201
  return response, context_posts
 
73
 
74
  # Fetch and process Reddit data
75
  def fetch_reddit_data(keyword, days=7, limit=None):
 
 
76
  end_time = datetime.utcnow()
77
  start_time = end_time - timedelta(days=days)
78
  subreddit = reddit.subreddit("all")
 
193
  context_posts = retrieve_context(question, keyword, reddit_id)
194
  context = "\n\n".join([f"{p[0]}:\n{p[1]}" for p in context_posts])
195
  if len(context) > 3000:
196
+ context = summarize_chain.invoke({"context": context})
197
  combined_input = f"Context:\n{context}\n\nUser Question: {question}"
198
  response = chat_chain.invoke({"input": combined_input})
199
  return response, context_posts