Nikhil0987 commited on
Commit
80062ad
1 Parent(s): 317a04b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -154
app.py CHANGED
@@ -8,17 +8,6 @@ from datetime import datetime, timedelta
8
  import uuid
9
  import re
10
 
11
- # Set your API key
12
- # Or use `os.getenv('GOOGLE_API_KEY')` to fetch an environment variable.
13
- # GOOGLE_API_KEY=os.getenv('GEMINI_KEY')
14
-
15
- # genai.configure(api_key=GOOGLE_API_KEY)
16
- # model = genai.GenerativeModel('gemini-pro')
17
-
18
- # Select the PaLM 2 model
19
- # model = 'models/text-bison-001'
20
-
21
-
22
  api1 = os.getenv("Groq_key")
23
  api2 = os.getenv("GRoq_key")
24
 
@@ -27,39 +16,6 @@ apis = [
27
  api2,
28
  ]
29
 
30
-
31
- # contx = """Act as a friendly personal assistant.
32
- # You help users manage their daily tasks by providing them with a variety of features.
33
- # Below are the list of features you have: \n
34
- # - You can create goals\n
35
- # - You can share goals with friends\n
36
- # - You can create reminders\n
37
- # - You can create routines\n
38
- # - You can share reminders with users friends\n
39
- # - You can share routines with users friends\n
40
- # - You can create todo lists\n
41
- # - You can share todo lists with users friends\n
42
- # - You can create groups\n
43
- # - You can share groups with users friends\n
44
- # - You can create communities\n
45
- # - You can create notes for user\n
46
- # - You can share notes with users friends\n
47
- # - You can publish posts on timeline\n
48
- # - You can invite friends to this(CosmoAI) app\n
49
- # - You can help users purchase coins\n
50
- # - You can view your friends\n
51
- # - You can view your groups\n
52
- # - You can view your communities\n
53
- # - You can view your shared reminders\n
54
- # - You can view your shared routines\n
55
- # - You can view your todo lists\n
56
- # - You can view your shared todo lists\n
57
- # - You can view your shared notes\n
58
- # - You can start a timer or a stopwatch\n\n"""
59
-
60
-
61
-
62
-
63
  def responsenew(data):
64
  idval = random.randint(1, 1000000000)
65
  print(f"\n\n{data}")
@@ -67,20 +23,14 @@ def responsenew(data):
67
  items = json.loads(newdata)
68
  query = items['text']
69
  query = query.lower()
70
- # try:
71
- # items = json.loads(newdata)
72
- # query = items['text']
73
- # query = query.lower()
74
- # print(query)
75
- # except json.JSONDecodeError as e:
76
- # print("Invalid JSON:", e)
77
  while True:
78
  for api in apis:
79
  client = Groq(
80
  api_key=api,
81
  ) # Configure the model with the API key
82
- # query = st.text_input("Enter your query")
83
- # prmptquery= f"Answer this query with wisdom, love and compassion, in context to bhagwat geeta, provide references of shloks from chapters of bhagwat geeta which is relevant to the query. Query= {query}"
84
  try:
85
  response = client.chat.completions.create(
86
  messages=[
@@ -283,108 +233,7 @@ def responsenew(data):
283
  }
284
  return json.dumps(respo)
285
 
286
- # intent = palm.chat(
287
- # messages=f"""
288
-
289
- # Identify the user's intent from text_data below:\n
290
- # Arguments: text_data = {data}\n\n
291
- # Return the intent as one-word string representing the user's intent, as mentioned below:
292
- # * if intent = viewing user's routine return = "my_routines"
293
- # * if intent = viewing user's notes return = "view_notes"
294
- # * if intent = viewing user's posts return = "view_posts"
295
- # * if intent = viewing user's shared notes return = "view_shared_notes"
296
- # * if intent = viewing user's todo lists return = "view_todo_lists"
297
- # * if intent = viewing user's shared todo lists return = "view_shared_todo_lists"
298
- # * if intent = viewing user's shared routines return = "view_shared_routines"
299
- # * if intent = creating a goal return = "create_goal"
300
- # * if intent = creating a reminder return = "create_reminder"
301
- # * if intent = creating a routine return = "create_routine"
302
- # * if intent = creating a group return = "create_group"
303
- # * if intent = creating a community return = "create_community"
304
- # * if intent = creating a note return = "create_note"
305
- # * if intent = creating a post return = "create_post"
306
- # * if intent = creating a todo list return = "create_todo_list"
307
- # * if intent = sharing a reminder return = "share_reminder"
308
- # * if intent = sharing a routine return = "share_routine"
309
- # * if intent = sharing a group return = "share_group"
310
- # * if intent = sharing a todo list return = "share_todo_list"
311
- # * if intent = sharing a note return = "share_note"
312
- # * if intent = notify then return = "send_notify"
313
- # * if intent = show actions then return = "show_actions"
314
-
315
- # """,
316
- # )
317
 
318
- # respo = {"message": intent.last, "action": "nothing", "function": "nothing"}
319
- # if intent.last is not None:
320
- # if "purchase_coins" in intent.last:
321
- # respo = {
322
- # "message": "Click the button below to view Premium Services and Coin Recharge options: ",
323
- # "action": "payment",
324
- # "function": "nothing",
325
- # }
326
- # elif "view_friends" in intent.last:
327
- # respo = {
328
- # "message": "Here's the list of your friends: ",
329
- # "action": "show_friends",
330
- # "function": "nothing",
331
- # }
332
- # elif "view_groups" in intent.last:
333
- # respo = {
334
- # "message": "You are member of following groups: ",
335
- # "action": "show_mygroups",
336
- # "function": "nothing",
337
- # }
338
- # elif "view_communities" in intent.last:
339
- # respo = {
340
- # "message": "You are part of following communities🫶: ",
341
- # "action": "show_mycommunities",
342
- # "function": "nothing",
343
- # }
344
- # elif "shared_reminders" in intent.last:
345
- # respo = {
346
- # "message": "Here's the list of your shared reminders: ",
347
- # "action": "shared_reminders",
348
- # "function": "nothing",
349
- # }
350
- # elif "my_routines" in intent.last:
351
- # respo = {
352
- # "message": "Here's the list of your routines: ",
353
- # "action": "myroutines",
354
- # "function": "nothing",
355
- # }
356
- # # elif "cosmo_name" in intent.last:
357
- # # respo = {
358
- # # "message": "My name is Cosmo. I am your friendly personal assistant.",
359
- # # "action": "nothing",
360
- # # "function": "nothing",
361
- # # }
362
- # elif "send_notify" in intent.last:
363
- # respo = {
364
- # "message": "Select your friends to notify",
365
- # "action": "send_notify",
366
- # "function": "nothing",
367
- # }
368
- # elif "show_actions" in intent.last:
369
- # respo = {
370
- # "message": "Here is list of actions you can use:",
371
- # "action": "show_actions",
372
- # "function": "nothing",
373
- # }
374
- # else:
375
- # respo = {
376
- # "message": response.last,
377
- # "action": "nothing",
378
- # "function": "nothing",
379
- # }
380
- # else:
381
- # respo = {
382
- # "message": response.last,
383
- # "action": "nothing",
384
- # "function": "nothing",
385
- # }
386
- # return json.dumps(respo)
387
-
388
 
389
  gradio_interface = gr.Interface(fn=responsenew, inputs="text", outputs="text")
390
  gradio_interface.launch()
 
8
  import uuid
9
  import re
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  api1 = os.getenv("Groq_key")
12
  api2 = os.getenv("GRoq_key")
13
 
 
16
  api2,
17
  ]
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def responsenew(data):
20
  idval = random.randint(1, 1000000000)
21
  print(f"\n\n{data}")
 
23
  items = json.loads(newdata)
24
  query = items['text']
25
  query = query.lower()
26
+
27
+
 
 
 
 
 
28
  while True:
29
  for api in apis:
30
  client = Groq(
31
  api_key=api,
32
  ) # Configure the model with the API key
33
+
 
34
  try:
35
  response = client.chat.completions.create(
36
  messages=[
 
233
  }
234
  return json.dumps(respo)
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
  gradio_interface = gr.Interface(fn=responsenew, inputs="text", outputs="text")
239
  gradio_interface.launch()