Commit ยท
c8b5877
1
Parent(s): 3158dba
Fixed it
Browse files- blubeAPI.py +8 -4
blubeAPI.py
CHANGED
|
@@ -11,9 +11,9 @@ from openai import OpenAI
|
|
| 11 |
import os
|
| 12 |
import time
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
)
|
| 17 |
|
| 18 |
def findOccurrences(s, ch):
|
| 19 |
return [i for i, letter in enumerate(s) if letter == ch]
|
|
@@ -72,7 +72,7 @@ def runbot():
|
|
| 72 |
thread = client.beta.threads.create()
|
| 73 |
print("(3/3) Finished creating thread, launching interface...\n")
|
| 74 |
|
| 75 |
-
iface.launch(share=
|
| 76 |
def getAssistant():
|
| 77 |
return my_assistant
|
| 78 |
def getPersona():
|
|
@@ -114,6 +114,7 @@ def chatbot(input_text):
|
|
| 114 |
tt = 0
|
| 115 |
errorCode = 0
|
| 116 |
while run.status != "completed":
|
|
|
|
| 117 |
run = client.beta.threads.runs.retrieve(
|
| 118 |
thread_id=thread.id, run_id=run.id
|
| 119 |
)
|
|
@@ -134,6 +135,9 @@ def chatbot(input_text):
|
|
| 134 |
if t > 15:
|
| 135 |
print(f"Time taken is over 15 ticks, average time is 11, check issues.\n\nINFO: Status is {s} and the total ticks is {tt}")
|
| 136 |
t = 0
|
|
|
|
|
|
|
|
|
|
| 137 |
if errorCode == 1:
|
| 138 |
raise RuntimeError("\n\nThe process finished with an error: Process failed unexpectedly. Check the command prompt for more details. This error is most likely a overuse error, so the program will sleep for 20 seconds to avoid more errors\n\n")
|
| 139 |
time.sleep(20)
|
|
|
|
| 11 |
import os
|
| 12 |
import time
|
| 13 |
|
| 14 |
+
os.environ["OPENAI_API_KEY"] = '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'
|
| 15 |
+
|
| 16 |
+
client = OpenAI()
|
| 17 |
|
| 18 |
def findOccurrences(s, ch):
|
| 19 |
return [i for i, letter in enumerate(s) if letter == ch]
|
|
|
|
| 72 |
thread = client.beta.threads.create()
|
| 73 |
print("(3/3) Finished creating thread, launching interface...\n")
|
| 74 |
|
| 75 |
+
iface.launch(share=True)
|
| 76 |
def getAssistant():
|
| 77 |
return my_assistant
|
| 78 |
def getPersona():
|
|
|
|
| 114 |
tt = 0
|
| 115 |
errorCode = 0
|
| 116 |
while run.status != "completed":
|
| 117 |
+
ttime = time.time() - stime
|
| 118 |
run = client.beta.threads.runs.retrieve(
|
| 119 |
thread_id=thread.id, run_id=run.id
|
| 120 |
)
|
|
|
|
| 135 |
if t > 15:
|
| 136 |
print(f"Time taken is over 15 ticks, average time is 11, check issues.\n\nINFO: Status is {s} and the total ticks is {tt}")
|
| 137 |
t = 0
|
| 138 |
+
if ttime > 20:
|
| 139 |
+
print("\n\n\nTAKEN OVER 20 SECONDS, RESTARTING PROCESS\n\n\n")
|
| 140 |
+
chatbot(input_text)
|
| 141 |
if errorCode == 1:
|
| 142 |
raise RuntimeError("\n\nThe process finished with an error: Process failed unexpectedly. Check the command prompt for more details. This error is most likely a overuse error, so the program will sleep for 20 seconds to avoid more errors\n\n")
|
| 143 |
time.sleep(20)
|