KalooAI commited on
Commit
a9aede8
·
verified ·
1 Parent(s): 0373023

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -18,23 +18,27 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
18
  # -------------------------
19
 
20
  # You can change this to any instruct model you like
21
- HF_MODEL_ID = "mistralai/Mistral-7B-Instruct-v0.2"
 
 
 
22
 
23
  # If you use a private token, set it as HF_TOKEN env var in Spaces
24
  client = InferenceClient(HF_MODEL_ID, token=os.getenv("HF_TOKEN"))
25
 
26
 
27
  def get_llm():
28
- """Simple callable LLM wrapper compatible with LangChain's RetrievalQA."""
29
 
30
  def _llm(prompt: str) -> str:
 
31
  response = client.text_generation(
32
  prompt,
33
- max_new_tokens=256,
34
- temperature=0.5,
 
35
  )
36
  return response
37
-
38
  return _llm
39
 
40
 
 
18
  # -------------------------
19
 
20
  # You can change this to any instruct model you like
21
+ HF_MODEL_ID = "ibm-granite/granite-3.1-8b-instruct"
22
+
23
+ # Option B: Llama 3.3 (Current industry standard)
24
+ # HF_MODEL_ID = "meta-llama/Llama-3.3-70B-Instruct"
25
 
26
  # If you use a private token, set it as HF_TOKEN env var in Spaces
27
  client = InferenceClient(HF_MODEL_ID, token=os.getenv("HF_TOKEN"))
28
 
29
 
30
  def get_llm():
31
+ token = os.getenv("HF_TOKEN")
32
 
33
  def _llm(prompt: str) -> str:
34
+ # We add wait_for_model to wake up the API if it's sleeping
35
  response = client.text_generation(
36
  prompt,
37
+ max_new_tokens=512,
38
+ temperature=0.1,
39
+ wait_for_model=True
40
  )
41
  return response
 
42
  return _llm
43
 
44