LSL Script to Initialize Conversation in Our LLM AI systems
When our OpenAI-like-API AI systems like our Private LLM System are fully reset (gptclear function), the pre-existing conversation is completely cleared out. This turns out to be bad for certain chat completion LLMs (Mistral API in particular), which throw an error until the conversation goes a certain depth (up to 14 prompt-response pairs).
So I wrote a small script that responds to a gptclear event and then resets the conversation to something innocuous but non-blank. The code as written just provides "hello" as both input and output for prior conversation, but you could set it to anything you want - which could be nice for starting the conversation off with a pre-existing conversation that sets tone, mood, etc. I have not experimented with it but it might be able to provide long-term memories for some LLMs as well!
Just put this code into a script in the prim with the AI system (which contains the gptconnect scripts) and hit gptclear. Pretty simple, when the command comes there is a short delay, then the thing resets linkset data according to the prompt and response strings in the function linksetconvinit(). Just change the "hello" strings to what you want, let me know how it goes.
linksetconvinit()
{ llLinksetDataWrite("gprompt1","hello"); llLinksetDataWrite("answer1","hello");
llLinksetDataWrite("gprompt2","hello"); llLinksetDataWrite("answer2","hello");
llLinksetDataWrite("gprompt3","hello"); llLinksetDataWrite("answer3","hello");
llLinksetDataWrite("gprompt4","hello"); llLinksetDataWrite("answer4","hello");
llLinksetDataWrite("gprompt5","hello"); llLinksetDataWrite("answer5","hello");
llLinksetDataWrite("gprompt6","hello"); llLinksetDataWrite("answer6","hello");
llLinksetDataWrite("gprompt7","hello"); llLinksetDataWrite("answer7","hello");
llLinksetDataWrite("gprompt8","hello"); llLinksetDataWrite("answer8","hello");
llLinksetDataWrite("gprompt9","hello"); llLinksetDataWrite("answer9","hello");
llLinksetDataWrite("gprompt10","hello"); llLinksetDataWrite("answer10","hello");
llLinksetDataWrite("gprompt11","hello"); llLinksetDataWrite("answer11","hello");
llLinksetDataWrite("gprompt12","hello"); llLinksetDataWrite("answer12","hello");
llLinksetDataWrite("gprompt13","hello"); llLinksetDataWrite("answer13","hello");
llLinksetDataWrite("gprompt14","hello"); llLinksetDataWrite("answer14","hello");
}
default
{
state_entry()
{ linksetconvinit();
}
link_message(integer l, integer n, string t, key id)
{ if(n == -2000 && t == "gptclear")
{ llSleep(2.); // time for the usual clear to exec
llOwnerSay("mistral-compatible conversation initialization");
linksetconvinit(); // mistral-compatible initialization
}
}
}
This picture of Sarah and her friend is just for fun - you can follow their exploits
.png.jpg)
Comments
Post a Comment