Skip to content

Commit

Permalink
Register new event history node
Browse files Browse the repository at this point in the history
  • Loading branch information
parzival418 committed Feb 1, 2024
1 parent 510e2cf commit de52b6f
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 12 deletions.
74 changes: 74 additions & 0 deletions packages/shared/nodeSpec/src/nodeSpec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,80 @@
],
"configuration": []
},
{
"type": "queries/events/eventHistory",
"category": "Flow",
"label": "Event History",
"inputs": [
{
"name": "flow",
"valueType": "flow"
},
{
"name": "entries",
"valueType": "integer",
"defaultValue": 10
}
],
"outputs": [
{
"name": "flow",
"valueType": "flow"
},
{
"name": "events",
"valueType": "array"
},
{
"name": "strings",
"valueType": "array"
}
],
"configuration": [
{
"name": "hiddenProperties",
"valueType": "array",
"defaultValue": [
"hiddenProperties",
"eventState",
"availableEvents"
]
},
{
"name": "eventState",
"valueType": "array",
"defaultValue": [
"sender",
"agentId"
]
},
{
"name": "eventStateProperties",
"valueType": "array",
"defaultValue": [
"connector",
"client",
"channel",
"sender",
"agentId"
]
},
{
"name": "availableEvents",
"valueType": "array",
"defaultValue": [
"messageReceived",
"messageSend",
"messageStream"
]
},
{
"name": "selectedEvents",
"valueType": "array",
"defaultValue": []
}
]
},
{
"type": "logic/string",
"category": "None",
Expand Down
24 changes: 12 additions & 12 deletions plugins/core/src/lib/corePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ import {
corePluginName,
coreRemovedNodes,
} from './constants'
import {
ON_ERROR,
ON_MESSAGE,
SEND_MESSAGE,
STREAM_MESSAGE,
} from 'communication'
import { EventTypes, ON_ERROR } from 'communication'
import { delay } from './nodes/time/delay'
import { queryEventHistory } from './nodes/events/eventHistory'

/**
* CorePlugin handles all generic events and has its own nodes, dependencies, and values.
Expand Down Expand Up @@ -85,6 +81,7 @@ export class CorePlugin extends CoreEventsPlugin<
searchKnowledge,
searchManyKnowledge,
delay,
queryEventHistory,
]
values = []
coreLLMService: CoreLLMService
Expand Down Expand Up @@ -120,7 +117,7 @@ export class CorePlugin extends CoreEventsPlugin<
defineEvents() {
// Define events here
this.registerEvent({
eventName: ON_MESSAGE,
eventName: EventTypes.ON_MESSAGE,
displayName: 'Message Received',
})
}
Expand All @@ -131,12 +128,12 @@ export class CorePlugin extends CoreEventsPlugin<
defineActions() {
// Define actions here
this.registerAction({
actionName: SEND_MESSAGE,
actionName: EventTypes.SEND_MESSAGE,
displayName: 'Send Message',
handler: this.handleSendMessage.bind(this),
})
this.registerAction({
actionName: STREAM_MESSAGE,
actionName: EventTypes.STREAM_MESSAGE,
displayName: 'Stream Message',
handler: this.handleSendMessage.bind(this),
})
Expand All @@ -150,7 +147,10 @@ export class CorePlugin extends CoreEventsPlugin<
async initializeFunctionalities() {
await this.getLLMCredentials()

this.centralEventBus.on(ON_MESSAGE, this.handleOnMessage.bind(this))
this.centralEventBus.on(
EventTypes.ON_MESSAGE,
this.handleOnMessage.bind(this)
)
this.client.onMessage(this.handleOnMessage.bind(this))
}

Expand Down Expand Up @@ -235,8 +235,8 @@ export class CorePlugin extends CoreEventsPlugin<
}

handleOnMessage(payload: EventPayload) {
const event = this.formatMessageEvent(ON_MESSAGE, payload)
this.emitEvent(ON_MESSAGE, event)
const event = this.formatMessageEvent(EventTypes.ON_MESSAGE, payload)
this.emitEvent(EventTypes.ON_MESSAGE, event)
}

handleSendMessage(actionPayload: ActionPayload) {
Expand Down

0 comments on commit de52b6f

Please sign in to comment.