Commit ยท
a18c696
1
Parent(s): 40c0d69
Upload blubeAPI.py
Browse files- blubeAPI.py +6 -13
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]
|
|
@@ -73,7 +73,7 @@ def runbot():
|
|
| 73 |
thread = client.beta.threads.create()
|
| 74 |
print("(3/3) Finished creating thread, launching interface...\n")
|
| 75 |
|
| 76 |
-
iface.launch(share=
|
| 77 |
def getAssistant():
|
| 78 |
return my_assistant
|
| 79 |
def getPersona():
|
|
@@ -138,13 +138,7 @@ def chatbot(input_text):
|
|
| 138 |
t = 0
|
| 139 |
if ttime > 20:
|
| 140 |
print("\n\n\nTAKEN OVER 20 SECONDS, RESTARTING PROCESS\n\n\n")
|
| 141 |
-
|
| 142 |
-
thread_id=thread.id,
|
| 143 |
-
run_id=run.id
|
| 144 |
-
)
|
| 145 |
-
client.beta.threads.delete(thread.id)
|
| 146 |
-
iface.close()
|
| 147 |
-
runbot()
|
| 148 |
if errorCode == 1:
|
| 149 |
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")
|
| 150 |
time.sleep(20)
|
|
@@ -174,5 +168,4 @@ def chatbot(input_text):
|
|
| 174 |
etime = time.time()
|
| 175 |
ttime = etime - stime
|
| 176 |
print(f"Finished in {ttime} seconds.")
|
| 177 |
-
return finalMsg
|
| 178 |
-
|
|
|
|
| 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]
|
|
|
|
| 73 |
thread = client.beta.threads.create()
|
| 74 |
print("(3/3) Finished creating thread, launching interface...\n")
|
| 75 |
|
| 76 |
+
iface.launch(share=True)
|
| 77 |
def getAssistant():
|
| 78 |
return my_assistant
|
| 79 |
def getPersona():
|
|
|
|
| 138 |
t = 0
|
| 139 |
if ttime > 20:
|
| 140 |
print("\n\n\nTAKEN OVER 20 SECONDS, RESTARTING PROCESS\n\n\n")
|
| 141 |
+
chatbot(input_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
if errorCode == 1:
|
| 143 |
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")
|
| 144 |
time.sleep(20)
|
|
|
|
| 168 |
etime = time.time()
|
| 169 |
ttime = etime - stime
|
| 170 |
print(f"Finished in {ttime} seconds.")
|
| 171 |
+
return finalMsg
|
|
|