-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1290 from AletheiaFact/enabled-parallel-conversat…
…ions-on-chat-bot Enabled Parallel ChatBot Conversations.
- Loading branch information
Showing
7 changed files
with
204 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { MongooseModule } from "@nestjs/mongoose"; | ||
import { ChatBotState, ChatBotStateSchema } from "./chat-bot-state.schema"; | ||
import { ChatBotStateService } from "./chat-bot-state.service"; | ||
|
||
const ChatBotStateModel = MongooseModule.forFeature([ | ||
{ | ||
name: ChatBotState.name, | ||
schema: ChatBotStateSchema, | ||
}, | ||
]); | ||
|
||
@Module({ | ||
imports: [ChatBotStateModel], | ||
exports: [ChatBotStateService], | ||
providers: [ChatBotStateService], | ||
}) | ||
export class ChatBotStateModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose"; | ||
import * as mongoose from "mongoose"; | ||
|
||
export type ChatBotStateDocument = ChatBotState & mongoose.Document; | ||
|
||
@Schema() | ||
export class ChatBotState { | ||
@Prop({ required: true }) | ||
_id: string; | ||
|
||
@Prop({ required: true, type: mongoose.Schema.Types.Mixed }) | ||
state: any; | ||
} | ||
|
||
const ChatBotStateSchemaRaw = SchemaFactory.createForClass(ChatBotState); | ||
|
||
export const ChatBotStateSchema = ChatBotStateSchemaRaw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { InjectModel } from "@nestjs/mongoose"; | ||
import { Model } from "mongoose"; | ||
import { ChatBotState, ChatBotStateDocument } from "./chat-bot-state.schema"; | ||
|
||
@Injectable() | ||
export class ChatBotStateService { | ||
constructor( | ||
@InjectModel(ChatBotState.name) | ||
private ChatBotStateModel: Model<ChatBotStateDocument> | ||
) {} | ||
|
||
async create(state, id: string) { | ||
const newChatBotState = new this.ChatBotStateModel({ | ||
_id: id, | ||
state: state, | ||
}); | ||
return await newChatBotState.save(); | ||
} | ||
|
||
async updateState( | ||
id: string, | ||
state: any | ||
): Promise<ChatBotStateDocument | null> { | ||
return await this.ChatBotStateModel.findByIdAndUpdate( | ||
id, | ||
{ state: state }, | ||
{ new: true, useFindAndModify: false } | ||
).exec(); | ||
} | ||
|
||
async getById(id: string) { | ||
const chatBotState = this.ChatBotStateModel.findById(id); | ||
return chatBotState; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters