jzou19950715 commited on
Commit
e576ca7
·
verified ·
1 Parent(s): 5a28fe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -11,7 +11,7 @@ import io
11
  logging.basicConfig(level=logging.INFO)
12
  logger = logging.getLogger(__name__)
13
 
14
- # Prompts
15
  CONVERSATION_PROMPT = """You are LOSS DOG, a professional profile builder. Your goal is to have natural conversations
16
  with users to gather information about their professional background across 9 categories:
17
 
@@ -167,7 +167,7 @@ class ProfileBuilder:
167
 
168
  # Get AI response
169
  completion = await self.client.chat.completions.create(
170
- model="gpt-4-0125-preview",
171
  messages=[
172
  {"role": "system", "content": CONVERSATION_PROMPT},
173
  *conversation_history
@@ -325,7 +325,8 @@ def create_gradio_interface():
325
  with gr.Row():
326
  msg = gr.Textbox(
327
  label="Message",
328
- placeholder="Chat with LOSS DOG..."
 
329
  )
330
  send = gr.Button("Send")
331
 
@@ -338,15 +339,15 @@ def create_gradio_interface():
338
  # Event handlers
339
  async def on_message(message: str, history: List[List[str]], key: str):
340
  if not message.strip():
341
- return history, None, None
342
 
343
  result = await builder.process_message(message, history, key)
344
 
345
  if "error" in result:
346
- return history, {"error": result["error"]}, None
347
 
348
  new_history = history + [[message, result["response"]]]
349
- return new_history, None, None
350
 
351
  async def on_pdf_upload(pdf, key):
352
  if not pdf:
@@ -377,13 +378,13 @@ def create_gradio_interface():
377
  msg.submit(
378
  on_message,
379
  inputs=[msg, chatbot, api_key],
380
- outputs=[chatbot, profile_output, download_btn]
381
  )
382
 
383
  send.click(
384
  on_message,
385
  inputs=[msg, chatbot, api_key],
386
- outputs=[chatbot, profile_output, download_btn]
387
  )
388
 
389
  process_pdf_btn.click(
 
11
  logging.basicConfig(level=logging.INFO)
12
  logger = logging.getLogger(__name__)
13
 
14
+ # Prompts remain the same
15
  CONVERSATION_PROMPT = """You are LOSS DOG, a professional profile builder. Your goal is to have natural conversations
16
  with users to gather information about their professional background across 9 categories:
17
 
 
167
 
168
  # Get AI response
169
  completion = await self.client.chat.completions.create(
170
+ model="gpt-4o-mini",
171
  messages=[
172
  {"role": "system", "content": CONVERSATION_PROMPT},
173
  *conversation_history
 
325
  with gr.Row():
326
  msg = gr.Textbox(
327
  label="Message",
328
+ placeholder="Chat with LOSS DOG...",
329
+ show_label=False
330
  )
331
  send = gr.Button("Send")
332
 
 
339
  # Event handlers
340
  async def on_message(message: str, history: List[List[str]], key: str):
341
  if not message.strip():
342
+ return history, None, None, "" # Added empty string to clear input
343
 
344
  result = await builder.process_message(message, history, key)
345
 
346
  if "error" in result:
347
+ return history, {"error": result["error"]}, None, message
348
 
349
  new_history = history + [[message, result["response"]]]
350
+ return new_history, None, None, "" # Empty string to clear input
351
 
352
  async def on_pdf_upload(pdf, key):
353
  if not pdf:
 
378
  msg.submit(
379
  on_message,
380
  inputs=[msg, chatbot, api_key],
381
+ outputs=[chatbot, profile_output, download_btn, msg] # Added msg to outputs
382
  )
383
 
384
  send.click(
385
  on_message,
386
  inputs=[msg, chatbot, api_key],
387
+ outputs=[chatbot, profile_output, download_btn, msg] # Added msg to outputs
388
  )
389
 
390
  process_pdf_btn.click(