Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,10 @@ import gradio as gr
|
|
| 4 |
import openai
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
openai.api_key = os.getenv('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')
|
| 9 |
|
| 10 |
-
|
| 11 |
# Code examples to illustrate the output
|
| 12 |
python_code_examples = """
|
| 13 |
---------------------
|
|
@@ -44,9 +44,9 @@ async def get_completion(code_snippet):
|
|
| 44 |
"""
|
| 45 |
|
| 46 |
try:
|
| 47 |
-
# Using the
|
| 48 |
-
response =
|
| 49 |
-
model="gpt-3.5-turbo",
|
| 50 |
messages=[{"role": "user", "content": prompt}],
|
| 51 |
max_tokens=500
|
| 52 |
)
|
|
|
|
| 4 |
import openai
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
# Ensure your OpenAI API key is set in environment variables
|
| 8 |
+
openai.api_key = os.getenv('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')
|
| 9 |
|
| 10 |
+
def get_completion(code_snippet):
|
| 11 |
# Code examples to illustrate the output
|
| 12 |
python_code_examples = """
|
| 13 |
---------------------
|
|
|
|
| 44 |
"""
|
| 45 |
|
| 46 |
try:
|
| 47 |
+
# Using the updated method for chat completion
|
| 48 |
+
response = openai.ChatCompletion.create(
|
| 49 |
+
model="gpt-3.5-turbo", # Specify the model name correctly
|
| 50 |
messages=[{"role": "user", "content": prompt}],
|
| 51 |
max_tokens=500
|
| 52 |
)
|