Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,16 +53,21 @@ client = InferenceClient(HF_MODEL_ID, token=os.getenv("HF_TOKEN"))
|
|
| 53 |
# wait_for_model=True
|
| 54 |
# )
|
| 55 |
|
| 56 |
-
# 1.
|
|
|
|
| 57 |
llm_endpoint = HuggingFaceEndpoint(
|
| 58 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 59 |
-
task="text-generation",
|
| 60 |
max_new_tokens=512,
|
| 61 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 62 |
)
|
| 63 |
|
| 64 |
-
# 2.
|
| 65 |
-
# This
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
llm = ChatHuggingFace(llm=llm_endpoint)
|
| 67 |
|
| 68 |
# -------------------------
|
|
|
|
| 53 |
# wait_for_model=True
|
| 54 |
# )
|
| 55 |
|
| 56 |
+
# 1. Configure the endpoint
|
| 57 |
+
# We use 'text-generation' because that's what the LangChain client expects
|
| 58 |
llm_endpoint = HuggingFaceEndpoint(
|
| 59 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 60 |
+
task="text-generation", # Keep this as text-generation
|
| 61 |
max_new_tokens=512,
|
| 62 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 63 |
)
|
| 64 |
|
| 65 |
+
# 2. IMPORTANT: Manually set the model_id before wrapping
|
| 66 |
+
# This bypasses the automated router check that's causing your ValueError
|
| 67 |
+
llm_endpoint.model_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 68 |
+
|
| 69 |
+
# 3. Wrap in ChatHuggingFace
|
| 70 |
+
# This will now handle the chat formatting without the router rejecting the task
|
| 71 |
llm = ChatHuggingFace(llm=llm_endpoint)
|
| 72 |
|
| 73 |
# -------------------------
|