Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,26 +7,27 @@ import time
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
|
| 10 |
-
def check_openai_speed(
|
| 11 |
|
| 12 |
start_time = time.time()
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
end_time = time.time()
|
| 23 |
response_time = end_time - start_time
|
| 24 |
print(f'Response time: {response_time:.2f} seconds')
|
| 25 |
-
print(f'Response status code: {response.status_code}')
|
| 26 |
-
print(f'Response text: {response.text}')
|
| 27 |
response_time = "Time to answer: " + f'{end_time - start_time:.2f}' + " seconds"
|
| 28 |
-
|
| 29 |
-
return status_code, response_time
|
| 30 |
|
| 31 |
title = "Status API ChatGPT"
|
| 32 |
css="""
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
|
| 10 |
+
def check_openai_speed():
|
| 11 |
|
| 12 |
start_time = time.time()
|
| 13 |
+
try:
|
| 14 |
+
response = openai.Completion.create(
|
| 15 |
+
model="text-davinci-003",
|
| 16 |
+
prompt="Say this is a test",
|
| 17 |
+
temperature=0,
|
| 18 |
+
max_tokens=7
|
| 19 |
+
)
|
| 20 |
+
except openai.api_errors.APIError as e:
|
| 21 |
+
print(f"Ошибка API: {e}")
|
| 22 |
+
return "Erorr" + e, "000"
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f"Общая ошибка: {e}")
|
| 25 |
+
return "Erorr" + e, "000"
|
| 26 |
end_time = time.time()
|
| 27 |
response_time = end_time - start_time
|
| 28 |
print(f'Response time: {response_time:.2f} seconds')
|
|
|
|
|
|
|
| 29 |
response_time = "Time to answer: " + f'{end_time - start_time:.2f}' + " seconds"
|
| 30 |
+
return "Ok", response_time
|
|
|
|
| 31 |
|
| 32 |
title = "Status API ChatGPT"
|
| 33 |
css="""
|