Spaces:
Running
Running
File size: 6,305 Bytes
e460bb5 c1548d4 b396381 c1548d4 71ad11e e460bb5 b396381 71ad11e e460bb5 a91e5a1 71ad11e 83e0b34 c1548d4 7747bcb e646f95 b396381 a07fe07 b396381 a07fe07 b396381 47c93b4 5c96829 24f170e b396381 5c96829 b396381 c1548d4 4238098 b396381 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
import google.generativeai as palm
import gradio as gr
import os
import json
# Set your API key
palm.configure(api_key=os.environ["PALM_KEY"])
# Select the PaLM 2 model
# model = 'models/text-bison-001'
def responsenew(data):
print(data)
response = palm.chat(messages=data)
intent = palm.chat(
messages=f"""Act as a friendly personal assistant who's name is Cosmo. ".
You help users manage their daily tasks by providing them with a variety of features.
Below are the list of features you have: \n
- You can create goals\n
- You can share goals with friends\n
- You can create reminders\n
- You can create routines\n
- You can share reminders with users friends\n
- You can share routines with users friends\n
- You can create todo lists\n
- You can share todo lists with users friends\n
- You can create groups\n
- You can share groups with users friends\n
- You can create communities\n
- You can create notes for user\n
- You can share notes with users friends\n
- You can publish posts on timeline\n
- You can invite friends to this(CosmoAI) app\n
- You can help users purchase coins\n
- You can view your friends\n
- You can view your groups\n
- You can view your communities\n
- You can view your shared reminders\n
- You can view your shared routines\n
- You can view your todo lists\n
- You can view your shared todo lists\n
- You can view your shared notes\n
- You can start a timer or a stopwatch\n
Identify the user's intent from the given text data.\n
Args:\n
text_data: {data}.\n\n
Return the intent as one-word string representing the user's intent, one of:
* if intent = purchasing coins return = "purchase_coins"
* if intent = viewing friends return = "view_friends"
* if intent = viewing groups joined return = "view_groups"
* if intent = viewing communities joined return = "view_communities"
* if intent = viewing shared reminders return = "shared_reminders"
* if intent = viewing user's routines return = "my_routines"
* if intent = viewing all the groups existing on CosmoAI return = "view_all_groups"
* if intent = viewing all the communities existing on CosmoAI return = "view_all_communities"
* if intent = viewing user's notes return = "view_notes"
* if intent = viewing user's posts return = "view_posts"
* if intent = viewing user's shared notes return = "view_shared_notes"
* if intent = viewing user's todo lists return = "view_todo_lists"
* if intent = viewing user's shared todo lists return = "view_shared_todo_lists"
* if intent = viewing user's shared routines return = "view_shared_routines"
* if intent = creating a goal return = "create_goal"
* if intent = creating a reminder return = "create_reminder"
* if intent = creating a routine return = "create_routine"
* if intent = creating a group return = "create_group"
* if intent = creating a community return = "create_community"
* if intent = creating a note return = "create_note"
* if intent = creating a post return = "create_post"
* if intent = creating a todo list return = "create_todo_list"
* if intent = sharing a reminder return = "share_reminder"
* if intent = sharing a routine return = "share_routine"
* if intent = sharing a group return = "share_group"
* if intent = sharing a todo list return = "share_todo_list"
* if intent = sharing a note return = "share_note"
* if intent = knowing your name or who you are or what is your name return = "cosmo_name"
"""
)
print(intent)
# respo = {
# "message": intent.last,
# "action": "nothing",
# "function": "nothing"
# }
if intent.last is not None:
if "purchase_coins" in intent.last:
respo = {
"message": "Click the button below to view Premium Services and Coin Recharge options: ",
"action": "payment",
"function": "nothing",
}
elif "view_friends" in intent.last:
respo = {
"message": "Here's the list of your friends: ",
"action": "show_friends",
"function": "nothing",
}
elif "view_groups" in intent.last:
respo = {
"message": "You are member of following groups: ",
"action": "show_mygroups",
"function": "nothing",
}
elif "view_communities" in intent.last:
respo = {
"message": "You are part of following communities🫶: ",
"action": "show_mycommunities",
"function": "nothing",
}
elif "shared_reminders" in intent.last:
respo = {
"message": "Here's the list of your shared reminders: ",
"action": "shared_reminders",
"function": "nothing",
}
elif "my_routines" in intent.last:
respo = {
"message": "Here's the list of your routines: ",
"action": "myroutines",
"function": "nothing",
}
elif "cosmo_name" in intent.last:
respo = {
"message": "My name is Cosmo. I am your friendly personal assistant.",
"action": "nothing",
"function": "nothing",
}
else:
respo = {"message": response.last, "action": "nothing", "function": "nothing"}
else:
respo = {"message": "Unable to understand.", "action": "nothing", "function": "nothing"}
return json.dumps(respo)
gradio_interface = gr.Interface(fn=responsenew, inputs="text", outputs="text")
gradio_interface.launch()
|