camillelacan1 commited on
Commit
043af13
·
1 Parent(s): 2d4cb27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -8,13 +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, from_lang, to_lang):
12
  """
13
- Convert the given code from the specified source language to the
14
- specified target language using GPT-3.
15
  """
16
  # Set the prompt to use as input to the model
17
- prompt = f"Convert {from_lang} code to {to_lang} code:\n{code}"
18
 
19
  # Call the GPT-3 API to generate text
20
  response = openai.Completion.create(
@@ -34,5 +33,7 @@ def convert_code(code, from_lang, to_lang):
34
  app = gr.Interface(
35
  fn=convert_code,
36
  inputs=gr.inputs.Textbox(lines=10, label="Code to convert"),
 
37
  outputs=gr.outputs.Textbox(label="Converted code"))
 
38
  app.launch()
 
8
  # Set the model to use (e.g. "text-davinci-002")
9
  model = "text-davinci-002"
10
 
11
+ def convert_code(code, language):
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} code to R code:\n{code}"
17
 
18
  # Call the GPT-3 API to generate text
19
  response = openai.Completion.create(
 
33
  app = gr.Interface(
34
  fn=convert_code,
35
  inputs=gr.inputs.Textbox(lines=10, label="Code to convert"),
36
+ controls=gr.controls.Radio(["Python", "R"], label="Source language"),
37
  outputs=gr.outputs.Textbox(label="Converted code"))
38
+
39
  app.launch()