KalooAI commited on
Commit
33a210e
·
verified ·
1 Parent(s): a2cf604

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
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. First, define the base endpoint (keep task as text-generation here)
 
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. Wrap it in ChatHuggingFace to fix the task mismatch
65
- # This automatically handles the "conversational" formatting for you
 
 
 
 
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
  # -------------------------