Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
# Import necessary packages
|
|
|
|
| 2 |
from ibm_watson_machine_learning.foundation_models import Model
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Model and project settings
|
| 8 |
model_id = "meta-llama/llama-2-13b-chat" # Directly specifying the LLAMA2 model
|
|
@@ -18,13 +21,8 @@ gen_parms = {
|
|
| 18 |
"temperature": 0.7 # Adjust for creativity
|
| 19 |
}
|
| 20 |
|
| 21 |
-
watsonx_API = os.getenv("watson_API")
|
| 22 |
-
project_id = os.getenv("project_id")
|
| 23 |
-
space_id = None
|
| 24 |
-
verify = False
|
| 25 |
-
|
| 26 |
# Initialize the model
|
| 27 |
-
model = Model(model_id,
|
| 28 |
|
| 29 |
# Function to generate customized career advice
|
| 30 |
def generate_career_advice(field, position_name, current_qualifications, likes, skills):
|
|
@@ -41,11 +39,10 @@ def generate_career_advice(field, position_name, current_qualifications, likes,
|
|
| 41 |
career_advice = generated_response["results"][0]["generated_text"]
|
| 42 |
return career_advice
|
| 43 |
|
| 44 |
-
|
| 45 |
-
# Create Gradio interface for the cover letter generation application
|
| 46 |
career_advice_app = gr.Interface(
|
| 47 |
fn=generate_career_advice,
|
| 48 |
-
allow_flagging="never",
|
| 49 |
inputs=[
|
| 50 |
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'."),
|
| 51 |
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'"),
|
|
@@ -55,8 +52,9 @@ career_advice_app = gr.Interface(
|
|
| 55 |
],
|
| 56 |
outputs=gr.Textbox(label="Customized Career Advice"),
|
| 57 |
title="Customized Career Advice",
|
| 58 |
-
description="Generate a customized career advice using field, position name, likes and skills"
|
| 59 |
)
|
| 60 |
|
| 61 |
# Launch the application
|
| 62 |
career_advice_app.launch(server_name="0.0.0.0", debug=True, server_port=7860, share=True)
|
|
|
|
|
|
| 1 |
# Import necessary packages
|
| 2 |
+
import os
|
| 3 |
from ibm_watson_machine_learning.foundation_models import Model
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
# Securely access the API key and project ID from environment variables
|
| 7 |
+
watsonx_API = os.getenv("WATSONX_API")
|
| 8 |
+
project_id = os.getenv("PROJECT_ID")
|
| 9 |
|
| 10 |
# Model and project settings
|
| 11 |
model_id = "meta-llama/llama-2-13b-chat" # Directly specifying the LLAMA2 model
|
|
|
|
| 21 |
"temperature": 0.7 # Adjust for creativity
|
| 22 |
}
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# Initialize the model
|
| 25 |
+
model = Model(model_id, watsonx_API, gen_parms, project_id)
|
| 26 |
|
| 27 |
# Function to generate customized career advice
|
| 28 |
def generate_career_advice(field, position_name, current_qualifications, likes, skills):
|
|
|
|
| 39 |
career_advice = generated_response["results"][0]["generated_text"]
|
| 40 |
return career_advice
|
| 41 |
|
| 42 |
+
# Create Gradio interface for the career advice 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'"),
|
|
|
|
| 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)
|
| 60 |
+
|