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

Instead of sending a new Message, appended to last message. #628

Closed FujiwaraChoki closed 8 months ago

FujiwaraChoki commented 8 months ago

Verify latest release

Verify webapp is working

Environment details

Next.js + ChakraUI, Windows, Node.js v20.8.0, Latest Windows Version (11)

Describe the Bug

When I send multiple messages using ChatGPTUnofficialProxyAPI, it justs appends my new prompt to the latest message, how do I fix this?

Code:

const sendFirstMessage = async () => {
    const response = await api.sendMessage("...");

    return {
        conversationId: response.conversationId,
        parentMessageId: response.parentMessageId,
    };
};

const refinedPrompt = ""; // This is the new prompt, instead of sending a new message, it appends to firstMessage

if (chat.messages.length === 0) {
    const firstMessage = await sendFirstMessage();
    gptResponse = await api.sendMessage(refinedPrompt, {
        conversationId: firstMessage.conversationId,
        parentMessageId: firstMessage.parentMessageId,
    });
} else {
    gptResponse = await api.sendMessage(refinedPrompt, {
        conversationId: chat.messages[chat.messages.length - 1].conversationId,
        parentMessageId: chat.messages[chat.messages.length - 1].parentMessageId,
    });
}
FujiwaraChoki commented 8 months ago

Turns out I should've set parentMessageId to the message Id, not IT'S parent message...

Silly.