hinojosachapel
commited on
Commit
•
e28330b
1
Parent(s):
1e7b8f1
Upload folder using huggingface_hub
Browse files- .gitignore +1 -1
- app.py +33 -43
- 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
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
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 |
-
#
|
42 |
-
###
|
43 |
""")
|
44 |
|
45 |
interface = gr.Interface(
|
46 |
-
fn =
|
47 |
-
inputs = [gr.Textbox(placeholder="Enter the
|
48 |
-
|
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 |
-
|
2 |
-
torch
|
3 |
gradio
|
|
|
1 |
+
openai
|
|
|
2 |
gradio
|