Spaces:
Runtime error
Runtime error
Download app.py from Gradio-Blocks/Codex_OpenAI: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/Gradio-Blocks/Codex_OpenAI/resolve/refs%2Fpr%2F2/app.py
- Command line
-
hf download hf://spaces/Gradio-Blocks/Codex_OpenAI@refs/pr/2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Gradio-Blocks/Codex_OpenAI/resolve/refs%2Fpr%2F2/app.py
1 kB
| import openai | |
| import numpy as np | |
| import os | |
| import gradio as gr | |
| openai.api_key = os.environ["api_key"] | |
| engine = os.environ["engine"] | |
| def happytt(temperature,max_tokens,text): | |
| response = openai.Completion.create( | |
| engine=engine, | |
| prompt=text, | |
| temperature=temperature, | |
| max_tokens=max_tokens, | |
| top_p=1, | |
| frequency_penalty=0, | |
| presence_penalty=0 | |
| ) | |
| return response.choices[0].text | |
| title = "OpenAI Codex" | |
| description = "OpenAI Codex is an artificial intelligence model developed by OpenAI. | |
| It parses natural language and generates code in response. | |
| It is used to power GitHub Copilot, a programming autocompletion | |
| tool developed for Code generation." | |
| iface = gr.Interface( happytt,[ gr.inputs.Slider(0, 1, step=0.1),gr.inputs.Slider(1, 4000, step=1), | |
| gr.inputs.Textbox(type='str', | |
| label="input prompt")],"text", title = title, description = description ) | |
| iface.launch(debug=True) |