willn9 commited on
Commit
60de072
·
verified ·
1 Parent(s): 7299a32

Create app.py

Browse files

Enter your field and job of interest (or not sure), current qualifications, likes and skills and receive career advice!

Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import necessary packages
2
+ from ibm_watson_machine_learning.foundation_models import Model
3
+ import gradio as gr
4
+
5
+
6
+ # Model and project settings
7
+ model_id = "meta-llama/llama-2-13b-chat" # Directly specifying the LLAMA2 model
8
+
9
+ # Set credentials to use the model
10
+ my_credentials = {
11
+ "url": "https://us-south.ml.cloud.ibm.com"
12
+ }
13
+
14
+ # Generation parameters
15
+ gen_parms = {
16
+ "max_new_tokens": 512, # Adjust as needed for the length of the cover letter
17
+ "temperature": 0.7 # Adjust for creativity
18
+ }
19
+ project_id = "skills-network"
20
+ space_id = None
21
+ verify = False
22
+
23
+ # Initialize the model
24
+ model = Model(model_id, my_credentials, gen_parms, project_id, space_id, verify)
25
+
26
+ # Function to generate customized career advice
27
+ def generate_career_advice(field, position_name, current_qualifications, likes, skills):
28
+ # Craft the prompt for the model
29
+ prompt = f"Generate a customized career advice using field: {field}, \
30
+ position_name: {position_name}, \
31
+ current_qualifications: {current_qualifications}, \
32
+ likes: {likes}, \
33
+ skills: {skills}."
34
+
35
+ generated_response = model.generate(prompt, gen_parms)
36
+
37
+ # Extract the generated text
38
+ career_advice = generated_response["results"][0]["generated_text"]
39
+ return career_advice
40
+
41
+
42
+ # Create Gradio interface for the cover letter generation application
43
+ career_advice_app = gr.Interface(
44
+ fn=generate_career_advice,
45
+ allow_flagging="never", # Deactivate the flag function in gradio as it is not needed.
46
+ inputs=[
47
+ gr.Textbox(label="Field of Interest (e.g., healthcare, trades, social service, etc., or enter 'not sure')", placeholder="Enter the field which you are interested in... or type 'not sure'."),
48
+ gr.Textbox(label="Position Name (e.g., nurse, personal support worker, software developer, plumber, etc., or enter 'not sure')", placeholder="Enter the name of the position you are interested in... or type 'not sure'"),
49
+ gr.Textbox(label="Current Qualifications (e.g., studying in high school, high school diploma, college diploma, etc.)", placeholder="Enter your current qualifications ..."),
50
+ gr.Textbox(label="Likes (e.g., I like working with my hands, I like to work outside, I like to help people, I like teaching, ...", placeholder="Enter activities you like ...", lines=10),
51
+ gr.Textbox(label="Skills (e.g., I am good at math, science, languages, computers, research, hand tools, etc.)", placeholder="Skills ...", lines=10),
52
+ ],
53
+ outputs=gr.Textbox(label="Customized Career Advice"),
54
+ title="Customized Career Advice",
55
+ description="Generate a customized career advice using field, position name, likes and skills"
56
+ )
57
+
58
+ # Launch the application
59
+ career_advice_app.launch(server_name="0.0.0.0", debug=True, server_port=7860, share=True)