-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
It would be good if there were an easy way to stream strutured data. For example I have an application that generates SQL along with an explanation. I stream the explanation to the chat window while extracting the SQL to a coding window using this method:
@chat.transform_assistant_response
async def extract_sql(content: str, chunk: str, done: bool):
# When streaming is complete, extract SQL from code blocks
if done and content:
import re
# Look for SQL code blocks
sql_pattern = r"```sql\s*(.*?)```"
matches = re.findall(sql_pattern, content, re.DOTALL)
if matches:
# Take the first SQL block found
sql_code.set(matches[0].strip())
# Always return content as-is for streaming display
return content
Since this method is deprecated in favor of a chatlas solution, it would be good to have a documented method for streaming structured data.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels