Spaces:
Runtime error
Runtime error
Commit
·
4c88f7e
1
Parent(s):
7ca7bb9
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,12 @@ openai.api_key = "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"
|
|
8 |
# Set the model to use (e.g. "text-davinci-002")
|
9 |
model = "text-davinci-002"
|
10 |
|
11 |
-
def convert_code(code,
|
12 |
"""
|
13 |
Convert the given code to the specified language using GPT-3.
|
14 |
"""
|
15 |
# Set the prompt to use as input to the model
|
16 |
-
prompt = f"Convert {
|
17 |
|
18 |
# Call the GPT-3 API to generate text
|
19 |
response = openai.Completion.create(
|
@@ -32,7 +32,7 @@ def convert_code(code, language):
|
|
32 |
# Create the Gradio app
|
33 |
app = gr.Interface(
|
34 |
fn=convert_code,
|
35 |
-
inputs=[gr.inputs.Textbox(lines=10, label="Code to convert"), gr.Radio(["Python", "R"], label="Source language")],
|
36 |
outputs=[gr.outputs.Textbox(label="Converted code")]
|
37 |
)
|
38 |
|
|
|
8 |
# Set the model to use (e.g. "text-davinci-002")
|
9 |
model = "text-davinci-002"
|
10 |
|
11 |
+
def convert_code(code, language_in, language_out,):
|
12 |
"""
|
13 |
Convert the given code to the specified language using GPT-3.
|
14 |
"""
|
15 |
# Set the prompt to use as input to the model
|
16 |
+
prompt = f"Convert {language_in} code to {language_out} code:\n{code}"
|
17 |
|
18 |
# Call the GPT-3 API to generate text
|
19 |
response = openai.Completion.create(
|
|
|
32 |
# Create the Gradio app
|
33 |
app = gr.Interface(
|
34 |
fn=convert_code,
|
35 |
+
inputs=[gr.inputs.Textbox(lines=10, label="Code to convert"), gr.Radio(["Python", "R"], label="Source language"), gr.Radio(["Python", "R"], label="Output language")],
|
36 |
outputs=[gr.outputs.Textbox(label="Converted code")]
|
37 |
)
|
38 |
|