willn9 commited on
Commit
7a6f260
·
verified ·
1 Parent(s): d376395

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -2,14 +2,10 @@
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
  # Set credentials to use the model
14
  my_credentials = {
15
  "url": "https://us-south.ml.cloud.ibm.com"
@@ -27,7 +23,6 @@ verify = False
27
  # Initialize the model
28
  model = Model(model_id, my_credentials, gen_parms, project_id, space_id, verify)
29
 
30
-
31
  # Function to generate customized career advice
32
  def generate_career_advice(field, position_name, current_qualifications, likes, skills):
33
  # Craft the prompt for the model
@@ -43,10 +38,11 @@ def generate_career_advice(field, position_name, current_qualifications, likes,
43
  career_advice = generated_response["results"][0]["generated_text"]
44
  return career_advice
45
 
 
46
  # Create Gradio interface for the cover letter generation application
47
  career_advice_app = gr.Interface(
48
  fn=generate_career_advice,
49
- allow_flagging="never", # Deactivate the flag function in gradio as it is not needed.
50
  inputs=[
51
  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'."),
52
  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'"),
@@ -56,8 +52,8 @@ career_advice_app = gr.Interface(
56
  ],
57
  outputs=gr.Textbox(label="Customized Career Advice"),
58
  title="Customized Career Advice",
59
- description="Generate a customized career advice using field, position name, likes, and skills"
60
  )
61
 
62
  # Launch the application
63
- career_advice_app.launch()
 
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"
 
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
 
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'"),
 
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)