from utils import * with gr.Blocks() as demo: gr.Markdown("""

Mohadata: Debate Data Generator 🤖 🇲🇦

This tool generates a debate-style conversation between two AI models based on a given **context**. It simulates a question-answer dialogue, where one model acts as the questioner and the other as the answerer. The conversation is generated iteratively, with each model responding to the previous message from the other model. To use this tool: * First, add information about the models you want to use by clicking the "+" button and filling in the required details. * simply enter the **context** of the debate in the provided text box. * select the models you want to use for the **questioner** and **answerer**. * specify the **number of rounds** you want the conversation to last. * click the **"Submit"** button to generate the conversation. * download the conversation by clicking the **"Download Conversation"** button. The conversation will be displayed in the chatbot window, with the questioner's messages on the right and the answerer's messages on the left. This tool can be useful for generating debate-style conversations on a given topic, and can help in understanding different perspectives and arguments on a particular issue.
📋 Example Models and Base URLs
Model Name Base URL
claude-3 https://api.anthropic.com/v1
gpt-4 https://api.openai.com/v1
gemini-1.5-pro https://generativelanguage.googleapis.com/v1beta
deepseek-chat https://api.deepseek.com
""") with gr.Row("compact"): model_name=gr.Textbox(label="Model Name",placeholder="Enter Model Name") base_url=gr.Textbox(label="Base URL",placeholder="Enter Base URL") api_key=gr.Textbox(label="API Key",placeholder="Enter API Key",type="password") add=gr.Button("+",variant="huggingface") with gr.Row(equal_height=True): context=gr.Textbox(label="context",lines=3) with gr.Row(): model_quest=gr.Dropdown(label="Questioner Model",choices=list(model_base_url.keys())) model_answ=gr.Dropdown(label="Answerer Model",choices=list(model_base_url.keys())) num_rounds=gr.Number(label="Number Rounds",minimum=1) with gr.Row(): submit=gr.Button("Submit",variant="primary") with gr.Row(): chatbot=gr.Chatbot( type="messages",rtl=True ) with gr.Row(): save=gr.DownloadButton(label="Download Conversation",visible=False) add.click( add_model, inputs=[model_name,base_url,api_key], outputs=[model_quest,model_answ] ) submit.click( user_input, inputs=[context,model_quest,model_answ,num_rounds,chatbot], outputs=[chatbot,save]) demo.launch()