addcorpbc commited on
Commit ·
fefaa5a
1
Parent(s): e1b5d77
Add AI-Powered Magic City Career Counselor with dynamic welcome message
Browse files12345625 unmodified lines3233343536373839404142434445464748495051525354555657585960616263646566from transformers import AutoTokenizer, AutoModelForCausalLMimport gradio as grimport os# Authenticate using a token from environment variableshf_token = os.getenv("HFTOKEN")25 unmodified linesoutputs = model.generate(**inputs, max_new_tokens=200)return tokenizer.decode(outputs[0], skip_special_tokens=True)# Add Markdown for welcome messagewelcome_message = """# AI-Powered Magic City Career CounselorHi, I'm your Magic City Career Counselor! Big Magic made me to help you plan for your future.He cares about his employees and wants to make sure you have a future after Magic City.To do that, we've consulted dozens of experts to help you decide on the direction you may want to take in the future.We offer five different assessments you can take, or we can simply chat about your plans. The assessments include:1. The Myers-Briggs Type Indicator2. The Indecisiveness Scale3. RIASEC4. The Career Thought Inventory5. The Career Values Card SortIf you'd like to know more about what these assessments cover, just ask! Then, we can decide on which one(s) to take to better understand what might suit you."""# Define the Gradio interfaceinterface = gr.Blocks()with interface:gr.Markdown(welcome_message) # Display the welcome message explicitlygr.Interface(fn=recommend,inputs=gr.Textbox(label="Describe your career interests and goals"),outputs="text",title="AI-Powered Magic City Career Counselor", # Title updatedescription="Provide a description of your career goals, and get personalized career suggestions!" # Description update)# Launch the Gradio appinterface.launch()123456725 unmodified lines33343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293from transformers import AutoTokenizer, AutoModelForCausalLMimport gradio as grimport osimport time# Authenticate using a token from environment variableshf_token = os.getenv("HFTOKEN")25 unmodified linesoutputs = model.generate(**inputs, max_new_tokens=200)return tokenizer.decode(outputs[0], skip_special_tokens=True)def welcome_message():"""Simulate typing out the welcome message in the output box."""message = """Hi, I'm your Magic City Career Counselor! Big Magic made me to help you plan for your future.He cares about his employees and wants to make sure you have a future after Magic City.To do that, we've consulted dozens of experts to help you decide on the direction you may want to take in the future.We offer five different assessments you can take, or we can simply chat about your plans. The assessments include:1. The Myers-Briggs Type Indicator2. The Indecisiveness Scale3. RIASEC4. The Career Thought Inventory5. The Career Values Card Sort"""words = message.split(" ")output = ""for word in words:output += word + " "yield output # Output progressivelytime.sleep(0.1) # Typing delay between words# Define the Gradio interface with cobalt-themed designinterface = gr.Blocks()with interface:gr.Markdown("""# AI-Powered Magic City Career CounselorHi, I'm your Magic City Career Counselor! Big Magic made me to help you plan for your future.He cares about his employees and wants to make sure you have a future after Magic City.To do that, we've consulted dozens of experts to help you decide on the direction you may want to take in the future.We offer five different assessments you can take, or we can simply chat about your plans. The assessments include:1. The Myers-Briggs Type Indicator2. The Indecisiveness Scale3. RIASEC4. The Career Thought Inventory5. The Career Values Card SortIf you'd like to know more about what these assessments cover, just ask! Then, we can decide on which one(s) to take to better understand what might suit you.""")# Welcome message that types out in the output fieldgr.Interface(fn=welcome_message,inputs=None,outputs=gr.Textbox(label="Welcome Message", interactive=False, elem_id="welcome-box"), # Output in the same boxtitle="Welcome to the Magic City Career Counselor",description="Let’s start by exploring your career interests! You will see a welcome message typing out in the box below.")# Career recommendation input/outputgr.Interface(fn=recommend,inputs=gr.Textbox(label="Describe your career interests and goals", lines=2, elem_id="input-box"),outputs=gr.Textbox(label="Career Recommendations", lines=4, elem_id="output-box"),title="AI-Powered Magic City Career Counselor", # Updated titledescription="Provide a description of your career goals, and get personalized career suggestions!" # Description update)# Set the theme color to cobalt for the Gradio UIinterface.launch(share=True, theme="cobalt") # `cobalt` theme for styling
app.py+50-23