KalooAI commited on
Commit
9b8de6a
·
verified ·
1 Parent(s): 1609ba4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -60,18 +60,17 @@ client = InferenceClient(HF_MODEL_ID, token=os.getenv("HF_TOKEN"))
60
  import os
61
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
62
 
63
- # 1. Define the endpoint with text-generation task
64
- # This is the "engine" that talks to the Hugging Face servers
65
- http_llm = HuggingFaceEndpoint(
66
  repo_id="mistralai/Mistral-7B-Instruct-v0.3",
67
- task="text-generation",
68
  max_new_tokens=512,
69
  huggingfacehub_api_token=os.getenv("HF_TOKEN"),
70
  )
71
 
72
- # 2. Wrap it manually in ChatHuggingFace
73
- # We pass it as 'llm' to the constructor
74
- llm = ChatHuggingFace(llm=http_llm)
75
 
76
  # -------------------------
77
  # Document loader
 
60
  import os
61
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
62
 
63
+ # 1. Create the endpoint with the 'conversational' task
64
+ llm_endpoint = HuggingFaceEndpoint(
 
65
  repo_id="mistralai/Mistral-7B-Instruct-v0.3",
66
+ task="conversational", # Change this from 'text-generation'
67
  max_new_tokens=512,
68
  huggingfacehub_api_token=os.getenv("HF_TOKEN"),
69
  )
70
 
71
+ # 2. Wrap it in ChatHuggingFace
72
+ # This is REQUIRED for conversational tasks to work with RAG chains
73
+ llm = ChatHuggingFace(llm=llm_endpoint)
74
 
75
  # -------------------------
76
  # Document loader