Spaces:
Running
Running
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -57,14 +57,17 @@ def respond(
|
|
57 |
for chunk in response.iter_content(chunk_size=None):
|
58 |
if chunk:
|
59 |
chunk_data = chunk.decode('utf-8')
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
68 |
|
69 |
theme = "Nymbo/Nymbo_Theme"
|
70 |
|
@@ -81,4 +84,4 @@ demo = gr.ChatInterface(
|
|
81 |
)
|
82 |
|
83 |
if __name__ == "__main__":
|
84 |
-
demo.queue().launch(max_threads=20)
|
|
|
57 |
for chunk in response.iter_content(chunk_size=None):
|
58 |
if chunk:
|
59 |
chunk_data = chunk.decode('utf-8')
|
60 |
+
try:
|
61 |
+
response_json = json.loads(chunk_data)
|
62 |
+
# content ์์ญ๋ง ์ถ๋ ฅ
|
63 |
+
if "choices" in response_json:
|
64 |
+
content = response_json["choices"][0]["message"]["content"]
|
65 |
+
response_text = content
|
66 |
+
# ๋ง์ง๋ง ๋ํ์ ๋ชจ๋ธ์ ์๋ต์ ์ถ๊ฐํ์ฌ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅ
|
67 |
+
memory[-1] = (message, response_text)
|
68 |
+
yield content
|
69 |
+
except json.JSONDecodeError:
|
70 |
+
continue # ์ ํจํ์ง ์์ JSON์ด ์์ ๊ฒฝ์ฐ ๋ฌด์ํ๊ณ ๋ค์ ์ฒญํฌ๋ก ๋์ด๊ฐ
|
71 |
|
72 |
theme = "Nymbo/Nymbo_Theme"
|
73 |
|
|
|
84 |
)
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
+
demo.queue().launch(max_threads=20)
|