mvcrockett commited on
Commit
257fbd4
·
verified ·
1 Parent(s): 0bb6457

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import requests
3
 
 
4
  def talk_to_llama(prompt):
5
  url = "https://api.nvcf.nvidia.com/v2/completions"
6
  headers = {
@@ -11,8 +12,18 @@ def talk_to_llama(prompt):
11
  "messages": [{"role": "user", "content": prompt}]
12
  }
13
  response = requests.post(url, headers=headers, json=data)
14
- return response.json()["choices"][0]["message"]["content"]
 
 
 
15
 
16
- chat = gr.Interface(fn=talk_to_llama, inputs="text", outputs="text", title="Chat with LLaMA 4 Scout")
 
 
 
 
 
 
 
17
 
18
  chat.launch()
 
1
  import gradio as gr
2
  import requests
3
 
4
+ # Function to send your prompt to NVIDIA LLaMA 4 Scout
5
  def talk_to_llama(prompt):
6
  url = "https://api.nvcf.nvidia.com/v2/completions"
7
  headers = {
 
12
  "messages": [{"role": "user", "content": prompt}]
13
  }
14
  response = requests.post(url, headers=headers, json=data)
15
+ try:
16
+ return response.json()["choices"][0]["message"]["content"]
17
+ except:
18
+ return "Something went wrong. Here's what the server said: " + str(response.text)
19
 
20
+ # Build the chatbot interface
21
+ chat = gr.Interface(
22
+ fn=talk_to_llama,
23
+ inputs="text",
24
+ outputs="text",
25
+ title="Chat with LLaMA 4 Scout",
26
+ description="Ask anything! This chatbot uses NVIDIA’s 3.5M token LLaMA 4 Scout model."
27
+ )
28
 
29
  chat.launch()