Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,11 +55,17 @@ client = InferenceClient(HF_MODEL_ID, token=os.getenv("HF_TOKEN"))
|
|
| 55 |
|
| 56 |
# 1. Configure the endpoint
|
| 57 |
# We use 'text-generation' because that's what the LangChain client expects
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
)
|
| 64 |
|
| 65 |
# 2. IMPORTANT: Manually set the model_id before wrapping
|
|
|
|
| 55 |
|
| 56 |
# 1. Configure the endpoint
|
| 57 |
# We use 'text-generation' because that's what the LangChain client expects
|
| 58 |
+
# Use the dedicated Chat constructor
|
| 59 |
+
# This handles the model_id and the conversational task mapping automatically
|
| 60 |
+
llm = ChatHuggingFace.from_model_id(
|
| 61 |
+
model_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 62 |
+
model_kwargs={
|
| 63 |
+
"max_new_tokens": 512,
|
| 64 |
+
"huggingfacehub_api_token": os.getenv("HF_TOKEN"),
|
| 65 |
+
},
|
| 66 |
+
# This tells the server we are sending a Chat request
|
| 67 |
+
# but the local wrapper knows it's an "Instruct" model.
|
| 68 |
+
task="text-generation",
|
| 69 |
)
|
| 70 |
|
| 71 |
# 2. IMPORTANT: Manually set the model_id before wrapping
|