# -*- coding: utf-8 -*- """app.py Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1mcXiMSco30xGunxMFqCH3C9C2vqqim9M """ import os import openai openai.api_key = os.getenv("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") start_sequence = "\nAI:" restart_sequence = "\nHuman: " openai.api_key = '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' prompt = 'hello bot' response = openai.Completion.create( model="text-davinci-003", prompt=prompt, temperature=0.9, max_tokens=150, top_p=1, frequency_penalty=0, presence_penalty=0.6, stop=[" Human:", " AI:"] ) x = response response = x['choices'][0]['text'] import gradio as gr def start(inp): prompt = inp response = openai.Completion.create( model="text-davinci-003", prompt=prompt, temperature=0.9, max_tokens=150, top_p=1, frequency_penalty=0, presence_penalty=0.6, stop=[" Human:", " AI:"] ) x = response return x['choices'][0]['text'] iface = gr.Interface(fn=start, inputs='text', outputs='text') iface.launch(debug=True, share=True)