ExamFriendly commited on
Commit
3a9ccc3
·
verified ·
1 Parent(s): 6b82681

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -27,7 +27,7 @@ retriever = vectorstore.as_retriever()
27
 
28
  # 4. Initialize LLM (The Fix: Task="conversational")
29
  llm = HuggingFaceEndpoint(
30
- repo_id="meta-llama/Llama-3.2-3B-Instruct",
31
  task="conversational", # Required for Instruct/Chat models in 2026
32
  huggingfacehub_api_token=sec_token,
33
  temperature=0.1,
@@ -57,9 +57,13 @@ rag_chain = create_retrieval_chain(retriever, question_answer_chain)
57
 
58
  # 7. Define the Chat Function for Gradio
59
  def chat(message, history):
60
- # The chain expects a dictionary with "input"
61
- result = rag_chain.invoke({"input": message})
62
- return result["answer"]
 
 
 
 
63
 
64
  # 8. Launch the Interface
65
  demo = gr.ChatInterface(
 
27
 
28
  # 4. Initialize LLM (The Fix: Task="conversational")
29
  llm = HuggingFaceEndpoint(
30
+ repo_id="Mistral-7B-Instruct-v0.3"
31
  task="conversational", # Required for Instruct/Chat models in 2026
32
  huggingfacehub_api_token=sec_token,
33
  temperature=0.1,
 
57
 
58
  # 7. Define the Chat Function for Gradio
59
  def chat(message, history):
60
+ try:
61
+ # The chain expects a dictionary with "input"
62
+ result = rag_chain.invoke({"input": message})
63
+ return result["answer"]
64
+ except Exception as e:
65
+ # This will show you exactly why it failed in the chat box
66
+ return f"Error: {str(e)}"
67
 
68
  # 8. Launch the Interface
69
  demo = gr.ChatInterface(