antony-pk commited on
Commit
01bbd4b
1 Parent(s): bb609ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -1,10 +1,29 @@
1
  import os
 
2
  import gradio as gr
3
 
4
  # Your Hugging Face API token
5
  hf_token = os.getenv("hf_token")
 
6
 
7
- # Load the model with the token
8
- interface = gr.Interface.load("huggingface/antony-pk/llama-3-8b-Instruct-bnb-4bit-e10-emp-gold-jul16",
9
- api_key=hf_token)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  interface.launch()
 
1
  import os
2
+ import requests
3
  import gradio as gr
4
 
5
  # Your Hugging Face API token
6
  hf_token = os.getenv("hf_token")
7
+ api_url = "https://api-inference.huggingface.co/models/antony-pk/llama-3-8b-Instruct-bnb-4bit-e10-emp-gold-jul16"
8
 
9
+ def query_huggingface_api(prompt):
10
+ headers = {"Authorization": f"Bearer {hf_token}"}
11
+ payload = {"inputs": prompt}
12
+ response = requests.post(api_url, headers=headers, json=payload)
13
+ return response.json()
14
+
15
+ def generate_response(prompt):
16
+ response = query_huggingface_api(prompt)
17
+ return response.get("generated_text", "No response received")
18
+
19
+ # Create the Gradio interface
20
+ interface = gr.Interface(
21
+ fn=generate_response,
22
+ inputs="text",
23
+ outputs="text",
24
+ title="LLama Model Interaction",
25
+ description="Enter a prompt to receive a response from the private LLama model."
26
+ )
27
+
28
+ # Launch the Gradio interface
29
  interface.launch()