PD03 commited on
Commit
a3f5ecf
·
verified ·
1 Parent(s): fdcaff6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -1,17 +1,11 @@
1
- import gradio as gr
2
  import requests
3
  import os
4
 
5
- HF_API_TOKEN = os.getenv("HF_API_TOKEN")
6
  API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
7
  headers = {"Authorization": f"Bearer {HF_API_TOKEN}"}
8
 
9
- def call_llama3(prompt):
10
- response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
11
- if response.status_code == 200:
12
- return response.json()[0]['generated_text']
13
- else:
14
- return f"Error: {response.status_code} - {response.text}"
15
 
16
- demo = gr.Interface(call_llama3, "text", "text")
17
- demo.launch()
 
 
1
  import requests
2
  import os
3
 
4
+ HF_API_TOKEN = os.getenv("HF_API_TOKEN") # or paste explicitly for quick test
5
  API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
6
  headers = {"Authorization": f"Bearer {HF_API_TOKEN}"}
7
 
8
+ response = requests.post(API_URL, headers=headers, json={"inputs": "Test LLaMA-3 endpoint."})
 
 
 
 
 
9
 
10
+ print("Status code:", response.status_code)
11
+ print("Response:", response.text)