Kalyani8 commited on
Commit
eaad362
·
verified ·
1 Parent(s): 919e0ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -14,17 +14,19 @@ hf_token = os.getenv("HF_Token")
14
 
15
  if not hf_token:
16
  raise ValueError("HF_Token is not set. Please check your Hugging Face Secrets.")
 
17
 
18
- # Load LLaMA-2 model with authentication
19
- llama_pipe = pipeline(
20
- "text-generation",
21
- model="TheBloke/Llama-2-7B-Chat-GGUF",
22
- token=hf_token # Pass the token explicitly
23
- )
 
24
 
25
- # Test LLaMA-2 inference
26
- output = llama_pipe("What is machine learning?", max_length=100)
27
- print(output)
28
 
29
 
30
  '''
 
14
 
15
  if not hf_token:
16
  raise ValueError("HF_Token is not set. Please check your Hugging Face Secrets.")
17
+ import requests
18
 
19
+ API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-2-7b-chat-hf"
20
+ headers = {"Authorization": f"Bearer hf_token"}
21
+
22
+ def query_llama(prompt):
23
+ payload = {"inputs": prompt}
24
+ response = requests.post(API_URL, headers=headers, json=payload)
25
+ return response.json()
26
 
27
+ prompt = "Explain machine learning in simple terms."
28
+ response = query_llama(prompt)
29
+ print(response)
30
 
31
 
32
  '''