microsoft / TypeChat

TypeChat is a library that makes it easy to build natural language interfaces using types.
https://microsoft.github.io/TypeChat/
MIT License
8.16k stars 390 forks source link

How to model classical NLU intents and entities(slots)? #133

Open rmtuckerphx opened 11 months ago

rmtuckerphx commented 11 months ago

The calendar example's actions are similar to intents that one would define for Dialogflow or Alexa. How to use OpenAI as an intent NLU engine?

The issue is that "yes" and "yes, please" matches the YesIntent but "ok" or other affirmative responses do not.

Inputs:

Type schema:

// The following types define the structure of an object of type BotIntent that represents a user request that matches most closely to the sample or synonyms

export type BotIntent = YesIntent | NoIntent | UnknownIntent;

// if the user types text that closely matches 'yes' or a synonym, this intent is used
export type YesIntent = {
  intentName: 'YesIntent';
  sample: 'yes';
  text: string;
};

// if the user types text that closely matches 'no' or a synonym, this intent is used
export type NoIntent = {
  intentName: 'NoIntent';
  sample: 'no';
  text: string;
};

// if the user types text that can not easily be understood as a bot intent, this intent is used
export interface UnknownIntent {
  intentName: 'UnknownIntent';
  sample: 'unknown';
  // text typed by the user that the system did not understand
  text: string;
}

How to model more complicated intents with required and optional entities?