Spaces:
Runtime error
Runtime error
Update app.py
Browse files1 unmodified line23456735 unmodified lines4344454647484950515253545530 unmodified lines86878889909192939495969714 unmodified lines1121131141151161171181 unmodified lineimport gradio as grimport osimport json# Set your API keypalm.configure(api_key=os.environ["PALM_KEY"])35 unmodified linesdef responsenew(data):print(data)data = data.lower()response = palm.chat( messages=data)print(response)if data is not None:# if "remind me" or "remind me to" in data:if "add coins" in data:respo = {"message": "Click the button below to view Premium Services and Coin Recharge options: ",30 unmodified lines"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",# }elif "notify" in data:respo = {"message": "Select your friends to notify",14 unmodified lines}else:respo = {"message": "I am currently experiencing server overload, sorry for inconvenience. Please try again with your query.","action": "nothing","function": "nothing",}1 unmodified line234567891035 unmodified lines46474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314430 unmodified lines17517617717817918018118218318418518614 unmodified lines2012022032042052062071 unmodified lineimport gradio as grimport osimport jsonfrom getvalues import getValuesfrom datetime import datetimeimport uuid# Set your API keypalm.configure(api_key=os.environ["PALM_KEY"])35 unmodified linesdef responsenew(data):idval = uuid.uuid4()print(data)data = data.lower()response = palm.chat( messages=data)print(response)if data is not None:if "remind me" or "remind me to" in data:values = getValues(data)if values[0] is not None:msg = values[0]else:msg = "Reminder Alert"if values[1] is not None:time = values[1]else:time1 = datetime.now()time2 = time1 + timedelta(hours=1)time = time2.strftime("%d-%m-%Y %H:%M:%S.%f")if values[2] is not None:day = values[2]else:day = "today"if values[3] is not None:date = values[3]else:date = datetime.today()if values[4] is not None:reps = values[4]else:reps = "Once"respo = {'messages': f"Your reminder for {msg} on {time} for {day} has been created successfully.",'action': "create_reminder",'function': {'id': idval,'sound': 'General','subTitle': 'Task','type': 'Note','title': msg,'description': '','time': time.upper(),'timestamp' : datetime.now().strftime("%d-%m-%Y %H:%M:%S.%f"),'enable': False,'report': [],'icon': 'https://firebasestorage.googleapis.com/v0/b/cosmo-f5007.appspot.com/o/categories%2FIcons%2Ftaskicon.svg?alt=media&token=56f3fc55-8eda-4463-bceb-7bf3198dff3c','color': 'FFD700','sharedToMe': [],'sharedByMe': [],'repeat': reps,'reminders': [{'time': time.upper(),'enable': False,'repeat': reps,'title': msg,'id': idval,'note': '','dates': [],}],}}if "add todo" or "add to do" in data:respo = {'messages': "Todo added!",'action': "create_todo",'function': {'name': 'defaulttodo','id': idval,'subTasks': [{'task':data.replace("add todo", "add to do"),'done': False}],'shared': [],'sharedByMe': [],},}if "note down" in data:respo = {'messages': "Got it!",'action': "create_note",'function': {'title': 'defaultnote','id': idval,'type': 'Note','description': data.replace("note down"),'time': datetime.now().strftime("%d/%m/%Y"),'mainTime': datetime.now().strftime("%I:%M %p"),'complete': False,'shared': [],'sharedByMe': [],}}if "add coins" in data:respo = {"message": "Click the button below to view Premium Services and Coin Recharge options: ",30 unmodified lines"action": "myroutines","function": "nothing",}elif "what is your name" or "what's your name" or "who are you" in data:respo = {"message": "My name is Cosmo. I am your friendly personal assistant.","action": "nothing","function": "nothing",}elif "notify" in data:respo = {"message": "Select your friends to notify",14 unmodified lines}else:respo = {"message": "Whoops, seems like we're a bit overloaded! Don't worry, your request is in the queue and we'll get back to you as soon as possible.","action": "nothing","function": "nothing",}
app.py+97-8