Spaces:
Runtime error
Runtime error
Commit
·
a95c496
1
Parent(s):
313a72e
Update app.py
Browse files
app.py
CHANGED
@@ -5,15 +5,15 @@ import openai
|
|
5 |
openai.api_key = "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"
|
6 |
|
7 |
# Define the code generation function
|
8 |
-
def code_generation(
|
9 |
# Set the model name and parameters
|
10 |
-
model = "
|
11 |
max_tokens = 100
|
12 |
|
13 |
-
# Generate code using the model
|
14 |
response = openai.Completion.create(
|
15 |
-
engine="
|
16 |
-
prompt=
|
17 |
max_tokens=max_tokens,
|
18 |
temperature=0.7,
|
19 |
top_p=1.0,
|
@@ -32,13 +32,16 @@ iface = gr.Interface(
|
|
32 |
fn=code_generation,
|
33 |
inputs="text",
|
34 |
outputs="text",
|
35 |
-
title="Code
|
36 |
-
description="
|
37 |
examples=[
|
38 |
-
["
|
39 |
-
["
|
40 |
],
|
41 |
-
|
|
|
|
|
|
|
42 |
)
|
43 |
|
44 |
# Run the Gradio interface
|
|
|
5 |
openai.api_key = "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"
|
6 |
|
7 |
# Define the code generation function
|
8 |
+
def code_generation(code):
|
9 |
# Set the model name and parameters
|
10 |
+
model = "openai-codex"
|
11 |
max_tokens = 100
|
12 |
|
13 |
+
# Generate code suggestions using the model
|
14 |
response = openai.Completion.create(
|
15 |
+
engine="davinci-codex",
|
16 |
+
prompt=code,
|
17 |
max_tokens=max_tokens,
|
18 |
temperature=0.7,
|
19 |
top_p=1.0,
|
|
|
32 |
fn=code_generation,
|
33 |
inputs="text",
|
34 |
outputs="text",
|
35 |
+
title="Code Writing and Debugging",
|
36 |
+
description="Write code and get code suggestions.",
|
37 |
examples=[
|
38 |
+
["for i in range(10):", "\tprint(i)"],
|
39 |
+
["def factorial(n):", "\tif n == 0:", "\t\treturn 1", "\telse:", "\t\treturn n * factorial(n-1)"]
|
40 |
],
|
41 |
+
allow_flagging=False,
|
42 |
+
layout="vertical",
|
43 |
+
theme="compact",
|
44 |
+
live=True,
|
45 |
)
|
46 |
|
47 |
# Run the Gradio interface
|