Spaces:
Running
Running
Update app.py
Browse files
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="
|
| 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 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|