Spaces:
Runtime error
Runtime error
Download app.py from Serg4451D/code-davinci-edit-001: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/Serg4451D/code-davinci-edit-001/resolve/main/app.py
- Command line
-
hf download hf://spaces/Serg4451D/code-davinci-edit-001/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Serg4451D/code-davinci-edit-001/resolve/main/app.py
1 kB
| import streamlit as st | |
| import openai | |
| openai.api_key = "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" | |
| model_engine = "code-davinci-edit-001" | |
| def edit_code(request): | |
| """Отправляет запрос на редактирование программного кода.""" | |
| response = openai.Edit.create( | |
| model=model_engine, | |
| input=request, | |
| instruction="improve, fix and continue this code ", | |
| temperature=0.7, | |
| top_p=1 | |
| ) | |
| return response.choices[0].text | |
| # Создаем графический интерфейс | |
| st.title("OpenAI Code Editor") | |
| # Создаем поле ввода запроса | |
| input_request = st.text_area("Введите ваш код:") | |
| # Создаем кнопку для отправки запроса | |
| if st.button("Отправить запрос"): | |
| output = edit_code(input_request) | |
| # Создаем поле вывода результатов | |
| st.text("Результат:") | |
| st.code(output) | |