Merge pull request #9 from tools4ds/retargeting
Browse filesFiles changed (3)
276 unmodified lines277278279280281282106 unmodified lines389390391392393394395276 unmodified linesuser_details.metadata["tokens_left"] = (TOKENS_LEFT # set the number of tokens left for the new user)if "last_message_time" not in user_details.metadata:user_details.metadata["last_message_time"] = current_datetimeif "all_time_tokens_allocated" not in user_details.metadata:106 unmodified linesif __name__ == "__main__":parser = argparse.ArgumentParser(description="Run the AI Tutor application")parser.add_argument("--host", default="0.0.0.0", help="Host to run the server on")parser.add_argument("--port", type=int, default=7860, help="Port to run the server on")276 unmodified lines277278279280281282283284285286106 unmodified lines393394395396397398399276 unmodified linesuser_details.metadata["tokens_left"] = (TOKENS_LEFT # set the number of tokens left for the new user)if "role" not in user_details.metadata:user_details.metadata["role"] = get_user_role(user_info["email"])if "tokens_left" not in user_details.metadata:user_details.metadata["tokens_left"] = TOKENS_LEFTif "last_message_time" not in user_details.metadata:user_details.metadata["last_message_time"] = current_datetimeif "all_time_tokens_allocated" not in user_details.metadata:106 unmodified linesif __name__ == "__main__":parser = argparse.ArgumentParser(description="Run the AI Tutor application")parser.add_argument("--host", default="localhost", help="Host to run the server on")parser.add_argument("--port", type=int, default=7860, help="Port to run the server on")
226 unmodified lines227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264240 unmodified lines5055065075085095105119 unmodified lines521522523524525526527528529530226 unmodified lines"""Set starter messages for the chatbot."""# Return Starters only if the chat is newtry:thread = cl_data._data_layer.get_thread(cl.context.session.thread_id) # see if the thread has any stepsif thread.steps or len(thread.steps) > 0:return Noneexcept Exception as e:print(e)return [cl.Starter(label="What is this course about?",message="What is this course about? I'm not sure I'm in the right class.",icon="/public/assets/images/starter_icons/adv-screen-recorder-svgrepo-com.svg",),cl.Starter(label="Where is the schedule?",message="When are the lectures? I can't find the schedule.",icon="/public/assets/images/starter_icons/alarmy-svgrepo-com.svg",),cl.Starter(label="When are office hours?",message="When are the office hours for this course?",icon="/public/assets/images/starter_icons/calendar-samsung-17-svgrepo-com.svg",),cl.Starter(label="Explain KMeans",message="I didn't understand the math behind KMeans, could you explain it?",icon="/public/assets/images/starter_icons/acastusphoton-svgrepo-com.svg",),]def rename(self, orig_author: str):"""240 unmodified linesawait self.start()@cl.header_auth_callbackdef header_auth_callback(headers: dict) -> Optional[cl.User]:# try: # TODO: Add try-except block after testing# TODO: Implement to get the user information from the headers (not the cookie)cookie = headers.get("cookie") # gets back a str9 unmodified lines).decode()decoded_user_info = json.loads(decoded_user_info)return cl.User(id=decoded_user_info["literalai_info"]["id"],identifier=decoded_user_info["literalai_info"]["identifier"],metadata=decoded_user_info["literalai_info"]["metadata"],)async def on_follow_up(self, action: cl.Action):226 unmodified lines227228229230231232233234235236237238239240241242243244245246247248249250251252253254240 unmodified lines4954964974984995005019 unmodified lines511512513514515516517518519520521522523524226 unmodified lines"""Set starter messages for the chatbot."""return [cl.Starter(label="What is this course about?",message="What is this course about? I'm not sure I'm in the right class.",icon="/public/assets/images/starter_icons/adv-screen-recorder-svgrepo-com.svg",),cl.Starter(label="Where is the schedule?",message="When are the lectures? I can't find the schedule.",icon="/public/assets/images/starter_icons/alarmy-svgrepo-com.svg",),cl.Starter(label="When are office hours?",message="When are the office hours for this course?",icon="/public/assets/images/starter_icons/calendar-samsung-17-svgrepo-com.svg",),cl.Starter(label="Explain KMeans",message="I didn't understand the math behind KMeans, could you explain it?",icon="/public/assets/images/starter_icons/acastusphoton-svgrepo-com.svg",),]def rename(self, orig_author: str):"""240 unmodified linesawait self.start()@cl.header_auth_callbackasync def header_auth_callback(headers: dict) -> Optional[cl.User]:# try: # TODO: Add try-except block after testing# TODO: Implement to get the user information from the headers (not the cookie)cookie = headers.get("cookie") # gets back a str9 unmodified lines).decode()decoded_user_info = json.loads(decoded_user_info)user_id = decoded_user_info["literalai_info"]["identifier"]user_info = await get_user_details(user_id)metadata = user_info.metadatareturn cl.User(id=decoded_user_info["literalai_info"]["id"],identifier=decoded_user_info["literalai_info"]["identifier"],metadata=metadata,)async def on_follow_up(self, action: cl.Action):
147 unmodified lines148149150151152153154147 unmodified lines</div><script>let token = "{{ jwt_token }}";console.log("Token: ", token);localStorage.setItem("token", token);</script></body>147 unmodified lines148149150151152153147 unmodified lines</div><script>let token = "{{ jwt_token }}";localStorage.setItem("token", token);</script></body>
apps/ai_tutor/app.py+5-1
apps/ai_tutor/chainlit_app.py+28-34
apps/ai_tutor/templates/dashboard.html-1