Overview / StrayCat
StrayCat
The stray cat goes around tools and hook, making troubles
Constructors
new StrayCat()
new StrayCat(
userId
,ws
?):StrayCat
Parameters
Parameter | Type |
---|---|
userId | string |
ws ? | ElysiaWS |
Returns
Properties
Property | Modifier | Type | Default value |
---|---|---|---|
activeForm? | public | string | undefined |
userId | public | string | undefined |
workingMemory | public | WorkingMemory | undefined |
wsQueue | public | WSMessage [] | [] |
Accessors
agentManager
Get Signature
get agentManager():
AgentManager
Returns
currentEmbedder
Get Signature
get currentEmbedder():
Embeddings
Returns
Embeddings
currentLLM
Get Signature
get currentLLM():
BaseChatModel
Returns
BaseChatModel
lastUserMessage
Get Signature
get lastUserMessage():
Message
Returns
plugins
Get Signature
get plugins():
object
[]
Returns
object
[]
rabbitHole
Get Signature
get rabbitHole():
RabbitHole
Returns
vectorMemory
Get Signature
get vectorMemory():
VectorMemory
Returns
whiteRabbit
Get Signature
get whiteRabbit():
WhiteRabbit
Returns
Methods
addHistory()
addHistory(
message
):void
Adds messages to the chat history.
Parameters
Parameter | Type | Description |
---|---|---|
message | MemoryMessage [] | the messages to add |
Returns
void
addInteraction()
addInteraction(
interaction
):void
Adds an interaction to the working memory.
Parameters
Parameter | Type | Description |
---|---|---|
interaction | ModelInteraction | the interaction to add |
Returns
void
addWebSocket()
addWebSocket(
value
):void
This property is used to establish a new WebSocket connection.
Parameters
Parameter | Type | Description |
---|---|---|
value | undefined | ElysiaWS | The WebSocket instance. |
Returns
void
classify()
classify<
S
,T
>(sentence
,labels
,examples
?):Promise
<null
|S
>
Experimental
Classifies the given sentence into one of the provided labels.
Type Parameters
Type Parameter |
---|
S extends string |
T extends [S , ...S[] ] |
Parameters
Parameter | Type | Description |
---|---|---|
sentence | string | The sentence to classify. |
labels | T | The labels to classify the sentence into. |
examples ? | { [key in string]: S[] } | Optional examples to help the LLM classify the sentence. |
Returns
Promise
<null
| S
>
The label of the sentence or null if it could not be classified.
clearHistory()
clearHistory():
void
Clears the chat history.
Returns
void
getHistory()
getHistory(
k
?):MemoryMessage
[]
If passed a number k, retrieves the last k messages in the chat history. Otherwise, retrieves all messages in the chat history.
Parameters
Parameter | Type | Description |
---|---|---|
k ? | number | the number of messages to retrieve |
Returns
the messages present in the chat history
getInteraction()
getInteraction(
k
?):ModelInteraction
[]
If passed a number k, retrieves the last k interactions in the working memory. Otherwise, retrieves all interactions in the working memory.
Parameters
Parameter | Type | Description |
---|---|---|
k ? | number | the number of interactions to retrieve |
Returns
the interactions present in the working memory
getPluginInfo()
getPluginInfo(
id
):undefined
| {active
:boolean
;manifest
: {authorName
:string
;authorUrl
:string
;description
:string
;name
:string
;pluginUrl
:string
;tags
:string
[];thumb
:string
;version
:string
; };settings
: {}; }
Retrieves information about a plugin.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The ID of the plugin. |
Returns
undefined
| { active
: boolean
; manifest
: { authorName
: string
; authorUrl
: string
; description
: string
; name
: string
; pluginUrl
: string
; tags
: string
[]; thumb
: string
; version
: string
; }; settings
: {}; }
An object containing the plugin's active status, manifest, and settings.
Returns undefined if the plugin is not found.
llm()
Call Signature
llm(
prompt
,stream
?):Promise
<AIMessageChunk
>
Executes the LLM with the given prompt and returns the response.
Parameters
Parameter | Type | Description |
---|---|---|
prompt | BaseLanguageModelInput | The prompt or messages to be passed to the LLM. |
stream ? | false | Optional parameter to enable streaming mode. |
Returns
Promise
<AIMessageChunk
>
Call Signature
llm(
prompt
,stream
?):Promise
<IterableReadableStream
<AIMessageChunk
>>
Executes the LLM with the given prompt and returns the response.
Parameters
Parameter | Type | Description |
---|---|---|
prompt | BaseLanguageModelInput | The prompt or messages to be passed to the LLM. |
stream ? | true | Optional parameter to enable streaming mode. |
Returns
Promise
<IterableReadableStream
<AIMessageChunk
>>
queryDb()
queryDb<
T
>(question
,type
,source
):Promise
<string
>
Experimental
Executes a SQL query based on a natural language question.
Type Parameters
Type Parameter |
---|
T extends "oracle" | "postgres" | "sqlite" | "mysql" | "mssql" |
Parameters
Parameter | Type | Description |
---|---|---|
question | string | The user question. |
type | T | The SQL dialect to use. |
source | Omit <Extract <MysqlConnectionOptions , { type : T ; }> | Extract <PostgresConnectionOptions , { type : T ; }> | Extract <CockroachConnectionOptions , { type : T ; }> | Extract <SqliteConnectionOptions , { type : T ; }> | Extract <SqlServerConnectionOptions , { type : T ; }> | Extract <SapConnectionOptions , { type : T ; }> | Extract <OracleConnectionOptions , { type : T ; }> | Extract <CordovaConnectionOptions , { type : T ; }> | Extract <NativescriptConnectionOptions , { type : T ; }> | Extract <ReactNativeConnectionOptions , { type : T ; }> | Extract <SqljsConnectionOptions , { type : T ; }> | Extract <MongoConnectionOptions , { type : T ; }> | Extract <AuroraMysqlConnectionOptions , { type : T ; }> | Extract <AuroraPostgresConnectionOptions , { type : T ; }> | Extract <ExpoConnectionOptions , { type : T ; }> | Extract <BetterSqlite3ConnectionOptions , { type : T ; }> | Extract <CapacitorConnectionOptions , { type : T ; }> | Extract <SpannerConnectionOptions , { type : T ; }>, "type" > | The data source to execute the query on. |
Returns
Promise
<string
>
The result of the SQL query in natural language.
recallRelevantMemories()
recallRelevantMemories(
query
?):Promise
<void
>
Recalls relevant memories based on the given query. If no query is provided, it uses the last user's message text as the query.
Parameters
Parameter | Type | Description |
---|---|---|
query ? | string | The query string to search for relevant memories. |
Returns
Promise
<void
>
run()
run(
msg
,save
,returnWhy
):Promise
<WSMessage
>
Processes the user message and returns the response.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
msg | Message | undefined | The message to send. |
save | boolean | true | Whether to save the message or not in the chat history (default: true). |
returnWhy | boolean | true | Whether to return the 'why' field in the response (default: true). |
Returns
Promise
<WSMessage
>
The response message.
send()
send(
msg
):void
Sends a message through the websocket connection.
If the websocket connection is not open, the message is queued.
If the message is of type 'chat', it is also stored in the chat history.
Parameters
Parameter | Type | Description |
---|---|---|
msg | WSMessage | The message to send. |
Returns
void