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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
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
- 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
 
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