transitive-bullshit / agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.
MIT License
16.07k stars 2.11k forks source link

Streaming a response from onProgress return duplicates #621

Closed Gerovinka closed 1 month ago

Gerovinka commented 9 months ago

Verify latest release

Verify webapp is working

Environment details

I'm doing a test AWS Lambda function in Node.js 18.x

Describe the Bug

I apologize, can you suggest how to solve my problem. I have added data streaming directly from your onProgress, but when I test how the function works, I sometimes get duplicate messages. My code looks like this: const res = await api.sendMessage(question, { systemMessage: role, onProgress: (partialResponse) => { responseText = partialResponse.text; responseStream.write(responseText); } }) During testing, I sometimes get duplicates of the following kind: "The Three of PentaclesThe Three of Pentacles suggestsThe Three of Pentacles suggests that"

Could you please advise me if I did the right thing to add the data return directly from your 'onProgress' or do I need to modify my code

transitive-bullshit commented 1 month ago

This project is undergoing a major revamp; closing out old issues as part of the prep process.

The chatgpt package is pretty outdated at this point. I recommend that you use the openai package or the openai-fetch package instead.