Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import config
|
|
2 |
import openai
|
3 |
|
4 |
openai.api_key = config.api_key
|
|
|
5 |
response = openai.Completion.create(
|
6 |
model="code-davinci-002",
|
7 |
prompt="##### Fix bugs in the below function\n \n### Buggy Python\nimport Random\na = random.randint(1,12)\nb = random.randint(1,12)\nfor i in range(10):\n question = \"What is \"+a+\" x \"+b+\"? \"\n answer = input(question)\n if answer = a*b\n print (Well done!)\n else:\n print(\"No.\")\n \n### Fixed Python",
|
@@ -13,4 +14,6 @@ openai.api_key = config.api_key
|
|
13 |
stop=["###"]
|
14 |
)
|
15 |
|
16 |
-
return response.choices
|
|
|
|
|
|
2 |
import openai
|
3 |
|
4 |
openai.api_key = config.api_key
|
5 |
+
def question(question):
|
6 |
response = openai.Completion.create(
|
7 |
model="code-davinci-002",
|
8 |
prompt="##### Fix bugs in the below function\n \n### Buggy Python\nimport Random\na = random.randint(1,12)\nb = random.randint(1,12)\nfor i in range(10):\n question = \"What is \"+a+\" x \"+b+\"? \"\n answer = input(question)\n if answer = a*b\n print (Well done!)\n else:\n print(\"No.\")\n \n### Fixed Python",
|
|
|
14 |
stop=["###"]
|
15 |
)
|
16 |
|
17 |
+
return response.choices[0].text
|
18 |
+
|
19 |
+
result = question()
|