Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,28 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
2 |
from transformers import AutoTokenizer, pipeline
|
3 |
from peft import PeftModel, PeftConfig
|
4 |
from transformers import AutoModelForSeq2SeqLM
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
# Load the LoRA configuration and model
|
21 |
try:
|
@@ -30,38 +37,11 @@ except Exception as e:
|
|
30 |
# Set up the Q&A pipeline using the LoRA fine-tuned model
|
31 |
qa_pipeline = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
32 |
|
33 |
-
# Function to load Kaggle datasets directly into pandas DataFrames
|
34 |
-
def load_kaggle_dataset(dataset_path, file_name):
|
35 |
-
kaggle.api.authenticate() # Authenticate using your Kaggle credentials
|
36 |
-
kaggle.api.dataset_download_files(dataset_path, path=".", unzip=True)
|
37 |
-
return pd.read_csv(file_name)
|
38 |
-
|
39 |
-
# Load relevant Kaggle datasets
|
40 |
-
try:
|
41 |
-
# CareerBuilder Job Listings Dataset
|
42 |
-
job_listings_df = load_kaggle_dataset("promptcloud/careerbuilder-job-listing-2020", "job_listings.csv")
|
43 |
-
st.write("CareerBuilder Job Listings Dataset loaded successfully!") # Debugging message
|
44 |
-
|
45 |
-
# Career Prediction Dataset
|
46 |
-
career_df = load_kaggle_dataset("utkarshshrivastav07/career-prediction-dataset", "career_prediction.csv")
|
47 |
-
st.write("Career Prediction Dataset loaded successfully!") # Debugging message
|
48 |
-
except Exception as e:
|
49 |
-
st.error(f"Error loading Kaggle dataset: {e}")
|
50 |
-
|
51 |
-
# Load SQuAD dataset for intelligent Q&A from GitHub
|
52 |
-
try:
|
53 |
-
url = "https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v2.0.json"
|
54 |
-
response = requests.get(url)
|
55 |
-
squad_data = response.json()
|
56 |
-
st.write("SQuAD Dataset loaded successfully!") # Debugging message
|
57 |
-
except Exception as e:
|
58 |
-
st.error(f"Error loading SQuAD dataset: {e}")
|
59 |
-
|
60 |
# Streamlit App Structure
|
61 |
def main():
|
62 |
st.title("AI-Powered Career Counseling App with Advanced Q&A")
|
63 |
st.sidebar.title("Navigation")
|
64 |
-
option = st.sidebar.selectbox("Choose an Option", ["Profile Setup", "Career Q&A", "Career Recommendations", "Resource Library"])
|
65 |
|
66 |
if option == "Profile Setup":
|
67 |
profile_setup()
|
@@ -71,6 +51,8 @@ def main():
|
|
71 |
career_recommendations()
|
72 |
elif option == "Resource Library":
|
73 |
resource_library()
|
|
|
|
|
74 |
|
75 |
# Global variable to store user responses
|
76 |
user_responses = []
|
@@ -195,5 +177,25 @@ def resource_library():
|
|
195 |
for keyword in keywords:
|
196 |
st.write(f"- {keyword}")
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
if __name__ == "__main__":
|
199 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
+
import json
|
3 |
+
import os
|
4 |
+
import pandas as pd
|
5 |
+
import requests
|
6 |
from transformers import AutoTokenizer, pipeline
|
7 |
from peft import PeftModel, PeftConfig
|
8 |
from transformers import AutoModelForSeq2SeqLM
|
9 |
+
from kaggle.api.kaggle_api_extended import KaggleApi
|
10 |
+
|
11 |
+
# Function to load Kaggle API credentials
|
12 |
+
def load_kaggle_credentials():
|
13 |
+
# Load kaggle.json file
|
14 |
+
with open('kaggle.json') as f:
|
15 |
+
kaggle_credentials = json.load(f)
|
16 |
+
return kaggle_credentials['username'], kaggle_credentials['key']
|
17 |
+
|
18 |
+
# Set up the Kaggle API client
|
19 |
+
def setup_kaggle_api():
|
20 |
+
username, key = load_kaggle_credentials()
|
21 |
+
os.environ['KAGGLE_USERNAME'] = username
|
22 |
+
os.environ['KAGGLE_KEY'] = key
|
23 |
+
api = KaggleApi()
|
24 |
+
api.authenticate()
|
25 |
+
return api
|
26 |
|
27 |
# Load the LoRA configuration and model
|
28 |
try:
|
|
|
37 |
# Set up the Q&A pipeline using the LoRA fine-tuned model
|
38 |
qa_pipeline = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
# Streamlit App Structure
|
41 |
def main():
|
42 |
st.title("AI-Powered Career Counseling App with Advanced Q&A")
|
43 |
st.sidebar.title("Navigation")
|
44 |
+
option = st.sidebar.selectbox("Choose an Option", ["Profile Setup", "Career Q&A", "Career Recommendations", "Resource Library", "Kaggle Integration"])
|
45 |
|
46 |
if option == "Profile Setup":
|
47 |
profile_setup()
|
|
|
51 |
career_recommendations()
|
52 |
elif option == "Resource Library":
|
53 |
resource_library()
|
54 |
+
elif option == "Kaggle Integration":
|
55 |
+
kaggle_integration()
|
56 |
|
57 |
# Global variable to store user responses
|
58 |
user_responses = []
|
|
|
177 |
for keyword in keywords:
|
178 |
st.write(f"- {keyword}")
|
179 |
|
180 |
+
# Kaggle Integration Section
|
181 |
+
def kaggle_integration():
|
182 |
+
st.header("Kaggle Integration")
|
183 |
+
if st.button("Setup Kaggle API"):
|
184 |
+
try:
|
185 |
+
api = setup_kaggle_api()
|
186 |
+
st.success("Kaggle API successfully set up!")
|
187 |
+
except Exception as e:
|
188 |
+
st.error(f"Failed to set up Kaggle API: {e}")
|
189 |
+
|
190 |
+
if st.button("List Kaggle Datasets"):
|
191 |
+
try:
|
192 |
+
api = setup_kaggle_api() # Ensure API is set up
|
193 |
+
datasets = api.dataset_list()
|
194 |
+
st.write("### Available Datasets:")
|
195 |
+
for dataset in datasets:
|
196 |
+
st.write(dataset.ref)
|
197 |
+
except Exception as e:
|
198 |
+
st.error(f"Failed to retrieve datasets: {e}")
|
199 |
+
|
200 |
if __name__ == "__main__":
|
201 |
main()
|