import gradio as gr from utils.api.GPT import generate_answers_openai, Session import numpy as np import os import time def generate_interface(prompt, description=None): session = Session(prompt) def _fun(customer_input): print("(Q:) ", customer_input) response = generate_answers_openai(customer_input, session) print("(A:) ", response) return session.to_conversation_pair() interface = gr.Interface(description=description, fn=_fun, inputs=[gr.Textbox(lines=1, label="input")], outputs=[gr.Chatbot(label="conversation")]) return interface prompts = [ {"name": "Summary", "prompt": "Based on the language of human in the conversation, you will generate a report to assess the English level, summarize the conversation, and provide suggestions to improve the language. Conservation:{}", "description": "generate report."}, ] interfaces = [] names = [] for function in prompts: interface = generate_interface(function['prompt'], function['description']) interfaces.append(interface) names.append(function['name']) demo = gr.TabbedInterface(interfaces, names,title="Role Play Bot") if __name__ == '__main__': demo.launch()