Skip to content

Commit

Permalink
feat: XNLU (#101)
Browse files Browse the repository at this point in the history
* chore:done

* chore:done

* chore:done

* chore:done?
  • Loading branch information
michaelmyers committed May 17, 2023
1 parent ee23526 commit fef3ff2
Show file tree
Hide file tree
Showing 7 changed files with 1,024 additions and 623 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
ci:
runs-on: ubuntu-latest
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
strategy:
matrix:
node-version: [16.x]
Expand All @@ -22,7 +22,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- name: Setup .yarnrc.yml
run: |
yarn config set 'npmRegistries["https://registry.yarnpkg.com"].npmAuthToken' $NPM_AUTH_TOKEN
- run: yarn --immutable
- run: yarn lint
- run: yarn test
- run: yarn build
Expand Down
2 changes: 0 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
save-exact=true
@xapp:registry=https://registry.npmjs.org/
registry=https://registry.npmjs.org/
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## OC Studio Starter Template
## XAPP Assistant

A starter template repository for OC Studio leveraging 📣 stentor conversational framework.
The XAPP Assistant, "XAPPy", that is found on https://xapp.ai, Google Business Messages, and intelligent search.

## Repository Structure

Expand All @@ -21,3 +21,7 @@ Shared models across all the packages, specifically the app and components.
### Template /packages/templates

Starting point of content and interaction model.

## Private XNLU

We are using a private repo `@xapp/x-nlu` which cannot be accessed unless you have permission.
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@xapp/stentor-gbm": "1.45.71",
"@xapp/stentor-lex-v2": "1.45.71",
"@xapp/stentor-service-salesforce": "1.45.71",
"@xapp/x-nlu": "1.2.3",
"addresser": "1.1.19",
"ansi-styles": "6.2.1",
"body-parser": "1.20.2",
Expand Down
23 changes: 18 additions & 5 deletions packages/app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LexV2Channel } from "@xapp/stentor-lex-v2";
import { Stentor } from "stentor-channel";

// NLU
import { ExtendedNLU } from "./services/ExtendedNLU";
import { XNLU, OpenAIService } from "@xapp/x-nlu";

// Services
import { DynamoUserStorage } from "stentor-user-storage-dynamo";
Expand All @@ -30,9 +30,24 @@ import { preResponseHook } from "./hooks/preResponseHook";
export async function handler(event: any, context: Context, callback: Callback<any>): Promise<void> {
await setEnv().then().catch((error: Error) => console.error("Environment failed to load", error));

const nlu = new ExtendedNLU({
const studioService: StudioService = new StudioService({
appId: process.env.STUDIO_APP_ID,
token: process.env.STUDIO_TOKEN
});

const llmService = new OpenAIService({
businessDescription: "XAPP AI is a conversational AI company that provides intelligent virtual assistants for enterprise and small businesses with their home service templates. XAPP AI has a with deep understanding of applying conversational AI, intelligent search and generative AI to create conversational chat, search and messaging."
});

const nlu = new XNLU({
botId: process.env.LEX_BOT_ID,
botAliasId: process.env.LEX_BOT_ALIAS_ID
botAliasId: process.env.LEX_BOT_ALIAS_ID,
llmService,
knowledgeBaseService: studioService,
intentMap: {
questionAnswering: "OCSearch",
helpWith: "LeadGeneration"
}
});

const gbmChannel = GoogleBusinessMessages(nlu, {
Expand All @@ -44,8 +59,6 @@ export async function handler(event: any, context: Context, callback: Callback<a
preResponseTranslation: preResponseHook(nlu),
}

const studioService: StudioService = new StudioService({ appId: process.env.STUDIO_APP_ID, token: process.env.STUDIO_TOKEN });

// Return the handler for running in an AWS Lambda function.
const assistant = new Assistant()
// We are using a simple dynamo user storage but all you need is something that implements the interface UserStorageService
Expand Down
97 changes: 0 additions & 97 deletions packages/app/src/services/ExtendedNLU.ts

This file was deleted.

0 comments on commit fef3ff2

Please sign in to comment.