jeremierostan commited on
Commit
9825ea7
1 Parent(s): 008712b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -1,22 +1,20 @@
1
- from huggingface_hub import InferenceClient
2
  import os
3
  import openai
4
  import gradio as gr
5
  import time
6
 
 
7
  openai.api_key = os.getenv('openai_api_key')
8
- api_key = openai.api_key
9
-
10
- client = openai.Client(api_key=api_key)
11
-
12
- # Assuming you've already set up your OpenAI client and assistant
13
 
 
14
  assistant_id = os.getenv('assistant_id')
15
- assistant_id = assistant_id
16
  assistant = client.beta.assistants.retrieve(assistant_id)
17
-
18
  thread = client.beta.threads.create()
19
 
 
 
 
20
  def chat_with_assistant(message, history):
21
  # Add the user's message to the thread
22
  client.beta.threads.messages.create(
@@ -55,7 +53,6 @@ with gr.Blocks(css=custom_css) as demo:
55
  [],
56
  elem_id="chatbot",
57
  bubble_full_width=False,
58
- avatar_link = os.getenv('avatar_link'),
59
  avatar_images=(None, avatar_link)
60
  )
61
  msg = gr.Textbox(
@@ -76,4 +73,4 @@ with gr.Blocks(css=custom_css) as demo:
76
  bot, chatbot, chatbot
77
  )
78
 
79
- demo.launch(share=True)
 
 
1
  import os
2
  import openai
3
  import gradio as gr
4
  import time
5
 
6
+ # Set up OpenAI client
7
  openai.api_key = os.getenv('openai_api_key')
8
+ client = openai.Client(api_key=openai.api_key)
 
 
 
 
9
 
10
+ # Set up assistant
11
  assistant_id = os.getenv('assistant_id')
 
12
  assistant = client.beta.assistants.retrieve(assistant_id)
 
13
  thread = client.beta.threads.create()
14
 
15
+ # Get avatar link
16
+ avatar_link = os.getenv('avatar_link')
17
+
18
  def chat_with_assistant(message, history):
19
  # Add the user's message to the thread
20
  client.beta.threads.messages.create(
 
53
  [],
54
  elem_id="chatbot",
55
  bubble_full_width=False,
 
56
  avatar_images=(None, avatar_link)
57
  )
58
  msg = gr.Textbox(
 
73
  bot, chatbot, chatbot
74
  )
75
 
76
+ demo.launch()