Spaces:
Runtime error
Runtime error
Upload app.py
Browse files65 unmodified lines6667686970716 unmodified lines7879808182838476 unmodified lines16116216316416516616716816917017117217317417517617717817918018118218318418518618718818965 unmodified linesyielddef adverse(message, history):global writer_messages, editor_messages, turntotal_response = ''for i in range(8):# update writer_messages6 unmodified linesturn = 'writer' if len(writer_messages)%2==0 else 'editor'list_of_messages = writer_messages if turn=='writer' else editor_messagesprint(f'turn: {turn}\n\nlist_of_messages: {list_of_messages}')total_response+=f'\n\n\nturn: {turn}\n'############################## call llm.create_chat_completion for whoever's turn76 unmodified lineswriter_messages = [{'role':'system','content':writer_system_prompt}]editor_messages = [{'role':'system','content':editor_system_prompt}]return f'writer system prompt:\n{writer_system_prompt}\n\neditor system prompt:\n{editor_system_prompt}'with gr.Blocks() as demo:gr.Markdown("""# Multi Agent LLMs for End-to-End Story GenerationStart typing below to see the output.""")gr.Interface(fn=set_system_prompts,inputs=gr.Textbox(placeholder="What is the topic?", label = 'Topic', lines=4),outputs=gr.Textbox(label='System prompt to use', lines=4))out_test = gr.Textbox(lines=4)button = gr.Button("test")button.click(lambda : f"{writer_system_prompt} \n\n\n{editor_system_prompt}", outputs=out_test)chat = gr.ChatInterface(fn=adverse,examples=["Start the story", "Write a poem", 'The funniest joke ever!'],title="Multi-Agent Bot",autofocus=False,fill_height=True,).queue()if __name__ == "__main__":demo.launch()65 unmodified lines6667686970717273746 unmodified lines8182838485868776 unmodified lines16416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319465 unmodified linesyielddef adverse(message, history):global writer_messages, editor_messages, turnif len(message)>0:out = set_system_prompts(message)print(out)total_response = ''for i in range(8):# update writer_messages6 unmodified linesturn = 'writer' if len(writer_messages)%2==0 else 'editor'list_of_messages = writer_messages if turn=='writer' else editor_messagesprint(f'turn: {turn}\n\nlist_of_messages: {list_of_messages}')total_response+=f'\n\n\n**turn: {turn}**\n'############################## call llm.create_chat_completion for whoever's turn76 unmodified lineswriter_messages = [{'role':'system','content':writer_system_prompt}]editor_messages = [{'role':'system','content':editor_system_prompt}]return f'writer system prompt:\n{writer_system_prompt}\n\neditor system prompt:\n{editor_system_prompt}'# with gr.Blocks() as demo:# gr.Markdown(# """# # Multi Agent LLMs for End-to-End Story Generation# """)# hyper = gr.Interface(# fn=set_system_prompts,# inputs=gr.Textbox(placeholder="What is the topic?", label = 'Topic', lines=4),# outputs=gr.Textbox(label='System prompt to use', lines=4)# )# out_test = gr.Textbox(lines=4)# button = gr.Button("test")# button.click(lambda : f"{writer_system_prompt} \n\n\n{editor_system_prompt}", outputs=out_test)# chat_textbox = gr.Textbox(lines=10)chat = gr.ChatInterface(fn=adverse,examples=["Start the story", "Write a poem", 'The funniest joke ever!'],title="Multi-Agent Bot",autofocus=False,fill_height=True,# fill_vertical_space=True,# additional_inputs = hyper,# textbox = chat_textbox,).queue()if __name__ == "__main__":chat.launch()
app.py+29-24