davoodwadi commited on
Commit
74c20e9
1 Parent(s): 7145497

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -24
app.py CHANGED
@@ -66,6 +66,9 @@ def response_stream():
66
  yield
67
  def adverse(message, history):
68
  global writer_messages, editor_messages, turn
 
 
 
69
  total_response = ''
70
  for i in range(8):
71
  # update writer_messages
@@ -78,7 +81,7 @@ def adverse(message, history):
78
  turn = 'writer' if len(writer_messages)%2==0 else 'editor'
79
  list_of_messages = writer_messages if turn=='writer' else editor_messages
80
  print(f'turn: {turn}\n\nlist_of_messages: {list_of_messages}')
81
- total_response+=f'\n\n\nturn: {turn}\n'
82
  #############################
83
 
84
  # call llm.create_chat_completion for whoever's turn
@@ -161,29 +164,31 @@ def set_system_prompts(x):
161
  writer_messages = [{'role':'system','content':writer_system_prompt}]
162
  editor_messages = [{'role':'system','content':editor_system_prompt}]
163
  return f'writer system prompt:\n{writer_system_prompt}\n\neditor system prompt:\n{editor_system_prompt}'
164
- with gr.Blocks() as demo:
165
- gr.Markdown(
166
- """
167
- # Multi Agent LLMs for End-to-End Story Generation
168
- Start typing below to see the output.
169
- """)
170
- gr.Interface(
171
- fn=set_system_prompts,
172
- inputs=gr.Textbox(placeholder="What is the topic?", label = 'Topic', lines=4),
173
- outputs=gr.Textbox(label='System prompt to use', lines=4)
174
- )
175
 
176
- out_test = gr.Textbox(lines=4)
177
- button = gr.Button("test")
178
- button.click(lambda : f"{writer_system_prompt} \n\n\n{editor_system_prompt}", outputs=out_test)
179
-
180
- chat = gr.ChatInterface(
181
- fn=adverse,
182
- examples=["Start the story", "Write a poem", 'The funniest joke ever!'],
183
- title="Multi-Agent Bot",
184
- autofocus=False,
185
- fill_height=True,
186
- ).queue()
 
 
 
187
 
188
  if __name__ == "__main__":
189
- demo.launch()
 
66
  yield
67
  def adverse(message, history):
68
  global writer_messages, editor_messages, turn
69
+ if len(message)>0:
70
+ out = set_system_prompts(message)
71
+ print(out)
72
  total_response = ''
73
  for i in range(8):
74
  # update writer_messages
 
81
  turn = 'writer' if len(writer_messages)%2==0 else 'editor'
82
  list_of_messages = writer_messages if turn=='writer' else editor_messages
83
  print(f'turn: {turn}\n\nlist_of_messages: {list_of_messages}')
84
+ total_response+=f'\n\n\n**turn: {turn}**\n'
85
  #############################
86
 
87
  # call llm.create_chat_completion for whoever's turn
 
164
  writer_messages = [{'role':'system','content':writer_system_prompt}]
165
  editor_messages = [{'role':'system','content':editor_system_prompt}]
166
  return f'writer system prompt:\n{writer_system_prompt}\n\neditor system prompt:\n{editor_system_prompt}'
167
+ # with gr.Blocks() as demo:
168
+ # gr.Markdown(
169
+ # """
170
+ # # Multi Agent LLMs for End-to-End Story Generation
171
+ # """)
172
+ # hyper = gr.Interface(
173
+ # fn=set_system_prompts,
174
+ # inputs=gr.Textbox(placeholder="What is the topic?", label = 'Topic', lines=4),
175
+ # outputs=gr.Textbox(label='System prompt to use', lines=4)
176
+ # )
 
177
 
178
+ # out_test = gr.Textbox(lines=4)
179
+ # button = gr.Button("test")
180
+ # button.click(lambda : f"{writer_system_prompt} \n\n\n{editor_system_prompt}", outputs=out_test)
181
+ # chat_textbox = gr.Textbox(lines=10)
182
+ chat = gr.ChatInterface(
183
+ fn=adverse,
184
+ examples=["Start the story", "Write a poem", 'The funniest joke ever!'],
185
+ title="Multi-Agent Bot",
186
+ autofocus=False,
187
+ fill_height=True,
188
+ # fill_vertical_space=True,
189
+ # additional_inputs = hyper,
190
+ # textbox = chat_textbox,
191
+ ).queue()
192
 
193
  if __name__ == "__main__":
194
+ chat.launch()