Rahatara commited on
Commit
89b2b66
·
verified ·
1 Parent(s): de6cf94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -6
app.py CHANGED
@@ -9,7 +9,7 @@ client = Groq(api_key=api_key)
9
  # Initialize conversation history
10
  conversation_history = []
11
 
12
- def chat_with_bot_stream(user_input):
13
  global conversation_history
14
  conversation_history.append({"role": "user", "content": user_input})
15
 
@@ -22,9 +22,9 @@ def chat_with_bot_stream(user_input):
22
  completion = client.chat.completions.create(
23
  model="llama3-70b-8192",
24
  messages=conversation_history,
25
- temperature=1,
 
26
  max_tokens=1024,
27
- top_p=1,
28
  stream=True,
29
  stop=None,
30
  )
@@ -75,6 +75,14 @@ example_scenarios = [
75
  "A medieval knight navigating political intrigue."
76
  ]
77
 
 
 
 
 
 
 
 
 
78
  temperature_component = gr.Slider(
79
  minimum=0,
80
  maximum=1,
@@ -106,10 +114,26 @@ with gr.Blocks(theme=gr.themes.Glass(primary_hue="violet", secondary_hue="emeral
106
  )
107
  send_button = gr.Button("✋Ask Question")
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  # Chatbot functionality
110
  send_button.click(
111
  fn=chat_with_bot_stream,
112
- inputs=user_input,
113
  outputs=chatbot,
114
  queue=True
115
  ).then(
@@ -129,7 +153,7 @@ with gr.Blocks(theme=gr.themes.Glass(primary_hue="violet", secondary_hue="emeral
129
  generate_btn = gr.Button("Generate Storyboard")
130
  storyboard_output = gr.Textbox(label="Generated Storyboard", interactive=False)
131
 
132
- with gr.Accordion("🛠️ Customize", open=False):
133
  temperature_component.render()
134
  top_p_component.render()
135
 
@@ -145,4 +169,4 @@ with gr.Blocks(theme=gr.themes.Glass(primary_hue="violet", secondary_hue="emeral
145
  outputs=[scenario_input]
146
  )
147
 
148
- demo.launch()
 
9
  # Initialize conversation history
10
  conversation_history = []
11
 
12
+ def chat_with_bot_stream(user_input, temperature, top_p):
13
  global conversation_history
14
  conversation_history.append({"role": "user", "content": user_input})
15
 
 
22
  completion = client.chat.completions.create(
23
  model="llama3-70b-8192",
24
  messages=conversation_history,
25
+ temperature=temperature,
26
+ top_p=top_p,
27
  max_tokens=1024,
 
28
  stream=True,
29
  stop=None,
30
  )
 
75
  "A medieval knight navigating political intrigue."
76
  ]
77
 
78
+ example_questions = [
79
+ "How do I create a compelling storyboard?",
80
+ "What are the key elements of a good visual story?",
81
+ "How can AI help with storyboarding?",
82
+ "What are common mistakes in storyboarding?",
83
+ "How do I structure a scene effectively?"
84
+ ]
85
+
86
  temperature_component = gr.Slider(
87
  minimum=0,
88
  maximum=1,
 
114
  )
115
  send_button = gr.Button("✋Ask Question")
116
 
117
+ with gr.Accordion("🛠️ Customize Chatbot", open=False):
118
+ temperature_component.render()
119
+ top_p_component.render()
120
+
121
+ with gr.Accordion("🧪 Example Questions", open=False):
122
+ example_radio = gr.Radio(
123
+ choices=example_questions,
124
+ label="Example Queries",
125
+ info="Select an example question or enter your own."
126
+ )
127
+ example_radio.change(
128
+ fn=lambda q: q if q else "No question selected.",
129
+ inputs=[example_radio],
130
+ outputs=[user_input]
131
+ )
132
+
133
  # Chatbot functionality
134
  send_button.click(
135
  fn=chat_with_bot_stream,
136
+ inputs=[user_input, temperature_component, top_p_component],
137
  outputs=chatbot,
138
  queue=True
139
  ).then(
 
153
  generate_btn = gr.Button("Generate Storyboard")
154
  storyboard_output = gr.Textbox(label="Generated Storyboard", interactive=False)
155
 
156
+ with gr.Accordion("🛠️ Customize Storyboard", open=False):
157
  temperature_component.render()
158
  top_p_component.render()
159
 
 
169
  outputs=[scenario_input]
170
  )
171
 
172
+ demo.launch()