metropolitan-bronze
metropolitan-bronzeβ€’17mo ago

API Memory

Hey, im using stack ai api as an llm for my voiceflow chatbot, everything is ok, but it cant answer questions, according to previous messages, because llm takes every question as a separate. I'll give an example: -How much do your services cost?(customer) - it costs x amount (llm) - what does it include?(customer) - sorry, i dont know this information (llm) Llm cant answer to it, cause this question makes no logic, as a separate one, so are there any possible variants to make stack llm through api remember what was said in the previous messages?
9 Replies
W. Williams (SFT)
W. Williams (SFT)β€’17mo ago
Why are you using Stack AI? You get the same services through VF. Plus, it is like 10x faster.
xenial-black
xenial-blackβ€’17mo ago
Yup, on stack AI, you can pass in another key-value pair in the JSON. Next to in-0 you can pass user_id which you should pass a unique ID to for the session the user is having As long as you also enable memory in the LLM step on stack, the user_id will be used as the unique identifier for the memory What we do is we have a JS function in the beginning of the flow (it's the first thing that happens) and set's a randomized UUID to a variable, and we pass that in for every API call to stack we do. Every new session (when you get to the start block) it will generate a new one πŸ™‚ We also use Stack. Basically VF is our frontend tool, stack backend
typical-coral
typical-coralβ€’17mo ago
Are there any major advantages or its simply preference?
xenial-black
xenial-blackβ€’17mo ago
A couple more options come natively within stack (like using different knowledge base options) though mostly a bit more control over everything. But VF is the best for being able to map out dialogue so we use both for optimal control over everything πŸ™‚
metropolitan-bronze
metropolitan-bronzeOPβ€’17mo ago
Thanks a lotπŸ™ ! If you dont mind, can you share some screenshots of how to do it, cause im not good at coding πŸ˜…
xenial-black
xenial-blackβ€’17mo ago
The code for creating a random UUID
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}

unique_session_id = uuidv4()
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}

unique_session_id = uuidv4()
Make sure to have a variable in Voiceflow called unique_session_id Then when making an API call to stack, set a user_id key value pair in the JSON object with that new variable as the value
xenial-black
xenial-blackβ€’17mo ago
No description
metropolitan-bronze
metropolitan-bronzeOPβ€’17mo ago
Its working. Thought code would be more complicated tbh) Thanks again!!!
xenial-black
xenial-blackβ€’17mo ago
No worries πŸ™‚

Did you find this page helpful?