Skip to content

Commit

Permalink
chore(ner/intent): support for botonic full-stack (#1644)
Browse files Browse the repository at this point in the history
* chore(ner/intent): support for botonic full-stack

* refactor(plugin-ner, plugin-ic): baseUrl typed

Co-authored-by: Eric Lozano <ericlozano98@gmail.com>
  • Loading branch information
2 people authored and ericmarcos committed Jul 15, 2021
1 parent 82d0263 commit 3df40fc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
5 changes: 1 addition & 4 deletions packages/botonic-plugin-intent-classification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export default class BotonicPluginIntentClassification implements Plugin {
private readonly modelsSelector: Promise<IntentModelSelector>

constructor(readonly options: PluginOptions) {
this.modelsSelector = IntentModelSelector.build(
this.options.locales,
this.options.modelsBaseUrl
)
this.modelsSelector = IntentModelSelector.build(this.options.locales)
}

async pre(request: PluginPreRequest): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export class IntentModelSelector extends ModelSelector<
IntentClassifier,
IntentClassifierConfig
> {
static async build(
locales: Locale[],
modelsBaseUrl: string
): Promise<IntentModelSelector> {
const selector = new IntentModelSelector(locales, modelsBaseUrl)
static async build(locales: Locale[]): Promise<IntentModelSelector> {
const baseUrl: string =
// @ts-ignore
(typeof MODELS_BASE_URL !== 'undefined' && MODELS_BASE_URL) ||
process.env.MODELS_BASE_URL
const intentModelsUrl = `${baseUrl}/intent-classification/models`
const selector = new IntentModelSelector(locales, intentModelsUrl)
return await selector.load()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Locale } from '@botonic/nlp/lib/types'

export type PluginOptions = { locales: Locale[]; modelsBaseUrl: string }
export type PluginOptions = { locales: Locale[] }
5 changes: 1 addition & 4 deletions packages/botonic-plugin-ner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export default class BotonicPluginNER implements Plugin {
private modelsSelector: Promise<NerModelSelector>

constructor(readonly options: PluginOptions) {
this.modelsSelector = NerModelSelector.build(
this.options.locales,
this.options.modelsBaseUrl
)
this.modelsSelector = NerModelSelector.build(this.options.locales)
}

async pre(request: PluginPreRequest): Promise<void> {
Expand Down
12 changes: 7 additions & 5 deletions packages/botonic-plugin-ner/src/model/model-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export class NerModelSelector extends ModelSelector<
NamedEntityRecognizer,
NerConfig
> {
static async build(
locales: Locale[],
modelsBaseUrl: string
): Promise<NerModelSelector> {
const selector = new NerModelSelector(locales, modelsBaseUrl)
static async build(locales: Locale[]): Promise<NerModelSelector> {
const baseUrl: string =
// @ts-ignore
(typeof MODELS_BASE_URL !== 'undefined' && MODELS_BASE_URL) ||
process.env.MODELS_BASE_URL
const nerModelsUrl = `${baseUrl}/ner/models`
const selector = new NerModelSelector(locales, nerModelsUrl)
return await selector.load()
}

Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-plugin-ner/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Locale } from '@botonic/nlp/lib/types'

export type PluginOptions = { locales: Locale[]; modelsBaseUrl: string }
export type PluginOptions = { locales: Locale[] }

0 comments on commit 3df40fc

Please sign in to comment.