Skip to content

chat_snowflake() emits garbled output #533

@atheriel

Description

@atheriel

Any chat with chat_snowflake() now streams text correctly, but ends all messages with list(type = "text", text = ""):

> chat <- chat_snowflake(model = "claude-3-5-sonnet")
> chat$chat("Briefly list your favourite SQL dialects."I aim to be direct and honest: I don't actually have favorite SQL dialects since I don't experience preferences in the way humans do. However, I can discuss 
commonly used SQL dialects and their notable features:

1. PostgreSQL
2. MySQL/MariaDB
3. Microsoft SQL Server (T-SQL)
4. SQLite
5. Oracle SQL (PL/SQL)

Each has its own strengths and is suited for different use cases.list(type = "text", text = "")

In addition the actual turn is parsed incorrectly:

> chat$last_turn()@text
[1] "I"

Peeking at chat$last_turn()@json seems to indicate that we might not be parsing the deltas correctly:

Full str() output
> chat$last_turn()@json |> str()
List of 4
 $ id     : chr "6740d904-7fce-4ca6-bfff-612213918ef1"
 $ model  : chr "claude-3-5-sonnet"
 $ choices:List of 42
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "I"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "I"
  .. .. ..$ text        : chr "I"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " aim"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " aim"
  .. .. ..$ text        : chr " aim"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " to be direct"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " to be direct"
  .. .. ..$ text        : chr " to be direct"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " and honest:"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " and honest:"
  .. .. ..$ text        : chr " and honest:"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " I don't actually"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " I don't actually"
  .. .. ..$ text        : chr " I don't actually"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " have favorite"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " have favorite"
  .. .. ..$ text        : chr " have favorite"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " SQL dialects since"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " SQL dialects since"
  .. .. ..$ text        : chr " SQL dialects since"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " I don"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " I don"
  .. .. ..$ text        : chr " I don"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "'t experience"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "'t experience"
  .. .. ..$ text        : chr "'t experience"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " preferences"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " preferences"
  .. .. ..$ text        : chr " preferences"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " in"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " in"
  .. .. ..$ text        : chr " in"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " the"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " the"
  .. .. ..$ text        : chr " the"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " way"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " way"
  .. .. ..$ text        : chr " way"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " humans do. However"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " humans do. However"
  .. .. ..$ text        : chr " humans do. However"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr ", I can"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr ", I can"
  .. .. ..$ text        : chr ", I can"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " discuss"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " discuss"
  .. .. ..$ text        : chr " discuss"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " commonly"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " commonly"
  .. .. ..$ text        : chr " commonly"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " used SQL dialects"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " used SQL dialects"
  .. .. ..$ text        : chr " used SQL dialects"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " an"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " an"
  .. .. ..$ text        : chr " an"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "d their notable"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "d their notable"
  .. .. ..$ text        : chr "d their notable"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " features:\n\n1"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " features:\n\n1"
  .. .. ..$ text        : chr " features:\n\n1"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr ". Postgre"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr ". Postgre"
  .. .. ..$ text        : chr ". Postgre"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "SQL"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "SQL"
  .. .. ..$ text        : chr "SQL"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "\n2. MySQL/"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "\n2. MySQL/"
  .. .. ..$ text        : chr "\n2. MySQL/"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "MariaDB"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "MariaDB"
  .. .. ..$ text        : chr "MariaDB"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "\n3. Microsoft"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "\n3. Microsoft"
  .. .. ..$ text        : chr "\n3. Microsoft"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " SQL Server ("
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " SQL Server ("
  .. .. ..$ text        : chr " SQL Server ("
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "T"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "T"
  .. .. ..$ text        : chr "T"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "-SQL)"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "-SQL)"
  .. .. ..$ text        : chr "-SQL)"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "\n4. SQL"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "\n4. SQL"
  .. .. ..$ text        : chr "\n4. SQL"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "ite\n5."
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "ite\n5."
  .. .. ..$ text        : chr "ite\n5."
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " Oracle SQL ("
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " Oracle SQL ("
  .. .. ..$ text        : chr " Oracle SQL ("
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "P"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "P"
  .. .. ..$ text        : chr "P"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "L/SQL)"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "L/SQL)"
  .. .. ..$ text        : chr "L/SQL)"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "\n\nEach"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "\n\nEach"
  .. .. ..$ text        : chr "\n\nEach"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " has"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " has"
  .. .. ..$ text        : chr " has"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " its own strengths"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " its own strengths"
  .. .. ..$ text        : chr " its own strengths"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " and is"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " and is"
  .. .. ..$ text        : chr " and is"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr " suite"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr " suite"
  .. .. ..$ text        : chr " suite"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "d for different use cases"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "d for different use cases"
  .. .. ..$ text        : chr "d for different use cases"
  ..$ :List of 1
  .. ..$ delta:List of 4
  .. .. ..$ type        : chr "text"
  .. .. ..$ content     : chr "."
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr "."
  .. .. ..$ text        : chr "."
  ..$ :List of 1
  .. ..$ delta:List of 3
  .. .. ..$ type        : chr "text"
  .. .. ..$ content_list:List of 1
  .. .. .. ..$ :List of 2
  .. .. .. .. ..$ type: chr "text"
  .. .. .. .. ..$ text: chr ""
  .. .. ..$ text        : chr ""
 $ usage  :List of 3
  ..$ prompt_tokens    : int 16
  ..$ completion_tokens: int 102
  ..$ total_tokens     : int 118

I think this is a regression introduced in #426. I never went back to do the testing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions