Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP implement IBIS1 starter #1

Merged
merged 42 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f66ef8f
WIP implement IBIS1 starter
vladmaraev Aug 16, 2024
cd410e2
One object for rules
vladmaraev Aug 17, 2024
7e9b39e
Implement domain and isu rules
vladmaraev Aug 18, 2024
66eba57
Add abstraction over isu state transitions
vladmaraev Aug 20, 2024
7b14053
Add integrate_usr_request rule and a simple plan
alex-berman Aug 20, 2024
9c0fd8f
Decouple DME
vladmaraev Aug 20, 2024
945208b
Add basic test
vladmaraev Aug 20, 2024
4188413
Fix basic test, add example of a failing test
vladmaraev Aug 21, 2024
48cce6b
Start with documentation
vladmaraev Aug 22, 2024
17bc817
Make sendBackNextMove optional (default=false)
vladmaraev Aug 22, 2024
bbb9754
Rename a test
alex-berman Sep 6, 2024
1654bf4
Rename "effects" to "result"
alex-berman Sep 6, 2024
d078692
Remove failing test
alex-berman Sep 6, 2024
ce303b2
Add DME test: system question from plan
alex-berman Sep 6, 2024
271da78
DME tests: Add abstraction
alex-berman Sep 6, 2024
8e57067
Make Proposition more structured
alex-berman Sep 6, 2024
bef2deb
Fix syntax error in isu.ts
alex-berman Sep 6, 2024
2e5b14f
Share initial IS across production and test code
alex-berman Sep 6, 2024
6595e45
Declare type of initial IS
alex-berman Sep 6, 2024
92108a4
Treat relevance and resolve relations as functions
alex-berman Sep 6, 2024
81d0d07
Add plan that addresses question
alex-berman Sep 6, 2024
1f2b5eb
WIP Add exec_consultDB
alex-berman Sep 8, 2024
9e256d6
WIP Add exec_consultDB
alex-berman Sep 8, 2024
298546d
WIP Add exec_consultDB
alex-berman Sep 8, 2024
cdb069c
Add sorts, predicates and individuals
alex-berman Sep 9, 2024
68a9a5a
Make NLU case-insensitive
alex-berman Sep 9, 2024
f9b3bb8
Make rule definitions more concise
alex-berman Sep 9, 2024
805ae0b
Represent WHQ as object
alex-berman Sep 9, 2024
d187f44
Add utils for defining plan items
alex-berman Sep 9, 2024
7b51ff3
Plans: rename "question" to "issue"
alex-berman Sep 9, 2024
f6da9fd
Elevate logging of updateLatestMove and rules to info
alex-berman Sep 10, 2024
9b9b7f2
Send SAYS before notification of a test leg
vladmaraev Sep 10, 2024
10adaad
Solve bugs in remove_findout
alex-berman Sep 10, 2024
44a621c
Fix most of type errors
vladmaraev Sep 10, 2024
996a88a
Optimise some type inferences
vladmaraev Sep 10, 2024
33dbe6d
Disable simulated user input
alex-berman Sep 11, 2024
416a29f
Run select only after user has spoken
alex-berman Sep 11, 2024
7dcb6d1
Repeat ExecPlan
alex-berman Sep 11, 2024
cd4c58d
Fix bug in exec_consultDB
alex-berman Sep 11, 2024
fe117ff
Make nlgMapping more concise
alex-berman Sep 11, 2024
9bd1b55
Fix type errors
vladmaraev Sep 11, 2024
9f32ce2
toggle off azure imports
vladmaraev Sep 11, 2024
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
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"preview": "vite preview",
"test": "vitest"
},
"devDependencies": {
"typescript": "^5.2.2",
"vite": "^5.2.0"
"vite": "^5.2.0",
"vitest": "^2.0.5"
},
"dependencies": {
"@statelyai/inspect": "^0.2.5",
"speechstate": "^2.0.5"
}
"speechstate": "^2.4.0"
},
"packageManager": "[email protected]+sha256.7f7d51b38db0d94adf25c512e3f3d3b47d23c97922eecc540f7440f116bdb99a"
}
17 changes: 8 additions & 9 deletions src/main.ts → src/dipper/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assign, createActor, setup, AnyMachineSnapshot } from "xstate";
import { speechstate } from "speechstate";
import { createBrowserInspector } from "@statelyai/inspect";
import { KEY } from "./azure";
import { KEY } from "../azure";

const inspector = createBrowserInspector();

Expand All @@ -17,6 +17,7 @@ const settings = {
asrDefaultNoInputTimeout: 5000,
locale: "en-US",
ttsDefaultVoice: "en-US-DavisNeural",
azureRegion: "northeurope",
};

const dmMachine = setup({
Expand Down Expand Up @@ -86,19 +87,17 @@ const dmMachine = setup({
};
},
}).createMachine({
context: {
is: { input: ["ping"], output: [] },
context: ({ spawn }) => {
return {
ssRef: spawn(speechstate, { input: settings }),
is: { input: ["ping"], output: [] },
};
},
id: "DM",
initial: "Prepare",
states: {
Prepare: {
entry: [
assign({
ssRef: ({ spawn }) => spawn(speechstate, { input: settings }),
}),
({ context }) => context.ssRef.send({ type: "PREPARE" }),
],
entry: ({ context }) => context.ssRef.send({ type: "PREPARE" }),
on: { ASRTTS_READY: "WaitToStart" },
},
WaitToStart: {
Expand Down
127 changes: 127 additions & 0 deletions src/dme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { setup, assign, sendTo, AnyTransitionConfig } from "xstate";
import { rules } from "./rules";
import { SaysMoveEvent, DMEEvent, DMEContext } from "./types";

function isuTransition(
nextState: string,
ruleName: string,
nextMove: boolean,
): AnyTransitionConfig {
return {
target: nextState,
guard: { type: "isu", params: { name: ruleName } },
actions: nextMove
? [
{ type: "isu", params: { name: ruleName } },
{ type: "sendBackNextMove" },
]
: [{ type: "isu", params: { name: ruleName } }],
};
}

export const dme = setup({
types: {} as {
input: DMEContext;
context: DMEContext;
events: DMEEvent;
},
guards: {
isu: ({ context }, params: { name: string }) =>
rules[params.name](context).preconditions,
},
actions: {
sendBackNextMove: sendTo(
({ context }) => context.parentRef,
({ context }) => {
return {
type: "NEXT_MOVE",
value: context.is.next_move,
};
},
),
isu: assign(({ context }, params: { name: string }) => {
return { is: rules[params.name](context).effects };
}),
updateLatestMove: assign(({ event }) => {
console.debug("[DM updateLatestMove]", event);
return {
latest_move: (event as SaysMoveEvent).value.move,
latest_speaker: (event as SaysMoveEvent).value.speaker,
};
}),
},
}).createMachine({
context: ({ input }) => {
return input;
},
initial: "Select",
states: {
Select: {
initial: "SelectAction",
states: {
SelectAction: {
always: [
isuTransition("SelectMove", "select_respond", false),
isuTransition("SelectMove", "select_from_plan", false),
{ target: "SelectMove" }, // TODO check it -- needed for greeting
],
},
SelectMove: {
always: [
isuTransition("SelectionDone", "select_ask", true),
isuTransition("SelectionDone", "select_answer", true),
isuTransition("SelectionDone", "select_other", true),
{ target: "SelectionDone" },
],
},
SelectionDone: { type: "final" },
},
onDone: "Update",
},
Update: {
initial: "Init",
states: {
Init: {
always: isuTransition("Grounding", "clear_agenda", false),
},
Grounding: {
// TODO: rename to Perception?
on: {
SAYS: {
target: "Integrate",
actions: [
{
type: "updateLatestMove",
},
{ type: "isu", params: { name: "get_latest_move" } },
],
},
},
},
Integrate: {
always: [
isuTransition("DowndateQUD", "integrate_usr_request", false),
isuTransition("DowndateQUD", "integrate_sys_ask", false),
isuTransition("DowndateQUD", "integrate_usr_ask", false),
isuTransition("DowndateQUD", "integrate_greet", false),
],
},
DowndateQUD: {
always: [
isuTransition("LoadPlan", "downdate_qud", false),
{ target: "LoadPlan" },
],
},
LoadPlan: {
always: { target: "ExecPlan" },
},
ExecPlan: {
type: "final",
},
},
onDone: {
target: "Select",
},
},
},
});
Loading