transitive-bullshit / agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.
https://agentic.so
MIT License
16.22k stars 2.12k forks source link

How can I create pre-prompts? #587

Closed cmastro closed 3 months ago

cmastro commented 1 year ago

Verify latest release

Verify webapp is working

Environment details

Describe the Bug

I have 100 arrays and I want to add them as pre-prompts.

Array example:

const data = [
    '{"Orador": "A", "Salon": "2", "Tema": "AA", "Horario": "12", "Text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}',
     '{"Orador": "B", "Salon": "1", "Tema": "BB", "Horario": "15", , "Text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}',
... x98
];

I'm trying to add it at the begining of the conversation with this code:

for (let i = 0; i < data.length; i++) {
response = await chatgpt.sendMessage(data[i], {
    timeoutMs: 5 * 60 * 1000,
    conversationId: convId,
    parentMessageId: response.id
});
console.log(response.text);
}

But I get the maximum context length tokens error: This model's maximum context length is 4097 tokens. However, you requested 4159 tokens (2159 in the messages, 2000 in the completion). Please reduce the length of the messages or completion.

Is there a way to send big prompts to ChatGPT?

Thanks!

transitive-bullshit commented 3 months 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.