Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,12 +53,6 @@ client = InferenceClient(HF_MODEL_ID, token=os.getenv("HF_TOKEN"))
|
|
| 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 |
-
# Use the dedicated Chat constructor
|
| 59 |
-
# This handles the model_id and the conversational task mapping automatically
|
| 60 |
-
import os
|
| 61 |
-
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 62 |
|
| 63 |
# 1. Use a model that has high availability in the 2026 Provider network
|
| 64 |
# Llama-3.1-8B-Instruct is currently a 'gold standard' for this router
|
|
@@ -68,16 +62,19 @@ repo_id = "Qwen/Qwen2.5-7B-Instruct"
|
|
| 68 |
# repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 69 |
# repo_id = "HuggingFaceTB/SmolLM2-1.7B-Instruct"
|
| 70 |
# repo_id = "microsoft/Phi-3.5-mini-instruct"
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
llm = ChatHuggingFace(
|
| 76 |
-
model=repo_id,
|
| 77 |
max_new_tokens=512,
|
| 78 |
temperature=0.1,
|
| 79 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
|
|
|
|
|
|
| 80 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
# 2. ChatHuggingFace will correctly route this to the /v1/chat/completions
|
| 82 |
# endpoint which the Llama-3.1-8B-Instruct model supports.
|
| 83 |
# llm = ChatHuggingFace(llm=llm_endpoint)
|
|
|
|
| 53 |
# wait_for_model=True
|
| 54 |
# )
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# 1. Use a model that has high availability in the 2026 Provider network
|
| 58 |
# Llama-3.1-8B-Instruct is currently a 'gold standard' for this router
|
|
|
|
| 62 |
# repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 63 |
# repo_id = "HuggingFaceTB/SmolLM2-1.7B-Instruct"
|
| 64 |
# repo_id = "microsoft/Phi-3.5-mini-instruct"
|
| 65 |
+
llm_endpoint = HuggingFaceEndpoint(
|
| 66 |
+
repo_id=repo_id,
|
| 67 |
+
task="text-generation",
|
|
|
|
|
|
|
|
|
|
| 68 |
max_new_tokens=512,
|
| 69 |
temperature=0.1,
|
| 70 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 71 |
+
provider="hf-inference",
|
| 72 |
+
model_kwargs={"wait_for_model": True},
|
| 73 |
)
|
| 74 |
+
|
| 75 |
+
llm = ChatHuggingFace(llm=llm_endpoint)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
# 2. ChatHuggingFace will correctly route this to the /v1/chat/completions
|
| 79 |
# endpoint which the Llama-3.1-8B-Instruct model supports.
|
| 80 |
# llm = ChatHuggingFace(llm=llm_endpoint)
|