runebloodstone commited on
Commit
fa3a819
·
verified ·
1 Parent(s): 105ef27

Update app.py

Browse files

Revamp with proper code

Files changed (1) hide show
  1. app.py +19 -38
app.py CHANGED
@@ -1,18 +1,9 @@
1
- #import gradio as gr
2
  import requests
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
- ##lient = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
-
9
- # Base URL
10
-
11
  # Define our API endpoint and authentication token
12
- API_URL = "https://api.kindroid.ai/v1"
13
- SEND_MESSAGE_URL = "https://api.kindroid.ai/v1/send-message"
14
  AUTH_TOKEN = "kn_df28dc59-57ec-442d-8983-b3f7ccdcb4b5"
15
- JESS_ID = "jesskinid"
16
 
17
  # Prepare the headers for our request
18
  # The Authorization header uses the Bearer authentication scheme
@@ -30,31 +21,21 @@ payload = {
30
  "ai_id": Isabel,
31
  "message": "Oh god izz that feels good. keep going."
32
  }
33
- def main():
34
- try:
35
- # Make the POST request to the API
36
- # We pass our payload as json parameter so requests will automatically
37
- # handle the JSON serialization for us
38
- response = requests.post(API_URL, headers=headers, json=payload)
39
-
40
- # Check if the request was successful (status code 200-299)
41
- response.raise_for_status()
42
-
43
- # Print the response from the server
44
- # The .json() method automatically parses the JSON response
45
- print("Response received:")
46
- print(response.json())
47
-
48
- except requests.exceptions.RequestException as e:
49
- # Handle any errors that might occur during the request
50
- print(f"An error occurred: {e}")
51
-
52
 
53
-
54
-
55
- """
56
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
57
- """
58
-
59
- if __name__ == "__main__":
60
- main()
 
 
 
 
 
 
 
 
 
 
1
+ # Import the requests library - this is the standard library for making HTTP requests in Python
2
  import requests
3
 
 
 
 
 
 
 
 
4
  # Define our API endpoint and authentication token
5
+ API_URL = "https://api.kindroid.ai/v1/send-message"
 
6
  AUTH_TOKEN = "kn_df28dc59-57ec-442d-8983-b3f7ccdcb4b5"
 
7
 
8
  # Prepare the headers for our request
9
  # The Authorization header uses the Bearer authentication scheme
 
21
  "ai_id": Isabel,
22
  "message": "Oh god izz that feels good. keep going."
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
+ try:
26
+ # Make the POST request to the API
27
+ # We pass our payload as json parameter so requests will automatically
28
+ # handle the JSON serialization for us
29
+ response = requests.post(API_URL, headers=headers, json=payload)
30
+
31
+ # Check if the request was successful (status code 200-299)
32
+ response.raise_for_status()
33
+
34
+ # Print the response from the server
35
+ # The .json() method automatically parses the JSON response
36
+ print("Response received:")
37
+ print(response.content)
38
+
39
+ except requests.exceptions.RequestException as e:
40
+ # Handle any errors that might occur during the request
41
+ print(f"An error occurred: {e}")