Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,22 +2,23 @@
|
|
| 2 |
from ibm_watson_machine_learning.foundation_models import Model
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Model and project settings
|
| 9 |
model_id = "meta-llama/llama-2-13b-chat" # Directly specifying the LLAMA2 model
|
| 10 |
|
| 11 |
-
|
| 12 |
# Generation parameters
|
| 13 |
gen_parms = {
|
| 14 |
"max_new_tokens": 512, # Adjust as needed for the length of the cover letter
|
| 15 |
"temperature": 0.7 # Adjust for creativity
|
| 16 |
}
|
| 17 |
|
| 18 |
-
|
| 19 |
# Initialize the model
|
| 20 |
-
model = Model(model_id,
|
| 21 |
|
| 22 |
# Function to generate customized career advice
|
| 23 |
def generate_career_advice(field, position_name, current_qualifications, likes, skills):
|
|
@@ -34,11 +35,10 @@ def generate_career_advice(field, position_name, current_qualifications, likes,
|
|
| 34 |
career_advice = generated_response["results"][0]["generated_text"]
|
| 35 |
return career_advice
|
| 36 |
|
| 37 |
-
|
| 38 |
# Create Gradio interface for the cover letter generation application
|
| 39 |
career_advice_app = gr.Interface(
|
| 40 |
fn=generate_career_advice,
|
| 41 |
-
allow_flagging="never",
|
| 42 |
inputs=[
|
| 43 |
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'."),
|
| 44 |
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'"),
|
|
@@ -48,7 +48,7 @@ career_advice_app = gr.Interface(
|
|
| 48 |
],
|
| 49 |
outputs=gr.Textbox(label="Customized Career Advice"),
|
| 50 |
title="Customized Career Advice",
|
| 51 |
-
description="Generate a customized career advice using field, position name, likes and skills"
|
| 52 |
)
|
| 53 |
|
| 54 |
# Launch the application
|
|
|
|
| 2 |
from ibm_watson_machine_learning.foundation_models import Model
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
# Securely load the API key and project ID
|
| 8 |
+
watsonx_API = os.getenv("WATSONX_API")
|
| 9 |
+
project_id= os.getenv("PROJECT_ID")
|
| 10 |
|
| 11 |
# Model and project settings
|
| 12 |
model_id = "meta-llama/llama-2-13b-chat" # Directly specifying the LLAMA2 model
|
| 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 |
|
|
|
|
| 20 |
# Initialize the model
|
| 21 |
+
model = Model(model_id, watsonx_API, gen_parms, project_id)
|
| 22 |
|
| 23 |
# Function to generate customized career advice
|
| 24 |
def generate_career_advice(field, position_name, current_qualifications, likes, skills):
|
|
|
|
| 35 |
career_advice = generated_response["results"][0]["generated_text"]
|
| 36 |
return career_advice
|
| 37 |
|
|
|
|
| 38 |
# Create Gradio interface for the cover letter generation application
|
| 39 |
career_advice_app = gr.Interface(
|
| 40 |
fn=generate_career_advice,
|
| 41 |
+
allow_flagging="never", # Deactivate the flag function in gradio as it is not needed.
|
| 42 |
inputs=[
|
| 43 |
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'."),
|
| 44 |
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'"),
|
|
|
|
| 48 |
],
|
| 49 |
outputs=gr.Textbox(label="Customized Career Advice"),
|
| 50 |
title="Customized Career Advice",
|
| 51 |
+
description="Generate a customized career advice using field, position name, likes, and skills"
|
| 52 |
)
|
| 53 |
|
| 54 |
# Launch the application
|