Skip to content

truncated openai_stream_parse(x=) : .p() must return a single TRUE or FALSE, not NA #63

@romainfrancois

Description

@romainfrancois
> chattr::chattr_use("gpt35")

── chattr 
• Provider: Open AI - Chat Completions
• Path/URL: https://api.openai.com/v1/chat/completions
• Model: gpt-3.5-turbo

> chattr::chattr("Can you write a poem about the R package called 'golem'. Please add a bunch of emojis.")
Sure! Here's a poem about the R package 'golem' with a bunch of emojis:

Error in `discard()`:
ℹ In index: 1.
Caused by error:
! `.p()` must return a single `TRUE` or `FALSE`, not `NA`.
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: In strsplit(., "data: ") :
  unable to translate 'data: {"id":"chatcmpl-8nsIIxlfPHfY8BhhuUu7NFsIO57AC","object":"chat.completion.chunk","created":1706897470,"model":"gpt-3.5-turbo-0613","system_fingerprint":null,"choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_re...' to a wide string
2: In strsplit(., "data: ") : input string 1 is invalid

If that helps, it seems that the openai_stream_parse(x=) is truncated somehow, sometimes:

> trace(chattr:::openai_stream_parse, quote(writeLines(x)))
> chattr::chattr("Can you write a poem about the R package called 'golem'. Please add a bunch of emojis.")
[...] 

data: {"id":"chatcmpl-8nsMS2ruQe1SpEDxQLFh07sNOXlQB","object":"chat.completion.chunk","created":1706897728,"model":"gpt-3.5-turbo-0613","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":":\n\n"},"logprobs":null,"finish_reason":null}]}

data: {"id":"chatcmpl-8nsMS2ruQe1SpEDxQLFh07sNOXlQB","object":"chat.completion.chunk","created":1706897728,"model":"gpt-3.5-turbo-0613","system_fingerprint":null,"choices":[{"index":0,"delta":{"content":"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions