abhi12ravi commited on
Commit
23bac42
1 Parent(s): a02907f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -1,9 +1,26 @@
1
  import gradio as gr
2
  import random
 
3
 
4
  def generate_response(input, history):
5
- #Hit the API and get results
6
- bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  return bot_message
9
 
 
1
  import gradio as gr
2
  import random
3
+ import requests
4
 
5
  def generate_response(input, history):
6
+ #bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
7
+
8
+ #Hit the Sagemaker API and get results
9
+
10
+ url = "https://runtime.sagemaker.eu-west-1.amazonaws.com/endpoints/jumpstart-dft-meta-textgeneration-llama-2-7b-f/invocations"
11
+ headers = {
12
+ "Content-Type": "application/json",
13
+ "Authorization": "Bearer <TOKEN>", # Replace with your actual token
14
+ }
15
+ payload = {"key": "value"}
16
+
17
+ response = requests.post(url, json=payload, headers=headers)
18
+
19
+ if response.status_code == 200:
20
+ print("Request was successful:", response.json())
21
+ else:
22
+ print("Request failed:", response.status_code, response.text)
23
+
24
 
25
  return bot_message
26