Spaces:
Runtime error
Runtime error
vinayakj02
commited on
Commit
•
00cd123
1
Parent(s):
837476c
made base files
Browse files- app.py +18 -0
- packages.txt +0 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
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="code-davinci-002",
|
10 |
+
prompt= "```" + input_prompt + "```" + code ,
|
11 |
+
temperature=0,
|
12 |
+
top_p=1,
|
13 |
+
max_tokens=1500,
|
14 |
+
)
|
15 |
+
return "\usepackage{algorithm}\n\usepackage{algpseudocode}\n" + response['choices'][0]["text"]
|
16 |
+
|
17 |
+
iface = gr.Interface(fn=generate_latex, inputs="text", outputs="text")
|
18 |
+
iface.launch()
|
packages.txt
ADDED
File without changes
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
openai
|
2 |
+
gradio
|