ginipick commited on
Commit
dcebc91
·
verified ·
1 Parent(s): 7616ace

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -47,16 +47,24 @@ def launch_web_script():
47
  # web.py를 백그라운드에서 실행
48
  subprocess.Popen(["python", "web.py"])
49
 
 
 
 
 
 
50
  if __name__ == "__main__":
51
  # web.py를 실행
52
  launch_web_script()
53
 
54
  # Gradio 인터페이스 설정
55
- iface = gr.Interface(
56
- fn=generate_response,
57
- inputs=gr.Textbox(lines=7, label="User Input"),
58
- outputs=gr.Textbox(label="Response"),
59
- title="Chat with OpenAI",
60
- description="Enter your message and receive a response.",
61
- )
62
- iface.launch(server_name="0.0.0.0", server_port=7861) # 다른 포트를 지정
 
 
 
 
47
  # web.py를 백그라운드에서 실행
48
  subprocess.Popen(["python", "web.py"])
49
 
50
+ def chat_interface(user_input, chat_history):
51
+ response = generate_response(user_input)
52
+ chat_history.append((user_input, response))
53
+ return "", chat_history
54
+
55
  if __name__ == "__main__":
56
  # web.py를 실행
57
  launch_web_script()
58
 
59
  # Gradio 인터페이스 설정
60
+ with gr.Blocks() as demo:
61
+ gr.Markdown("## Chat with OpenAI")
62
+ chatbot = gr.Chatbot()
63
+ with gr.Row():
64
+ with gr.Column():
65
+ user_input = gr.Textbox(show_label=False, placeholder="Enter your message...")
66
+ submit_button = gr.Button("Send")
67
+
68
+ submit_button.click(chat_interface, [user_input, chatbot], [user_input, chatbot])
69
+
70
+ demo.launch(server_name="0.0.0.0", server_port=7861)