ashfaq93 commited on
Commit
470ff4b
·
verified ·
1 Parent(s): 9a2c599

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,14 +1,15 @@
 
 
 
 
 
 
 
1
  import gradio as gr
2
- from Rag_conversation import rag_chain # Import the RAG pipeline from your script
3
  from langchain_core.messages import HumanMessage, SystemMessage
4
 
5
  # Function to process user messages
6
  def chatbot(user_message, history):
7
- """
8
- :param user_message: The latest user message
9
- :param history: A list of (user, ai) tuples from Gradio chat
10
- :return: (bot_reply, updated_history)
11
- """
12
  chat_history = []
13
  for h in history:
14
  chat_history.append(HumanMessage(content=h[0])) # User message
@@ -22,7 +23,6 @@ def chatbot(user_message, history):
22
 
23
  return bot_reply
24
 
25
-
26
  # Create Gradio UI
27
  demo = gr.ChatInterface(
28
  chatbot,
 
1
+ import os
2
+ from dotenv import load_dotenv
3
+
4
+ # Load .env from the root directory
5
+ load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), ".env"))
6
+
7
+ from Rag_conversation import rag_chain # Now import the chatbot pipeline
8
  import gradio as gr
 
9
  from langchain_core.messages import HumanMessage, SystemMessage
10
 
11
  # Function to process user messages
12
  def chatbot(user_message, history):
 
 
 
 
 
13
  chat_history = []
14
  for h in history:
15
  chat_history.append(HumanMessage(content=h[0])) # User message
 
23
 
24
  return bot_reply
25
 
 
26
  # Create Gradio UI
27
  demo = gr.ChatInterface(
28
  chatbot,