Serg4451D's picture
Update app.py
c665a4e
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)