Madiharehan commited on
Commit
a859006
1 Parent(s): b92c20b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +97 -0
app.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoTokenizer, pipeline
3
+ from peft import PeftModel, PeftConfig
4
+ from transformers import AutoModelForSeq2SeqLM
5
+ from datasets import load_dataset
6
+ import torch
7
+
8
+ st.write("Initializing...") # Debugging message
9
+
10
+ # Load the LoRA configuration and model
11
+ config = PeftConfig.from_pretrained("lorahub/flan_t5_large-web_questions_potential_correct_answer")
12
+ base_model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-large")
13
+ model = PeftModel.from_pretrained(base_model, "lorahub/flan_t5_large-web_questions_potential_correct_answer")
14
+ tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-large")
15
+
16
+ st.write("Model Loaded Successfully!") # Debugging message
17
+
18
+ qa_pipeline = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
19
+
20
+ # Load relevant datasets
21
+ hotpotqa_dataset = load_dataset("bdsaglam/hotpotqa-distractor")
22
+ squad_v2_dataset = load_dataset("tom-010/squad_v2_with_answerable")
23
+ bias_professions_dataset = load_dataset("society-ethics/stable-bias-professions")
24
+ classifier_dataset = load_dataset("habanoz/classifier_1300_610_url_p")
25
+
26
+ st.write("Datasets Loaded Successfully!") # Debugging message
27
+
28
+ # Streamlit App Structure
29
+ def main():
30
+ st.title("AI-Powered Career Counseling App with Advanced Q&A")
31
+ st.sidebar.title("Navigation")
32
+ option = st.sidebar.selectbox("Choose an Option", ["Profile Setup", "Career Q&A", "Career Recommendations", "Resource Library"])
33
+
34
+ if option == "Profile Setup":
35
+ profile_setup()
36
+ elif option == "Career Q&A":
37
+ career_qa()
38
+ elif option == "Career Recommendations":
39
+ career_recommendations()
40
+ elif option == "Resource Library":
41
+ resource_library()
42
+
43
+ # Profile Setup Section
44
+ def profile_setup():
45
+ st.header("Profile Setup")
46
+ st.write("Fill out your details to personalize your experience.")
47
+ age = st.number_input("Age", min_value=10, max_value=100)
48
+ education = st.selectbox("Education Level", ["High School", "Undergraduate", "Graduate", "Other"])
49
+ interests = st.text_area("Career Interests", "e.g., Data Science, Graphic Design")
50
+ skills = st.text_area("Skills (comma-separated)", "e.g., Python, communication, empathy")
51
+
52
+ if st.button("Save Profile"):
53
+ st.session_state["profile"] = {
54
+ "age": age,
55
+ "education": education,
56
+ "interests": interests.split(", "),
57
+ "skills": skills.split(", ")
58
+ }
59
+ st.success("Profile saved successfully!")
60
+
61
+ # Q&A Section for Career-related questions
62
+ def career_qa():
63
+ st.header("Career Q&A")
64
+ question = st.text_input("Ask a career-related question")
65
+
66
+ if st.button("Get Answer"):
67
+ if question:
68
+ # Prepare question for the model
69
+ response = qa_pipeline(question)
70
+ st.write("Answer:", response[0]['generated_text'])
71
+ else:
72
+ st.warning("Please enter a question.")
73
+
74
+ # Career Recommendations Section (Mockup, Extend as needed)
75
+ def career_recommendations():
76
+ st.header("Career Recommendations")
77
+
78
+ # Mock recommendation - In a real application, this should be based on a recommendation model
79
+ st.write("Based on your interests and skills, we recommend:")
80
+ st.write("1. Data Scientist")
81
+ st.write("2. Software Engineer")
82
+ st.write("3. Product Manager")
83
+
84
+ # Resource Library Section
85
+ def resource_library():
86
+ st.header("Resource Library")
87
+ st.write("Browse resources related to different careers.")
88
+ career_choice = st.selectbox("Choose a career", ["Data Scientist", "Graphic Designer", "Software Engineer", "Nurse"])
89
+
90
+ # Display resources for the chosen career
91
+ st.write(f"### Resources for {career_choice}")
92
+ st.write("1. Article: How to become a successful " + career_choice)
93
+ st.write("2. Video: Day in the life of a " + career_choice)
94
+ st.write("3. Guide: Top skills for " + career_choice)
95
+
96
+ if _name_ == "_main_":
97
+     main()