Skip to content

[JS] Please throw error on function calling #810

@zerolethanh

Description

@zerolethanh

Describe the bug
Screenshot 2024-08-22 at 13 59 01

To Reproduce

        try {
            let r;
            if (streamingCallback) {
                const {response, stream} = await generateStream(
                    generateOptions
                )
                for await (const chunk of stream()) {
                    const fContent = chunk.content
                    const buildChunk = {
                        name: undefined,
                        done: false,
                        result: {
                            response: fContent.at(-1)
                        }
                    }
                    console.log("-🤖- ", JSON.stringify(buildChunk), "\n")
                    streamingCallback(buildChunk)
                }
                r = await response()
            } else {
                r = await generate(generateOptions)
            }

            return r.toJSON()

        } catch (e) {
            return {
                error: (e as Error).message
            }
        }

Expected behavior

  • try catch can be catch error normally

Runtime:

  • OS: MacOS
  • Version: 15.0 Beta (24A5327a)

** Node version **
v20.13.1


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjs

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions