import gradio as gr # Function to process input and generate output def orthogonizer(text, api_key): prompt = f"Given the input '{text}', please provide an orthogonal perspective." # Set up OpenAI API openai.api_key = api_key # Call OpenAI API to process the input text response = openai.Completion.create( engine="text-davinci-003", prompt=prompt, max_tokens=200, #longer responses n=1, # one response temperature=0.5, # more deterministic output ) # Extract the generated orthogonal perspective from the OpenAI response orthogonal_perspective = response.choices[0]['text'].strip() # Remove the brackets and the words "orthogonal perspective" orthogonal_perspective = orthogonal_perspective.replace("{", "").replace("}", "").replace("Orthogonal Perspective: ", "") return orthogonal_perspective # Set up Gradio interface input_text = gr.inputs.Textbox(label="Enter your input text") api_key_text = gr.inputs.Textbox(label="Enter your OpenAI API key") output_text = gr.outputs.Textbox(label="Output") interface = gr.Interface( fn=orthogonizer, inputs=[input_text, api_key_text], outputs=output_text, title="Orthogonizer App", description="Enter your text and get an orthogonal perspective.", article="", ) if __name__ == "__main__": interface.launch()