Spaces:
Sleeping
Sleeping
handle streaming properly
Browse files- gemmademo/_model.py +2 -2
gemmademo/_model.py
CHANGED
|
@@ -129,16 +129,16 @@ class LlamaCppGemmaModel:
|
|
| 129 |
temperature=temperature,
|
| 130 |
stream=True,
|
| 131 |
)
|
|
|
|
| 132 |
|
| 133 |
outputs = ""
|
| 134 |
for chunk in response_stream:
|
| 135 |
delta = chunk["choices"][0]["delta"]
|
| 136 |
if "content" in delta:
|
| 137 |
outputs += delta["content"]
|
|
|
|
| 138 |
yield outputs
|
| 139 |
|
| 140 |
-
return outputs
|
| 141 |
-
|
| 142 |
def get_model_info(self) -> Dict:
|
| 143 |
"""
|
| 144 |
Return information about the model.
|
|
|
|
| 129 |
temperature=temperature,
|
| 130 |
stream=True,
|
| 131 |
)
|
| 132 |
+
self.messages.append({"role": "assistant", "content": ""})
|
| 133 |
|
| 134 |
outputs = ""
|
| 135 |
for chunk in response_stream:
|
| 136 |
delta = chunk["choices"][0]["delta"]
|
| 137 |
if "content" in delta:
|
| 138 |
outputs += delta["content"]
|
| 139 |
+
self.messages[-1]["content"] += delta["content"]
|
| 140 |
yield outputs
|
| 141 |
|
|
|
|
|
|
|
| 142 |
def get_model_info(self) -> Dict:
|
| 143 |
"""
|
| 144 |
Return information about the model.
|