Spaces:
Runtime error
Runtime error
Commit
·
dc3ff8d
1
Parent(s):
33fb99f
fixed unicode error
Browse files
app.py
CHANGED
@@ -3,16 +3,21 @@ import openai
|
|
3 |
import os
|
4 |
|
5 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
6 |
-
input_prompt = "Generate Pseudocode from given code snippet using the latex package algorithm and algpseudocode"+ "\n" + "Latex Code : \n" + "\" + usepackage{algorithm}\n" + "\" + usepackage{algpseudocode}\n"
|
7 |
def generate_latex(code):
|
8 |
response = openai.Completion.create(
|
9 |
-
model="
|
10 |
-
prompt= "
|
11 |
-
temperature=0,
|
12 |
-
top_p=
|
13 |
-
max_tokens=
|
14 |
)
|
15 |
-
return "\\usepackage{algorithm}\n\\usepackage{algpseudocode}
|
16 |
|
17 |
-
iface = gr.Interface(
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import os
|
4 |
|
5 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
6 |
def generate_latex(code):
|
7 |
response = openai.Completion.create(
|
8 |
+
model="text-davinci-003",
|
9 |
+
prompt= f"{code}\nGenerate Pseudocode from given code snippet using the latex packages algorithm and algpseudocode\nLatex Code : "
|
10 |
+
,temperature=0.5,
|
11 |
+
top_p=0.9,
|
12 |
+
max_tokens=200,
|
13 |
)
|
14 |
+
return "\\usepackage{algorithm}\n\\usepackage{algpseudocode}" + response['choices'][0]["text"]
|
15 |
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn = generate_latex,
|
18 |
+
inputs = "text",
|
19 |
+
outputs = "text",
|
20 |
+
title = "Generate LATEX code for psuedocode from any language",
|
21 |
+
description = "Enter your code snippet in any language and get the psuedocode in LATEX format, made by vinayakj02",
|
22 |
+
)
|
23 |
+
iface.launch()
|