CosmoAI commited on
Commit
84ab7d1
·
1 Parent(s): 1ab74ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -28
app.py CHANGED
@@ -3,37 +3,16 @@ import requests
3
  import time
4
  import os
5
  import json
6
- from bardapi import Bard
7
 
8
- bardKey = os.environ.get('_BARD_API_KEY')
 
 
 
 
9
 
10
 
11
  def bardChat(data):
12
- # Create a session object using the requests library
13
- session = requests.Session()
14
-
15
- # Set the headers for the session
16
- session.headers = {
17
- "Host": "bard.google.com",
18
- "X-Same-Domain": "1",
19
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
20
- "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
21
- "Origin": "https://bard.google.com",
22
- "Referer": "https://bard.google.com/",
23
- }
24
-
25
- # Set the "__Secure-1PSID" cookie with the Bard API key
26
- session.cookies.set("__Secure-1PSID", bardKey)
27
-
28
- # Create a Bard object with the session and a timeout of 30 seconds
29
- bard = Bard(session=session, timeout=30)
30
- answer = bard.get_answer(data)['content']
31
- respo = {
32
- "message": answer,
33
- "action": "nothing",
34
- "function": "nothing"
35
- }
36
- # print(answer)
37
  return json.dumps(respo)
38
 
39
  def responsenew(data):
@@ -47,7 +26,18 @@ gradio_interface = gr.Interface(
47
  outputs = "text"
48
  )
49
  gradio_interface.launch()
50
-
 
 
 
 
 
 
 
 
 
 
 
51
  # remind_val = ["create a reminder", "create reminder", "remind me"]
52
  # if remind_val in data:
53
  # return "Reminder created!"
 
3
  import time
4
  import os
5
  import json
 
6
 
7
+ genai.configure(
8
+ api_key=os.environ['API_KEY'])
9
+ model = genai.GenerativeModel(
10
+ model_name='gemini-pro')
11
+
12
 
13
 
14
  def bardChat(data):
15
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  return json.dumps(respo)
17
 
18
  def responsenew(data):
 
26
  outputs = "text"
27
  )
28
  gradio_interface.launch()
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
  # remind_val = ["create a reminder", "create reminder", "remind me"]
42
  # if remind_val in data:
43
  # return "Reminder created!"