willn9 commited on
Commit
9552cf2
·
verified ·
1 Parent(s): 895534e

Delete app_old_IBM.py

Browse files
Files changed (1) hide show
  1. app_old_IBM.py +0 -75
app_old_IBM.py DELETED
@@ -1,75 +0,0 @@
1
- import os
2
- from ibm_watson_machine_learning.foundation_models import Model
3
- from ibm_watson_machine_learning.metanames import GenTextParamsMetaNames as GenParams
4
- from ibm_watson_machine_learning.foundation_models.utils.enums import ModelTypes, DecodingMethods
5
- import gradio as gr
6
-
7
-
8
- # Set up the API key and project ID for IBM Watson
9
- watsonx_API = os.environ.get("watsonx_API")
10
- project_id = os.environ.get("project_id")
11
-
12
- # Generation parameters
13
- gen_parms = {
14
- "max_new_tokens": 512, # Adjust as needed
15
- "temperature": 0.7 # Adjust for creativity
16
- }
17
-
18
- # Model and project settings
19
- model_id = "meta-llama/llama-2-13b-chat"
20
-
21
- credentials={
22
- "apikey": watsonx_API,
23
- "url": "https://us-south.ml.cloud.ibm.com"
24
- }
25
-
26
- model = Model(
27
- model_id = 'meta-llama/llama-2-13b-chat', # you can also specify like: ModelTypes.LLAMA_2_70B_CHAT
28
- params = gen_parms,
29
- credentials={
30
- "apikey": watsonx_API,
31
- "url": "https://us-south.ml.cloud.ibm.com"
32
- },
33
- project_id= project_id
34
- )
35
-
36
- # Initialize the model
37
- model = Model(model_id, credentials, gen_parms, project_id)
38
-
39
- # Function to generate customized career advice
40
- def generate_career_advice(field, position_name, current_qualifications, likes, skills):
41
- # Craft the prompt for the model
42
- prompt = f"Generate a customized career advice using desired career field: {field}, \
43
- dream job: {position_name}, \
44
- current qualifications and certifications: {current_qualifications}, \
45
- likes: {likes}, \
46
- skills: {skills}. Include tips on which career paths make a good fit and are in demand, \
47
- what additional qualifications, courses, training or certifications to take, networking, \
48
- gaining experience, etc. Use a brief style and limit your answer within 512 tokens or less."
49
-
50
- generated_response = model.generate(prompt, gen_parms)
51
-
52
- # Extract the generated text
53
- career_advice = generated_response["results"][0]["generated_text"]
54
- return career_advice
55
-
56
-
57
- # Create Gradio interface for the cover letter generation application
58
- career_advice_app = gr.Interface(
59
- fn=generate_career_advice,
60
- allow_flagging="never", # Deactivate the flag function in gradio as it is not needed.
61
- inputs=[
62
- gr.Textbox(label="Desired Career Field (e.g., healthcare, trades, social service, etc., or enter 'not sure')", placeholder="Enter the field which you are interested in... or type 'not sure'."),
63
- gr.Textbox(label="Your Dream Job (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'"),
64
- gr.Textbox(label="Current Qualifications and or Certifications (e.g., studying in high school, high school diploma, college diploma, etc.)", placeholder="Enter your current qualifications ..."),
65
- 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),
66
- gr.Textbox(label="Skills (e.g., I am good at math, science, languages, computers, research, hand tools, etc.)", placeholder="Enter your skills ...", lines=10),
67
- ],
68
- outputs=gr.Textbox(label="Customized Career Advice"),
69
- title="Customized AI-Powered Career Advice - by Wael Nawara",
70
- description="This App will generate an AI-powered customized career advice based on the career field which you select, your dream job, current qualifications, likes and skills. A word of caution: even AI makes mistakes!"
71
- )
72
-
73
- # Launch the application
74
- career_advice_app.launch(server_name="0.0.0.0", debug=True, server_port=7860, share=True)
75
-