Aniquel's picture
Create app.py
2659b85
raw
history blame
No virus
766 Bytes
import gradio as gr
import openai
import os
openai.api_key = os.getenv("OPENAI_API_KEY")
MODEL = gpt-3.5-turbo
def generate_response(text):
prompt = f"Code generation:\n\n```python\n{text}\n```"
response = openai.Completion.create(
model=MODEL,
prompt=prompt,
max_tokens=3000,
n=1,
stop=None,
temperature=0.2,
)
message = response.choices[0].text.strip()
return message
iface = gr.Interface(
fn=generate_response,
inputs=gr.inputs.Textbox(label="Enter your code here"),
outputs=gr.outputs.Textbox(label="Chatbot's response"),
title="WizApp Code Generation",
description="Use AI to generate code based on your input",
theme="default"
)
if __name__ == "__main__":
iface.launch()