Commit
•
9cc847c
1
Parent(s):
3ce0cf6
Add code
Browse files
app.py
CHANGED
@@ -133,6 +133,16 @@ class OpenAIHandler(StreamHandler):
|
|
133 |
except StopIteration:
|
134 |
self._generator = self.generator()
|
135 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
def shutdown(self) -> None:
|
138 |
if self.connection:
|
@@ -140,6 +150,7 @@ class OpenAIHandler(StreamHandler):
|
|
140 |
self.quit.set()
|
141 |
if self.thread:
|
142 |
self.thread.join(timeout=5)
|
|
|
143 |
|
144 |
|
145 |
def update_chatbot(chatbot: list[dict], response: ResponseAudioTranscriptDoneEvent):
|
|
|
133 |
except StopIteration:
|
134 |
self._generator = self.generator()
|
135 |
return None
|
136 |
+
|
137 |
+
def reset_state(self):
|
138 |
+
"""Reset connection state for new recording session"""
|
139 |
+
self.connection = None
|
140 |
+
self.args_set.clear()
|
141 |
+
self.quit.clear()
|
142 |
+
self.connected.clear()
|
143 |
+
self.thread = None
|
144 |
+
self._generator = None
|
145 |
+
self.current_session = None
|
146 |
|
147 |
def shutdown(self) -> None:
|
148 |
if self.connection:
|
|
|
150 |
self.quit.set()
|
151 |
if self.thread:
|
152 |
self.thread.join(timeout=5)
|
153 |
+
self.reset_state()
|
154 |
|
155 |
|
156 |
def update_chatbot(chatbot: list[dict], response: ResponseAudioTranscriptDoneEvent):
|