ChatGPT/API/LSL/chat-gpt-integration_v2
をテンプレートにして作成
[
トップ
] [
タイトル一覧
|
ページ一覧
|
新規
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
- chat-gpt-integration v2.13- for OpenSim
<pre>
// OpenAI's ChatGPT integration for LSL
// Written by PanteraPolnocy, March 2023
// Version 2.13
// You're responsible for how your OpenAI account will be...
// Set script to "everyone" or "same group" on your own r...
// https://platform.openai.com/docs/usage-policies
// https://openai.com/pricing
// Place your API key here
// https://platform.openai.com/account/api-keys
string gChatGptApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
// ----------------------------------
// Defaults, do NOT change them here - use the dialog men...
string gListenMode = "Owner";
string gAnswerIn = "Nearby chat";
integer gEnabled = FALSE;
integer gHovertext = TRUE;
integer gSimpleAnswers = FALSE;
integer gHistoryEnabled = FALSE;
integer gPrefixMode = FALSE;
// Models database; First one is default
list gOpenAiModels = [
"ModelName", "3.5 Turbo",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-3.5-turbo",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "GPT-4 Turbo",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-4-turbo",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "GPT-4",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-4",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "GPT-4 Omni",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-4o",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "DALL-E 2",
"Endpoint", "/v1/images/generations",
"Items", 3,
"model", "dall-e-2",
"n", 1,
"size", "1024x1024",
"ModelName", "DALL-E 3",
"Endpoint", "/v1/images/generations",
"Items", 3,
"model", "dall-e-3",
"n", 1,
"size", "1024x1024"
];
// Personalities database; First one is default
list gPersonalities = [
"Assistant",
"a friendly assistant, as helpful as possible",
"default personality",
"Data",
"the android Data from Star Trek (use tone, manner, v...
"android from Star Trek, logical",
"Picard",
"the Captain Jean-Luc Picard from Star Trek (use tone...
"captain from Star Trek, strong leader",
"JARVIS",
"the J.A.R.V.I.S. AI from Marvel (use tone, manner, v...
"AI from Marvel, polite",
"Napoleon",
"the historical character Napoleon Bonaparte (use ton...
"military conquests, strategic thinking",
"Einstein",
"the historical character Albert Einstein (use tone, ...
"contributions to physics",
"Socrates",
"the historical character Socrates (use tone, manner,...
"philosopher, critical thinking",
"Shakespeare",
"the historical character William Shakespeare (use to...
"renowned playwright",
"Monroe",
"the historical character Marilyn Monroe (use tone, m...
"iconic actress",
"Curie",
"the historical character Marie Curie (use tone, mann...
"Marie Curie, a scientist",
"Elvis",
"the historical character Elvis Presley (use tone, ma...
"beloved musician",
"Freud",
"the historical character Sigmund Freud (use tone, ma...
"psychologist"
];
// Set in runtime
integer gScriptReady;
integer gListenHandle;
integer gDialogChannel;
integer gDialogHandle;
integer gManagingBlocks;
integer gChatIsLocked;
integer gPrefixLength;
string gPersonalityLabels;
string gCurrentPersonality;
string gCurrentPersonalityName;
string gCurrentEndpoint;
string gCurrentModelName;
list gCurrentModelData;
list gModelsList;
list gPersonalitiesList;
list gHistoryRecords;
key gAnswerToAvatar;
key gHTTPRequestId;
key gOwnerKey;
// Functions
setListener()
{
key listenKey = NULL_KEY;
if (gListenMode == "Owner")
{
listenKey = gOwnerKey;
}
gListenHandle = llListen(PUBLIC_CHANNEL, "", listenKe...
llListenControl(gListenHandle, gEnabled);
llSetText(gCurrentPersonalityName + " (" + gCurrentMo...
}
setModel(string modelName)
{
integer modelPosition = llListFindList(gOpenAiModels,...
gCurrentEndpoint = llList2String(gOpenAiModels, model...
gCurrentModelData = llList2List(gOpenAiModels, modelP...
gCurrentModelName = modelName;
gPrefixLength = llStringLength(modelName) + 1;
llOwnerSay("Model selected: " + modelName);
}
setPersonality(string personalityName)
{
integer personalityPosition = llListFindList(gPersona...
gCurrentPersonality = llList2String(gPersonalities, p...
gCurrentPersonalityName = personalityName;
llOwnerSay("Current personality: " + personalityName);
}
startDialog(key id, string text, list buttons)
{
gDialogHandle = llListen(gDialogChannel, "", id, "");
llDialog(id, "\n" + text, buttons, gDialogChannel);
llSetTimerEvent(90);
}
stopDialog()
{
llSetTimerEvent(0);
llListenRemove(gDialogHandle);
}
refreshState(key id, string message)
{
setListener();
llOwnerSay(message);
openMainMenu(id);
}
setChatLock(integer enable)
{
gChatIsLocked = enable;
if (enable)
{
// Chat lock timeout (10 seconds)
llSensorRepeat("cake is a lie", NULL_KEY, AGENT_B...
}
else
{
llSensorRemove();
}
}
addToHistory(string role, string message)
{
if (gCurrentModelName == "GPT-4" || gCurrentModelName...
{
if (!gHistoryEnabled)
{
gHistoryRecords = [];
}
gHistoryRecords = gHistoryRecords + llList2Json(J...
message = "";
integer historyLength = llGetListLength(gHistoryR...
if (historyLength > 10)
{
gHistoryRecords = llList2List(gHistoryRecords...
}
}
}
openMainMenu(key person)
{
gManagingBlocks = 0;
startDialog(person,
"Current state: " + llList2String(["DISABLED", "E...
"\nCurrent personality: " + gCurrentPersonalityNa...
"\nCurrent model: " + gCurrentModelName +
"\nSimple answers: " + llList2String(["DISABLED",...
"\nPrefix mode: " + llList2String(["DISABLED", "E...
"\nHistory: " + llList2String(["DISABLED", "ENABL...
"\nListen to: " + gListenMode +
"\nAnswer in: " + gAnswerIn,
["Simple mode", "History", "Hovertext", "Prefix m...
);
}
answerUser(string theMessage)
{
if (gAnswerIn == "Nearby chat")
{
llSay(0, theMessage);
}
else
{
llRegionSayTo(gAnswerToAvatar, 0, theMessage);
}
}
// Script body
default
{
state_entry()
{
llOwnerSay("Starting up...");
gOwnerKey = llGetOwner();
gDialogChannel = (integer)(llFrand(-10000000)-100...
integer listLength = llGetListLength(gOpenAiModel...
integer i;
while (i < listLength)
{
string currentItem = llList2String(gOpenAiMod...
if (currentItem == "ModelName")
{
gModelsList = gModelsList + llList2String...
}
++i;
}
gPersonalitiesList = llList2ListStrided(gPersonal...
listLength = llGetListLength(gPersonalities);
i = 0;
while (i < listLength)
{
gPersonalityLabels = gPersonalityLabels + llL...
i = i + 3;
}
integer memoryLimit = llGetMemoryLimit();
if (memoryLimit <= 16384)
{
llOwnerSay("FATAL ERROR: You are currently us...
}
else
{
setPersonality(llList2String(gPersonalitiesLi...
setModel(llList2String(gModelsList, 0));
stopDialog();
setListener();
setChatLock(FALSE);
llOwnerSay("Ready. Touch me to adjust options...
gScriptReady = TRUE;
}
}
touch_start(integer nd)
{
key toucherKey = llDetectedKey(0);
if (toucherKey == gOwnerKey && gScriptReady)
{
openMainMenu(toucherKey);
}
}
listen(integer channel, string name, key id, string m...
{
if (channel == gDialogChannel)
{
if (gManagingBlocks)
{
message = llStringTrim(message, STRING_TR...
if ((key)message)
{
/*
if (gManagingBlocks == 1)
{
llOwnerSay("Addition request has ...
//llLinksetDataWrite("gptblock:" ...
}
else
{
llOwnerSay("Removal request has b...
//llLinksetDataDelete("gptblock:"...
}
*/
}
else
{
llOwnerSay("The UUID '" + message + "...
}
openMainMenu(id);
}
else if (message == "ON / OFF")
{
gEnabled = !gEnabled;
refreshState(id, "Listener " + llList2Str...
}
else if (message == "Hovertext")
{
gHovertext = !gHovertext;
refreshState(id, "Hovertext " + llList2St...
}
else if (message == "Simple mode")
{
gSimpleAnswers = !gSimpleAnswers;
refreshState(id, "Simple answers mode " +...
}
else if (message == "History")
{
gHistoryEnabled = !gHistoryEnabled;
refreshState(id, "History is now " + llLi...
}
else if (message == "Prefix mode")
{
gPrefixMode = !gPrefixMode;
refreshState(id, "Prefix mode is now " + ...
}
else if (message == "Owner" || message == "Sa...
{
gListenMode = message;
refreshState(id, "Listen mode set to: " +...
}
else if (message == "Nearby chat" || message ...
{
gAnswerIn = message;
refreshState(id, "Answering in: " + messa...
}
else if (message == "Personality")
{
startDialog(id, gPersonalityLabels + " \n...
}
else if (message == "Select model")
{
startDialog(id, "Select the OpenAI model....
}
else if (message == "Listen to")
{
startDialog(id, "Select listen mode.\nCur...
}
else if (message == "Answer in")
{
startDialog(id, "Select where to send res...
}
else if (message == "Blacklist")
{
startDialog(id, "You are managing blocked...
}
else if (message == "List blocks")
{
/*
list blocks = llLinksetDataFindKeys("^gpt...
integer listLength = llGetListLength(bloc...
llOwnerSay("Blacklist items: " + (string)...
integer i;
while (i < listLength)
{
string record = llGetSubString(llList...
llOwnerSay("- secondlife:///app/agent...
++i;
}
blocks = [];
openMainMenu(id);
*/
}
else if (message == "Add block" || message ==...
{
string label = "add to";
gManagingBlocks = 1;
if (message == "Remove block")
{
gManagingBlocks = 2;
label = "remove from";
}
gDialogHandle = llListen(gDialogChannel, ...
llTextBox(id, "\nPlease specify one singl...
llSetTimerEvent(60);
}
else if (~llListFindList(gPersonalitiesList, ...
{
if (gCurrentPersonalityName != message)
{
gHistoryRecords = [];
}
setPersonality(message);
setListener();
openMainMenu(id);
}
else if (~llListFindList(gModelsList, (list)m...
{
setModel(message);
setListener();
openMainMenu(id);
}
return;
}
/*
// Remove 'llGetAgentSize(id) == ZERO_VECTOR' and...
if (gChatIsLocked || (gListenMode == "Owner" && i...
{
return;
}
*/
setChatLock(TRUE);
message = llStringTrim(message, STRING_TRIM);
if (gPrefixMode)
{
if (llSubStringIndex(llToLower(message), llTo...
{
setChatLock(FALSE);
return;
}
message = llStringTrim(llGetSubString(message...
}
gAnswerToAvatar = id;
list promptAdditions;
if (gCurrentModelName == "GPT-4" || gCurrentModel...
{
addToHistory("user", message);
list timeList = llParseString2List(llGetTimes...
promptAdditions = ["user", (string)id, "messa...
timeList = [];
}
else if (gCurrentModelName == "DALL-E 2" || gCurr...
{
promptAdditions = ["user", (string)id, "promp...
answerUser("Query received, please be patient...
}
message = "";
gHTTPRequestId = llHTTPRequest("https://api.opena...
HTTP_MIMETYPE, "application/json",
HTTP_METHOD, "POST",
HTTP_BODY_MAXLENGTH, 16384,
//HTTP_ACCEPT, "application/json",
HTTP_CUSTOM_HEADER, "Authorization", "Bearer ...
], llList2Json(JSON_OBJECT, llListInsertList(gCur...
}
http_response(key request_id, integer status, list me...
{
metadata = [];
if (gHTTPRequestId == request_id)
{
// GPT-4, GPT 3.5 Turbo
string result = llJsonGetValue(body, ["choice...
// DALL-E
if (result == JSON_INVALID || result == JSON_...
{
result = llJsonGetValue(body, ["data", 0,...
}
if (result == JSON_INVALID || result == JSON_...
{
llSay(0, "Something went wrong, please tr...
llOwnerSay("[SERVER MESSAGE] [HTTP STATUS...
setChatLock(FALSE);
return;
}
body = "";
result = llStringTrim(result, STRING_TRIM);
addToHistory("assistant", result);
result = "([https://platform.openai.com/docs/...
// Result Multi-Say Parsing by Duckie Dickins
integer chunkSize = 1024;
integer totalLength = llStringLength(result);
if (totalLength >= chunkSize)
{
integer currentPos = 0;
while (currentPos < totalLength)
{
answerUser(llGetSubString(result, cur...
currentPos += chunkSize;
llSleep(1);
}
}
else
{
answerUser(result);
}
setChatLock(FALSE);
}
}
/*
linkset_data(integer action, string name, string value)
{
if (action == LINKSETDATA_RESET || action == LINK...
{
llOwnerSay("Blacklist storage modified.");
}
}
*/
on_rez(integer sp)
{
llResetScript();
}
timer()
{
stopDialog();
}
no_sensor()
{
setChatLock(FALSE);
}
changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}
}
</pre>
終了行:
- chat-gpt-integration v2.13- for OpenSim
<pre>
// OpenAI's ChatGPT integration for LSL
// Written by PanteraPolnocy, March 2023
// Version 2.13
// You're responsible for how your OpenAI account will be...
// Set script to "everyone" or "same group" on your own r...
// https://platform.openai.com/docs/usage-policies
// https://openai.com/pricing
// Place your API key here
// https://platform.openai.com/account/api-keys
string gChatGptApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
// ----------------------------------
// Defaults, do NOT change them here - use the dialog men...
string gListenMode = "Owner";
string gAnswerIn = "Nearby chat";
integer gEnabled = FALSE;
integer gHovertext = TRUE;
integer gSimpleAnswers = FALSE;
integer gHistoryEnabled = FALSE;
integer gPrefixMode = FALSE;
// Models database; First one is default
list gOpenAiModels = [
"ModelName", "3.5 Turbo",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-3.5-turbo",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "GPT-4 Turbo",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-4-turbo",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "GPT-4",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-4",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "GPT-4 Omni",
"Endpoint", "/v1/chat/completions",
"Items", 6,
"model", "gpt-4o",
"temperature", 0.9,
"max_tokens", 1000,
"top_p", 1,
"frequency_penalty", 0.0,
"presence_penalty", 0.6,
"ModelName", "DALL-E 2",
"Endpoint", "/v1/images/generations",
"Items", 3,
"model", "dall-e-2",
"n", 1,
"size", "1024x1024",
"ModelName", "DALL-E 3",
"Endpoint", "/v1/images/generations",
"Items", 3,
"model", "dall-e-3",
"n", 1,
"size", "1024x1024"
];
// Personalities database; First one is default
list gPersonalities = [
"Assistant",
"a friendly assistant, as helpful as possible",
"default personality",
"Data",
"the android Data from Star Trek (use tone, manner, v...
"android from Star Trek, logical",
"Picard",
"the Captain Jean-Luc Picard from Star Trek (use tone...
"captain from Star Trek, strong leader",
"JARVIS",
"the J.A.R.V.I.S. AI from Marvel (use tone, manner, v...
"AI from Marvel, polite",
"Napoleon",
"the historical character Napoleon Bonaparte (use ton...
"military conquests, strategic thinking",
"Einstein",
"the historical character Albert Einstein (use tone, ...
"contributions to physics",
"Socrates",
"the historical character Socrates (use tone, manner,...
"philosopher, critical thinking",
"Shakespeare",
"the historical character William Shakespeare (use to...
"renowned playwright",
"Monroe",
"the historical character Marilyn Monroe (use tone, m...
"iconic actress",
"Curie",
"the historical character Marie Curie (use tone, mann...
"Marie Curie, a scientist",
"Elvis",
"the historical character Elvis Presley (use tone, ma...
"beloved musician",
"Freud",
"the historical character Sigmund Freud (use tone, ma...
"psychologist"
];
// Set in runtime
integer gScriptReady;
integer gListenHandle;
integer gDialogChannel;
integer gDialogHandle;
integer gManagingBlocks;
integer gChatIsLocked;
integer gPrefixLength;
string gPersonalityLabels;
string gCurrentPersonality;
string gCurrentPersonalityName;
string gCurrentEndpoint;
string gCurrentModelName;
list gCurrentModelData;
list gModelsList;
list gPersonalitiesList;
list gHistoryRecords;
key gAnswerToAvatar;
key gHTTPRequestId;
key gOwnerKey;
// Functions
setListener()
{
key listenKey = NULL_KEY;
if (gListenMode == "Owner")
{
listenKey = gOwnerKey;
}
gListenHandle = llListen(PUBLIC_CHANNEL, "", listenKe...
llListenControl(gListenHandle, gEnabled);
llSetText(gCurrentPersonalityName + " (" + gCurrentMo...
}
setModel(string modelName)
{
integer modelPosition = llListFindList(gOpenAiModels,...
gCurrentEndpoint = llList2String(gOpenAiModels, model...
gCurrentModelData = llList2List(gOpenAiModels, modelP...
gCurrentModelName = modelName;
gPrefixLength = llStringLength(modelName) + 1;
llOwnerSay("Model selected: " + modelName);
}
setPersonality(string personalityName)
{
integer personalityPosition = llListFindList(gPersona...
gCurrentPersonality = llList2String(gPersonalities, p...
gCurrentPersonalityName = personalityName;
llOwnerSay("Current personality: " + personalityName);
}
startDialog(key id, string text, list buttons)
{
gDialogHandle = llListen(gDialogChannel, "", id, "");
llDialog(id, "\n" + text, buttons, gDialogChannel);
llSetTimerEvent(90);
}
stopDialog()
{
llSetTimerEvent(0);
llListenRemove(gDialogHandle);
}
refreshState(key id, string message)
{
setListener();
llOwnerSay(message);
openMainMenu(id);
}
setChatLock(integer enable)
{
gChatIsLocked = enable;
if (enable)
{
// Chat lock timeout (10 seconds)
llSensorRepeat("cake is a lie", NULL_KEY, AGENT_B...
}
else
{
llSensorRemove();
}
}
addToHistory(string role, string message)
{
if (gCurrentModelName == "GPT-4" || gCurrentModelName...
{
if (!gHistoryEnabled)
{
gHistoryRecords = [];
}
gHistoryRecords = gHistoryRecords + llList2Json(J...
message = "";
integer historyLength = llGetListLength(gHistoryR...
if (historyLength > 10)
{
gHistoryRecords = llList2List(gHistoryRecords...
}
}
}
openMainMenu(key person)
{
gManagingBlocks = 0;
startDialog(person,
"Current state: " + llList2String(["DISABLED", "E...
"\nCurrent personality: " + gCurrentPersonalityNa...
"\nCurrent model: " + gCurrentModelName +
"\nSimple answers: " + llList2String(["DISABLED",...
"\nPrefix mode: " + llList2String(["DISABLED", "E...
"\nHistory: " + llList2String(["DISABLED", "ENABL...
"\nListen to: " + gListenMode +
"\nAnswer in: " + gAnswerIn,
["Simple mode", "History", "Hovertext", "Prefix m...
);
}
answerUser(string theMessage)
{
if (gAnswerIn == "Nearby chat")
{
llSay(0, theMessage);
}
else
{
llRegionSayTo(gAnswerToAvatar, 0, theMessage);
}
}
// Script body
default
{
state_entry()
{
llOwnerSay("Starting up...");
gOwnerKey = llGetOwner();
gDialogChannel = (integer)(llFrand(-10000000)-100...
integer listLength = llGetListLength(gOpenAiModel...
integer i;
while (i < listLength)
{
string currentItem = llList2String(gOpenAiMod...
if (currentItem == "ModelName")
{
gModelsList = gModelsList + llList2String...
}
++i;
}
gPersonalitiesList = llList2ListStrided(gPersonal...
listLength = llGetListLength(gPersonalities);
i = 0;
while (i < listLength)
{
gPersonalityLabels = gPersonalityLabels + llL...
i = i + 3;
}
integer memoryLimit = llGetMemoryLimit();
if (memoryLimit <= 16384)
{
llOwnerSay("FATAL ERROR: You are currently us...
}
else
{
setPersonality(llList2String(gPersonalitiesLi...
setModel(llList2String(gModelsList, 0));
stopDialog();
setListener();
setChatLock(FALSE);
llOwnerSay("Ready. Touch me to adjust options...
gScriptReady = TRUE;
}
}
touch_start(integer nd)
{
key toucherKey = llDetectedKey(0);
if (toucherKey == gOwnerKey && gScriptReady)
{
openMainMenu(toucherKey);
}
}
listen(integer channel, string name, key id, string m...
{
if (channel == gDialogChannel)
{
if (gManagingBlocks)
{
message = llStringTrim(message, STRING_TR...
if ((key)message)
{
/*
if (gManagingBlocks == 1)
{
llOwnerSay("Addition request has ...
//llLinksetDataWrite("gptblock:" ...
}
else
{
llOwnerSay("Removal request has b...
//llLinksetDataDelete("gptblock:"...
}
*/
}
else
{
llOwnerSay("The UUID '" + message + "...
}
openMainMenu(id);
}
else if (message == "ON / OFF")
{
gEnabled = !gEnabled;
refreshState(id, "Listener " + llList2Str...
}
else if (message == "Hovertext")
{
gHovertext = !gHovertext;
refreshState(id, "Hovertext " + llList2St...
}
else if (message == "Simple mode")
{
gSimpleAnswers = !gSimpleAnswers;
refreshState(id, "Simple answers mode " +...
}
else if (message == "History")
{
gHistoryEnabled = !gHistoryEnabled;
refreshState(id, "History is now " + llLi...
}
else if (message == "Prefix mode")
{
gPrefixMode = !gPrefixMode;
refreshState(id, "Prefix mode is now " + ...
}
else if (message == "Owner" || message == "Sa...
{
gListenMode = message;
refreshState(id, "Listen mode set to: " +...
}
else if (message == "Nearby chat" || message ...
{
gAnswerIn = message;
refreshState(id, "Answering in: " + messa...
}
else if (message == "Personality")
{
startDialog(id, gPersonalityLabels + " \n...
}
else if (message == "Select model")
{
startDialog(id, "Select the OpenAI model....
}
else if (message == "Listen to")
{
startDialog(id, "Select listen mode.\nCur...
}
else if (message == "Answer in")
{
startDialog(id, "Select where to send res...
}
else if (message == "Blacklist")
{
startDialog(id, "You are managing blocked...
}
else if (message == "List blocks")
{
/*
list blocks = llLinksetDataFindKeys("^gpt...
integer listLength = llGetListLength(bloc...
llOwnerSay("Blacklist items: " + (string)...
integer i;
while (i < listLength)
{
string record = llGetSubString(llList...
llOwnerSay("- secondlife:///app/agent...
++i;
}
blocks = [];
openMainMenu(id);
*/
}
else if (message == "Add block" || message ==...
{
string label = "add to";
gManagingBlocks = 1;
if (message == "Remove block")
{
gManagingBlocks = 2;
label = "remove from";
}
gDialogHandle = llListen(gDialogChannel, ...
llTextBox(id, "\nPlease specify one singl...
llSetTimerEvent(60);
}
else if (~llListFindList(gPersonalitiesList, ...
{
if (gCurrentPersonalityName != message)
{
gHistoryRecords = [];
}
setPersonality(message);
setListener();
openMainMenu(id);
}
else if (~llListFindList(gModelsList, (list)m...
{
setModel(message);
setListener();
openMainMenu(id);
}
return;
}
/*
// Remove 'llGetAgentSize(id) == ZERO_VECTOR' and...
if (gChatIsLocked || (gListenMode == "Owner" && i...
{
return;
}
*/
setChatLock(TRUE);
message = llStringTrim(message, STRING_TRIM);
if (gPrefixMode)
{
if (llSubStringIndex(llToLower(message), llTo...
{
setChatLock(FALSE);
return;
}
message = llStringTrim(llGetSubString(message...
}
gAnswerToAvatar = id;
list promptAdditions;
if (gCurrentModelName == "GPT-4" || gCurrentModel...
{
addToHistory("user", message);
list timeList = llParseString2List(llGetTimes...
promptAdditions = ["user", (string)id, "messa...
timeList = [];
}
else if (gCurrentModelName == "DALL-E 2" || gCurr...
{
promptAdditions = ["user", (string)id, "promp...
answerUser("Query received, please be patient...
}
message = "";
gHTTPRequestId = llHTTPRequest("https://api.opena...
HTTP_MIMETYPE, "application/json",
HTTP_METHOD, "POST",
HTTP_BODY_MAXLENGTH, 16384,
//HTTP_ACCEPT, "application/json",
HTTP_CUSTOM_HEADER, "Authorization", "Bearer ...
], llList2Json(JSON_OBJECT, llListInsertList(gCur...
}
http_response(key request_id, integer status, list me...
{
metadata = [];
if (gHTTPRequestId == request_id)
{
// GPT-4, GPT 3.5 Turbo
string result = llJsonGetValue(body, ["choice...
// DALL-E
if (result == JSON_INVALID || result == JSON_...
{
result = llJsonGetValue(body, ["data", 0,...
}
if (result == JSON_INVALID || result == JSON_...
{
llSay(0, "Something went wrong, please tr...
llOwnerSay("[SERVER MESSAGE] [HTTP STATUS...
setChatLock(FALSE);
return;
}
body = "";
result = llStringTrim(result, STRING_TRIM);
addToHistory("assistant", result);
result = "([https://platform.openai.com/docs/...
// Result Multi-Say Parsing by Duckie Dickins
integer chunkSize = 1024;
integer totalLength = llStringLength(result);
if (totalLength >= chunkSize)
{
integer currentPos = 0;
while (currentPos < totalLength)
{
answerUser(llGetSubString(result, cur...
currentPos += chunkSize;
llSleep(1);
}
}
else
{
answerUser(result);
}
setChatLock(FALSE);
}
}
/*
linkset_data(integer action, string name, string value)
{
if (action == LINKSETDATA_RESET || action == LINK...
{
llOwnerSay("Blacklist storage modified.");
}
}
*/
on_rez(integer sp)
{
llResetScript();
}
timer()
{
stopDialog();
}
no_sensor()
{
setChatLock(FALSE);
}
changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}
}
</pre>
ページ名: