hinojosachapel commited on
Commit
e28330b
1 Parent(s): 1e7b8f1

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitignore +1 -1
  2. app.py +33 -43
  3. requirements.txt +1 -2
.gitignore CHANGED
@@ -1,2 +1,2 @@
1
- private
2
  .DS_Store
 
1
+ private
2
  .DS_Store
app.py CHANGED
@@ -1,54 +1,44 @@
1
- from transformers import pipeline, Conversation
2
  import gradio as gr
3
- from datetime import datetime
4
-
5
- from transformers.utils import logging
6
- logging.set_verbosity_error()
7
-
8
- # Info about ['google/gemma-2b-it'](https://huggingface.co/google/gemma-2b-it)
9
- chatbot = pipeline(task="conversational",
10
- model="./models/google/gemma-2b-it")
11
-
12
- def get_job_description(company_name, sector, job_position):
13
- start_time = datetime.now()
14
-
15
- messages = [
16
- {
17
- "role": "user",
18
- "content": f"""
19
- You are the Talent Acquisition Manager at { company_name }, a company of the { sector } sector.
20
- Your goal is to hire people in different departments of the company.
21
- I want to generate a Job Description for the role '{ job_position }' in a creative, modern, formal and attractive way.
22
- """
23
- },
24
- {
25
- "role": "assistant",
26
- "content": "Description:"
27
- }
28
- ]
29
-
30
- conversation = Conversation(messages)
31
- conversation = chatbot(conversation, do_sample=True, max_new_tokens=600, temperature=1)
32
- response = conversation.messages[-1]["content"]
33
-
34
- delta_time = datetime.now() - start_time
35
-
36
- return response, delta_time
37
 
38
  with gr.Blocks() as demo:
39
  gr.Markdown(
40
  """
41
- # Job Description generator
42
- ### This SLM demo uses ['google/gemma-2b-it'](https://huggingface.co/google/gemma-2b-it)
43
  """)
44
 
45
  interface = gr.Interface(
46
- fn = get_job_description,
47
- inputs = [gr.Textbox(placeholder="Enter the company name", label="Company name"),
48
- gr.Textbox(placeholder="Enter the company sector", label="Company sector"),
49
- gr.Textbox(placeholder="Enter the job position", label="Job position")],
50
- outputs = [gr.Markdown(),
51
- gr.Textbox(label="Elapsed time")]
52
  )
53
 
54
  demo.launch(server_port=7860)
 
1
+ from openai import OpenAI
2
  import gradio as gr
3
+
4
+ openai_apikey = "sk-proj-JW9oMGO1QmwnOxQ3vUA8T3BlbkFJO2zo3KLERLeds7HJmt6y"
5
+
6
+ client = OpenAI(api_key = openai_apikey)
7
+
8
+ thread = client.beta.threads.create()
9
+
10
+ def get_answer(question):
11
+ message = client.beta.threads.messages.create(
12
+ thread_id = thread.id,
13
+ role = "user",
14
+ content = question
15
+ )
16
+
17
+ run = client.beta.threads.runs.create_and_poll(
18
+ thread_id = thread.id,
19
+ assistant_id = "asst_LgX8lE9erZR3ktgzOvkWNAQ8",
20
+ instructions = "Your name is Bossard ChatGPT. You enable access to Bossard technical knowledge in an interactive and targeted way. You act like an experienced Bossard engineer and can advise with skillful hints in the entirety and provide relevant further information. I want the answer you give to be more or less 100 words maximum if necessary. Try responding with a list, a short answer or a step-by-step guide if you feel like you should give an answer like that for the question."
21
+ )
22
+
23
+ messages = client.beta.threads.messages.list(
24
+ thread_id = thread.id
25
+ )
26
+
27
+ response = messages.data[0].content[0].text.value
28
+
29
+ return response
 
 
 
 
 
 
 
30
 
31
  with gr.Blocks() as demo:
32
  gr.Markdown(
33
  """
34
+ # Bossard ChatGPT
35
+ ### PoC with OpenAI GPT4o
36
  """)
37
 
38
  interface = gr.Interface(
39
+ fn = get_answer,
40
+ inputs = [gr.Textbox(placeholder="Enter the question", label="Question")],
41
+ outputs = [gr.Markdown()]
 
 
 
42
  )
43
 
44
  demo.launch(server_port=7860)
requirements.txt CHANGED
@@ -1,3 +1,2 @@
1
- transformers
2
- torch
3
  gradio
 
1
+ openai
 
2
  gradio