"Foreign key linking to the Users Collection. Crucial if you have multiple users.",
},
{
name:"source_message_id",
data_type: DataType.Int64,
description:
"Foreign key linking to the ChatMessages Collection, indicating which message initially triggered the learning of this fact. Useful for debugging and traceability.",
},
{
name:"fact_content",
data_type: DataType.VarChar,
description:`The actual natural language statement of the fact (e.g., "The user likes pizza."). This is what you'll inject into the LLM context.`,
},
{
name:"fact_embedding",
data_type: DataType.FloatVector,
type_params:{
dim: 3072,
},
description:`Vector for the fact_content itself. This allows you to retrieve facts based on semantic similarity to a user's new statement (e.g., user asks "What do I like?", you embed that and search fact_embedding).`,
},
/** Unix timestamp of when the fact was extracted/created. */
{name:"created_at",data_type: DataType.Int64},
],
});
asyncfunctioninitialize() {
/** List existing Collections to determine what we have to create.*/
"Foreign key linking to the Facts Collection. This is the fact that should be triggered.",
},
{
name:"trigger_phrase",
data_type: DataType.VarChar,
description:`The natural language phrase describing the trigger (e.g., "When food preferences are discussed"). Useful for context and debugging during trigger generation.`,
},
{
name:"trigger_phrase_embedding",
data_type: DataType.FloatVector,
type_params:{
dim: 3072,
},
description:`The vector representation of the trigger phrase. This is what you'll query with the current conversation context, with a large/smart LLM.`,
},
{
name:"priority_multiplier",
data_type: DataType.Float,
description:
"A score multiplier indicating the perceived importance or confidence in this fact trigger, within this FactTrigger's scope. For example, if the FactTrigger is scoped to 'every Wednesday', then it would be very relevant on Wednesdays.",
},
{
name:"priority_multiplier_reason",
data_type: DataType.VarChar,
description:
"The natural-language reason for why this FactTrigger was given its priority multiplier. We store the reason here so that we can easily explain it to the user; but more importantly, the same FactTrigger might have different priorities in different situations that are only discovered from subsequent user input. In this case, we don't want to update the existing FactTrigger's priority multiplier, but instead create a new FactTrigger with a new priority multiplier, with different trigger_phrase and different scope_priority_multiplier_reason.",
},
{
name:"scope_conversation_id",
data_type: DataType.Int64,
description:
"Foreign key linking to the Conversations Collection. This is optional. It is set for scoping the FactTrigger to a specific conversation.",
},
/** Unix timestamp of when this specific trigger was generated. */
{name:"created_at",data_type: DataType.Int64},
],
});
/** Create collections if they don't exist. */
if(!collectionNames.includes("facts")){
console.log("Creating collection: facts");
awaitclient.createCollection({
collection_name:"facts",
auto_id: true,
fields:[
{
name:"id",
data_type: DataType.Int64,
is_primary_key: true,
},
{
name:"user_id",
data_type: DataType.Int64,
description:
"Foreign key linking to the Users Collection. Crucial if you have multiple users.",
},
{
name:"source_message_id",
data_type: DataType.Int64,
description:
"Foreign key linking to the ChatMessages Collection, indicating which message initially triggered the learning of this fact. Useful for debugging and traceability.",
},
{
name:"fact_content",
data_type: DataType.VarChar,
description:`The actual natural language statement of the fact (e.g., "The user likes pizza."). This is what you'll inject into the LLM context.`,
type_params:{
max_length:"10240",
},
},
{
name:"fact_embedding",
data_type: DataType.FloatVector,
type_params:{
dim:"3072",
},
description:`Vector for the fact_content itself. This allows you to retrieve facts based on semantic similarity to a user's new statement (e.g., user asks "What do I like?", you embed that and search fact_embedding).`,
},
/** Unix timestamp of when the fact was extracted/created. */
"Foreign key linking to the Facts Collection. This is the fact that should be triggered.",
},
{
name:"trigger_phrase",
data_type: DataType.VarChar,
description:`The natural language phrase describing the trigger (e.g., "When food preferences are discussed"). Useful for context and debugging during trigger generation.`,
type_params:{
max_length:"10240",
},
},
{
name:"trigger_phrase_embedding",
data_type: DataType.FloatVector,
type_params:{
dim:"3072",
},
description:`The vector representation of the trigger phrase. This is what you'll query with the current conversation context, with a large/smart LLM.`,
},
{
name:"priority_multiplier",
data_type: DataType.Float,
description:
"A score multiplier indicating the perceived importance or confidence in this fact trigger, within this FactTrigger's scope. For example, if the FactTrigger is scoped to 'every Wednesday', then it would be very relevant on Wednesdays.",
},
{
name:"priority_multiplier_reason",
data_type: DataType.VarChar,
description:
"The natural-language reason for why this FactTrigger was given its priority multiplier. We store the reason here so that we can easily explain it to the user; but more importantly, the same FactTrigger might have different priorities in different situations that are only discovered from subsequent user input. In this case, we don't want to update the existing FactTrigger's priority multiplier, but instead create a new FactTrigger with a new priority multiplier, with different trigger_phrase and different scope_priority_multiplier_reason.",
type_params:{
max_length:"10240",
},
},
{
name:"scope_conversation_id",
data_type: DataType.Int64,
description:
"Foreign key linking to the Conversations Collection. This is optional. It is set for scoping the FactTrigger to a specific conversation.",
},
/** Unix timestamp of when this specific trigger was generated. */
"Foreign key linking to the ChatMessages Collection, indicating which message initially triggered the creation of this tool. Useful for debugging and traceability.",
},
{
name:"name",
data_type: DataType.VarChar,
description:`The name of the tool (e.g., "weather").`,
},
{
name:"description",
data_type: DataType.VarChar,
description:`The description of the tool (e.g., "Get the current weather in a given location.").`,
},
{
name:"parameter_schema",
data_type: DataType.JSON,
description:`The JSON Schema of the parameters to be passed to the tool (e.g., {"location": "string"}).`,
},
{
name:"implementation_language",
data_type: DataType.VarChar,
description:`The language of the tool (e.g., "Python"). This is so we know how to execute the tool's implementation code.`,
},
if(!collectionNames.includes("tools")){
console.log("Creating collection: tools");
awaitclient.createCollection({
collection_name:"tools",
auto_id: true,
fields:[
/** Primary key, unique identifier for each fact. */
{
name:"id",
data_type: DataType.Int64,
is_primary_key: true,
},
/**ForeignkeylinkingtotheUsersCollection.
*Crucialifyouhavemultipleusers.*/
{
name:"user_id",
data_type: DataType.Int64,
description:
"Foreign key linking to the Users Collection. Crucial if you have multiple users.",
"Foreign key linking to the ChatMessages Collection, indicating which message initially triggered the creation of this tool. Useful for debugging and traceability.",
},
{
name:"name",
data_type: DataType.VarChar,
description:`The name of the tool (e.g., "weather").`,
type_params:{
max_length:"64",
},
},
{
name:"description",
data_type: DataType.VarChar,
description:`The description of the tool (e.g., "Get the current weather in a given location.").`,
type_params:{
max_length:"10240",
},
},
{
name:"parameter_schema",
data_type: DataType.JSON,
description:`The JSON Schema of the parameters to be passed to the tool (e.g., {"location": "string"}).`,
},
{
name:"implementation_language",
data_type: DataType.VarChar,
description:`The language of the tool (e.g., "Python"). This is so we know how to execute the tool's implementation code.`,
type_params:{
max_length:"128",
},
},
{
name:"implementation_code",
data_type: DataType.VarChar,
description:`The actual code that implements the tool (e.g., "def get_weather(location): return 'Sunny'").`,
type_params:{
max_length:"65535",// 64KB
},
},
{
name:"implementation_embedding",
data_type: DataType.FloatVector,
type_params:{
dim:"3072",
},
description:`The embedding of the tool's implementation code.`,
},
/** Unix timestamp of when the fact was extracted/created. */
{name:"created_at",data_type: DataType.Int64},
],
});
}
{
name:"implementation_code",
data_type: DataType.VarChar,
description:`The actual code that implements the tool (e.g., "def get_weather(location): return 'Sunny'").`,
},
/** Unix timestamp of when the fact was extracted/created. */
{name:"created_at",data_type: DataType.Int64},
],
});
/** I'm still not sure if it's useful to have a `tool_trigger` collection. */
/** I'm still not sure if it's useful to have a `tool_trigger` collection. */