Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions packages/models/src/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ export class ActionBase {
// safety for those places which should require it.
// TODO: Remove ScoredAction since it doesn't have payload
static GetPayload(action: ActionBase | ScoredBase, entityValues: Map<string, string>): string {

if (this.useSimplePayload(action)) {
let simpleAction = new SimpleAction(action as ActionBase)
return simpleAction.renderValue(entityValues)
}

switch (action.actionType) {
case ActionTypes.TEXT: {
/**
Expand All @@ -122,8 +122,7 @@ export class ActionBase {
} catch (e) {
const error = e as Error
throw new Error(
`Error when attempting to parse text action payload. This might be an old action which was saved as a string. Please create a new action. ${
error.message
`Error when attempting to parse text action payload. This might be an old action which was saved as a string. Please create a new action. ${error.message
}`
)
}
Expand Down Expand Up @@ -166,7 +165,7 @@ export class ActionBase {
return false
}

// Return true if text action contains simple payload and no slate document
// Return true if text action contains simple payload and no slate document
static useSimplePayload(action: Partial<ActionBase> | undefined): boolean {
if (action === undefined) {
return false
Expand Down Expand Up @@ -396,7 +395,7 @@ export class SessionAction extends ActionBase {
}

export class SimpleAction extends ActionBase {
value: string
value: string

constructor(action: ActionBase) {
super(action)
Expand All @@ -411,9 +410,8 @@ export class SimpleAction extends ActionBase {

renderValue(entityValues: Map<string, string>): string {
let output = this.value
entityValues.forEach((value: string, key: string) =>
{
output = output.replace(`{${key}}`, value)
entityValues.forEach((value: string, key: string) => {
output = output.replace(new RegExp(`{${key}}`, 'g'), value)
})
return output
}
Expand Down
9 changes: 7 additions & 2 deletions packages/ui/src/routes/Apps/App/LogDialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ class LogDialogs extends React.Component<Props, ComponentState> {
}

@autobind
onCloseChatSessionWindow() {
async onCloseChatSessionWindow() {
// fetch all actions and entities for dynamically generated actions by generative predictor
await ((this.props.fetchAllEntitiesThunkAsync(this.props.app.appId) as any) as Promise<void>)
await ((this.props.fetchAllActionsThunkAsync(this.props.app.appId) as any) as Promise<void>)
this.setState({
chatSession: null,
isChatSessionWindowOpen: false,
Expand Down Expand Up @@ -548,7 +551,9 @@ const mapDispatchToProps = (dispatch: any) => {
createChatSessionThunkAsync: actionTypes.chat.createChatSessionThunkAsync,
deleteLogDialogsThunkAsync: actionTypes.log.deleteLogDialogsThunkAsync,
fetchLogDialogAsync: actionTypes.log.fetchLogDialogThunkAsync,
fetchLogDialogsThunkAsync: actionTypes.log.fetchLogDialogsThunkAsync
fetchLogDialogsThunkAsync: actionTypes.log.fetchLogDialogsThunkAsync,
fetchAllActionsThunkAsync: actionTypes.action.fetchAllActionsThunkAsync,
fetchAllEntitiesThunkAsync: actionTypes.entity.fetchAllEntitiesThunkAsync
}, dispatch)
}
const mapStateToProps = (state: State) => {
Expand Down