Gyufyjk commited on
Commit
85486a7
·
verified ·
1 Parent(s): 7d6caa7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -25
app.py CHANGED
@@ -86,30 +86,22 @@ additional_inputs = [
86
  with gr.Blocks(theme="Nymbo/Alyx_Theme") as demo:
87
  gr.Markdown("# Chatbot with Image Generation")
88
 
89
- with gr.Column():
90
- chat_interface = gr.ChatInterface(
91
- fn=generate_response,
92
- chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
93
- additional_inputs=additional_inputs,
94
- theme="Nymbo/Alyx_Theme",
95
- title="Mistral 7B v0.3 Chat with Mira"
96
- )
97
-
98
- chat_input = gr.Textbox(label="User Input", placeholder="Type your message here...")
99
- chat_output = gr.Textbox(label="Chatbot Response")
100
- image_output = gr.Image(label="Generated Image", visible=False)
101
- temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.7, step=0.1)
102
- max_tokens = gr.Slider(label="Max Tokens", minimum=10, maximum=512, value=100, step=10)
103
- top_p = gr.Slider(label="Top-p", minimum=0.1, maximum=1.0, value=0.9, step=0.1)
104
- repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.2, step=0.1)
105
- chat_button = gr.Button("Send")
106
-
107
- def respond(user_input, temperature, max_tokens, top_p, repetition_penalty, chat_history=[]):
108
- for response, image in generate_response(user_input, chat_history, temperature, max_tokens, top_p, repetition_penalty):
109
- if image:
110
- return "", image, gr.update(visible=True)
111
- return response, None, gr.update(visible=False)
112
-
113
- chat_button.click(respond, inputs=[chat_input, temperature, max_tokens, top_p, repetition_penalty], outputs=[chat_output, image_output, image_output])
114
 
115
  demo.launch()
 
86
  with gr.Blocks(theme="Nymbo/Alyx_Theme") as demo:
87
  gr.Markdown("# Chatbot with Image Generation")
88
 
89
+ chat_history = gr.Chatbot()
90
+ chat_input = gr.Textbox(label="User Input", placeholder="Type your message here...")
91
+ chat_output = gr.Textbox(label="Chatbot Response")
92
+ image_output = gr.Image(label="Generated Image", visible=False)
93
+ temperature = gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.7, step=0.1)
94
+ max_tokens = gr.Slider(label="Max Tokens", minimum=10, maximum=512, value=100, step=10)
95
+ top_p = gr.Slider(label="Top-p", minimum=0.1, maximum=1.0, value=0.9, step=0.1)
96
+ repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.2, step=0.1)
97
+ chat_button = gr.Button("Send")
98
+
99
+ def respond(user_input, temperature, max_tokens, top_p, repetition_penalty, chat_history=[]):
100
+ for response, image in generate_response(user_input, chat_history, temperature, max_tokens, top_p, repetition_penalty):
101
+ if image:
102
+ return "", image, gr.update(visible=True)
103
+ return response, None, gr.update(visible=False)
104
+
105
+ chat_button.click(respond, inputs=[chat_input, temperature, max_tokens, top_p, repetition_penalty], outputs=[chat_output, image_output, image_output])
 
 
 
 
 
 
 
 
106
 
107
  demo.launch()