Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,18 +60,17 @@ client = InferenceClient(HF_MODEL_ID, token=os.getenv("HF_TOKEN"))
|
|
| 60 |
import os
|
| 61 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 62 |
|
| 63 |
-
# 1.
|
| 64 |
-
|
| 65 |
-
http_llm = HuggingFaceEndpoint(
|
| 66 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 67 |
-
task="text-generation
|
| 68 |
max_new_tokens=512,
|
| 69 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 70 |
)
|
| 71 |
|
| 72 |
-
# 2. Wrap it
|
| 73 |
-
#
|
| 74 |
-
llm = ChatHuggingFace(llm=
|
| 75 |
|
| 76 |
# -------------------------
|
| 77 |
# Document loader
|
|
|
|
| 60 |
import os
|
| 61 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 62 |
|
| 63 |
+
# 1. Create the endpoint with the 'conversational' task
|
| 64 |
+
llm_endpoint = HuggingFaceEndpoint(
|
|
|
|
| 65 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 66 |
+
task="conversational", # Change this from 'text-generation'
|
| 67 |
max_new_tokens=512,
|
| 68 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 69 |
)
|
| 70 |
|
| 71 |
+
# 2. Wrap it in ChatHuggingFace
|
| 72 |
+
# This is REQUIRED for conversational tasks to work with RAG chains
|
| 73 |
+
llm = ChatHuggingFace(llm=llm_endpoint)
|
| 74 |
|
| 75 |
# -------------------------
|
| 76 |
# Document loader
|