import gradio as gr import openai import os openai.api_key = os.getenv("OPENAI_API_KEY") input_prompt = "Generate Pseudocode from given code snippet using the latex package algorithm and algpseudocode\n Latex Code : \n\usepackage{algorithm}\n\usepackage{algpseudocode}\n" def generate_latex(code): response = openai.Completion.create( model="code-davinci-002", prompt= "```" + input_prompt + "```" + code , temperature=0, top_p=1, max_tokens=1500, ) return "\usepackage{algorithm}\n\usepackage{algpseudocode}\n" + response['choices'][0]["text"] iface = gr.Interface(fn=generate_latex, inputs="text", outputs="text") iface.launch()