Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihturker committed May 18, 2023
1 parent 63372e4 commit 38f5ab4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 75 deletions.
4 changes: 2 additions & 2 deletions docs/ACTION-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ActionType } from '@pi-agi/core';
export enum ComposeActionType {
ADD_INSTRUMENT = 'addInstrument',
ADD_NOTE = 'addNote',
EXPORT_WAV = 'exportWav',
EXPORT_MIDI = 'exportMIDI',
}

export type MergedActionType = ActionType & ComposeActionType;
Expand Down Expand Up @@ -71,7 +71,7 @@ export class ComposeActionUtil implements Actionable<MergedActionType> {
action.input.duration
);
break;
case ComposeActionType.EXPORT_WAV:
case ComposeActionType.EXPORT_MIDI:
return await this.composeUtil.exportMIDI(action.input.name);
default:
throw new Error('Invalid action type');
Expand Down
76 changes: 3 additions & 73 deletions docs/AGI-CREATION-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,65 +32,7 @@ After the installation, you're ready to start creating your own AGI!

Actions are the building blocks of your AGI. Each action corresponds to a specific task or function that your AGI can perform. To create an action, you'll need to define it using the `Actionable` interface.

Here's a basic example:

### Actions

```javascript
import { ActionType } from '@pi-agi/core';

export enum ComposeActionType {
ADD_INSTRUMENT = 'addInstrument',
ADD_NOTE = 'addNote',
EXPORT_MIDI = 'exportMIDI',
}

export type MergedActionType = ActionType & ComposeActionType;
```

### Action Util

```javascript
import { Action, Actionable, LoggerUtil } from '@pi-agi/core';
import {
ComposeActionType,
MergedActionType,
} from '../enum/compose-action-type.enum';
import { ComposeUtil } from './compose.util';

export class ComposeActionUtil implements Actionable<MergedActionType> {
private composeUtil: ComposeUtil;

constructor(private taskDir: string, private loggerUtil: LoggerUtil) {
this.composeUtil = new ComposeUtil(this.taskDir, this.loggerUtil);
}

async takeAction(action: Action<MergedActionType>): Promise<any> {
try {
switch (action.type) {
case ComposeActionType.ADD_INSTRUMENT:
this.composeUtil.addInstrument(action.input.name);
break;
case ComposeActionType.ADD_NOTE:
this.composeUtil.addNote(
action.input.instrumentName,
action.input.note,
action.input.duration
);
break;
case ComposeActionType.EXPORT_WAV:
return await this.composeUtil.exportMIDI(action.input.name);
default:
throw new Error('Invalid action type');
}
} catch (e) {
return e;
}
}
}
```

For more detailed information about defining actions, check out our [Action Guide](LINK_TO_ACTION_GUIDE).
For more detailed information about defining actions, check out our [Action Guide](ACTION-GUIDE.md).

## Creating AGI

Expand Down Expand Up @@ -243,10 +185,8 @@ Ensure a JSON object is returned in the response, adhering to proper syntax and
Here you can find the Action Types; you should use string values in the 'type' field like 'addInstrument':
ComposeActionType {
ADD_INSTRUMENT = 'addInstrument',
SET_TEMPO = 'setTempo',
ADD_NOTE = 'addNote',
ADD_EFFECT = 'addEffect',
EXPORT_WAV = 'exportWav',
EXPORT_MIDI = 'exportMIDI',
}
Input is different for each action.
Expand All @@ -262,14 +202,6 @@ For 'addInstrument', the input will include the name of the instrument and optio
}
}
For 'setTempo', the input will include the beats per minute (bpm) value. Here is an example payload for 'setTempo':
{
"type": "setTempo",
"input": {
"bpm": "Beats per Minute"
}
}
For 'addNote', the input will include the instrument name, note and duration. Here is an example payload for 'addNote':
{
"type": "addNote",
Expand Down Expand Up @@ -325,10 +257,8 @@ Ensure a JSON object is returned in the response, adhering to proper syntax and
Here you can find the ComposeActionTypes; you should use string values in the 'type' field like 'addInstrument':
ComposeActionType {
ADD_INSTRUMENT = 'addInstrument',
SET_TEMPO = 'setTempo',
ADD_NOTE = 'addNote',
ADD_EFFECT = 'addEffect',
EXPORT_WAV = 'exportWav',
EXPORT_MIDI = 'exportMIDI',
}
Input is different for each action.
Expand Down

0 comments on commit 38f5ab4

Please sign in to comment.