import g4f import gradio as gr system_msg = """I want you to act as a machine learning engineer. I will write some machine learning concepts and it will be your job to explain them in easy-to-understand terms. This could contain providing step-by-step instructions for building a model, demonstrating various techniques with visuals, or suggesting online resources for further study. My first suggestion request is "I have a dataset without labels. Which machine learning algorithm should I use?"""" # system_msg = """""" def predict(message, history): history_openai_format = [] history_openai_format.append({"role": "user", "content": system_msg}) for human, assistant in history: history_openai_format.append({"role": "user", "content": human }) history_openai_format.append({"role": "Bing", "content":assistant}) history_openai_format.append({"role": "user", "content": message}) response = g4f.ChatCompletion.create( model="gpt-4", provider=g4f.Provider.Bing, messages=history_openai_format, stream=True) output = "" for message in response: output = output + message yield output response.close() gr.ChatInterface(predict).queue().launch(share=False)