@microsoft/teams.ai 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/citation.d.mts +19 -0
- package/dist/citation.d.ts +19 -0
- package/dist/citation.js +4 -0
- package/dist/citation.js.map +1 -0
- package/dist/citation.mjs +3 -0
- package/dist/citation.mjs.map +1 -0
- package/dist/function.d.mts +18 -0
- package/dist/function.d.ts +18 -0
- package/dist/function.js +4 -0
- package/dist/function.js.map +1 -0
- package/dist/function.mjs +3 -0
- package/dist/function.mjs.map +1 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -0
- package/dist/local-memory.d.mts +32 -0
- package/dist/local-memory.d.ts +32 -0
- package/dist/local-memory.js +78 -0
- package/dist/local-memory.js.map +1 -0
- package/dist/local-memory.mjs +76 -0
- package/dist/local-memory.mjs.map +1 -0
- package/dist/memory.d.mts +11 -0
- package/dist/memory.d.ts +11 -0
- package/dist/memory.js +4 -0
- package/dist/memory.js.map +1 -0
- package/dist/memory.mjs +3 -0
- package/dist/memory.mjs.map +1 -0
- package/dist/message.d.mts +76 -0
- package/dist/message.d.ts +76 -0
- package/dist/message.js +4 -0
- package/dist/message.js.map +1 -0
- package/dist/message.mjs +3 -0
- package/dist/message.mjs.map +1 -0
- package/dist/models/audio.d.mts +27 -0
- package/dist/models/audio.d.ts +27 -0
- package/dist/models/audio.js +4 -0
- package/dist/models/audio.js.map +1 -0
- package/dist/models/audio.mjs +3 -0
- package/dist/models/audio.mjs.map +1 -0
- package/dist/models/chat.d.mts +46 -0
- package/dist/models/chat.d.ts +46 -0
- package/dist/models/chat.js +4 -0
- package/dist/models/chat.js.map +1 -0
- package/dist/models/chat.mjs +3 -0
- package/dist/models/chat.mjs.map +1 -0
- package/dist/models/image.d.mts +22 -0
- package/dist/models/image.d.ts +22 -0
- package/dist/models/image.js +4 -0
- package/dist/models/image.js.map +1 -0
- package/dist/models/image.mjs +3 -0
- package/dist/models/image.mjs.map +1 -0
- package/dist/models/index.d.mts +16 -0
- package/dist/models/index.d.ts +16 -0
- package/dist/models/index.js +28 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/index.mjs +5 -0
- package/dist/models/index.mjs.map +1 -0
- package/dist/prompts/audio.d.mts +54 -0
- package/dist/prompts/audio.d.ts +54 -0
- package/dist/prompts/audio.js +34 -0
- package/dist/prompts/audio.js.map +1 -0
- package/dist/prompts/audio.mjs +32 -0
- package/dist/prompts/audio.mjs.map +1 -0
- package/dist/prompts/chat.d.mts +146 -0
- package/dist/prompts/chat.d.ts +146 -0
- package/dist/prompts/chat.js +162 -0
- package/dist/prompts/chat.js.map +1 -0
- package/dist/prompts/chat.mjs +160 -0
- package/dist/prompts/chat.mjs.map +1 -0
- package/dist/prompts/index.d.mts +18 -0
- package/dist/prompts/index.d.ts +18 -0
- package/dist/prompts/index.js +21 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/index.mjs +4 -0
- package/dist/prompts/index.mjs.map +1 -0
- package/dist/prompts/plugin.d.mts +26 -0
- package/dist/prompts/plugin.d.ts +26 -0
- package/dist/prompts/plugin.js +4 -0
- package/dist/prompts/plugin.js.map +1 -0
- package/dist/prompts/plugin.mjs +3 -0
- package/dist/prompts/plugin.mjs.map +1 -0
- package/dist/schema.d.mts +46 -0
- package/dist/schema.d.ts +46 -0
- package/dist/schema.js +4 -0
- package/dist/schema.js.map +1 -0
- package/dist/schema.mjs +3 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/template.d.mts +13 -0
- package/dist/template.d.ts +13 -0
- package/dist/template.js +4 -0
- package/dist/template.js.map +1 -0
- package/dist/template.mjs +3 -0
- package/dist/template.mjs.map +1 -0
- package/dist/templates/index.d.mts +2 -0
- package/dist/templates/index.d.ts +2 -0
- package/dist/templates/index.js +14 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/index.mjs +3 -0
- package/dist/templates/index.mjs.map +1 -0
- package/dist/templates/string.d.mts +9 -0
- package/dist/templates/string.d.ts +9 -0
- package/dist/templates/string.js +14 -0
- package/dist/templates/string.js.map +1 -0
- package/dist/templates/string.mjs +12 -0
- package/dist/templates/string.mjs.map +1 -0
- package/dist/utils/types.d.mts +5 -0
- package/dist/utils/types.d.ts +5 -0
- package/dist/utils/types.js +4 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/types.mjs +3 -0
- package/dist/utils/types.mjs.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Citation } from './citation.js';
|
|
2
|
+
import { FunctionCall } from './function.js';
|
|
3
|
+
import './schema.js';
|
|
4
|
+
|
|
5
|
+
type Message = UserMessage | ModelMessage | SystemMessage | FunctionMessage;
|
|
6
|
+
type UserMessage = {
|
|
7
|
+
role: 'user';
|
|
8
|
+
content: string | ContentPart[];
|
|
9
|
+
};
|
|
10
|
+
type ModelMessage = {
|
|
11
|
+
role: 'model';
|
|
12
|
+
audio?: MessageAudio;
|
|
13
|
+
content?: string;
|
|
14
|
+
context?: MessageContext;
|
|
15
|
+
function_calls?: FunctionCall[];
|
|
16
|
+
};
|
|
17
|
+
type SystemMessage = {
|
|
18
|
+
role: 'system';
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
type FunctionMessage = {
|
|
22
|
+
role: 'function';
|
|
23
|
+
content?: string;
|
|
24
|
+
function_id: string;
|
|
25
|
+
};
|
|
26
|
+
type ContentPart = TextContentPart | ImageContentPart;
|
|
27
|
+
type TextContentPart = {
|
|
28
|
+
type: 'text';
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
type ImageContentPart = {
|
|
32
|
+
type: 'image_url';
|
|
33
|
+
image_url: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A representation of the additional context information available when Azure OpenAI chat extensions are involved
|
|
37
|
+
* in the generation of a corresponding chat completions response. This context information is only populated when
|
|
38
|
+
* using an Azure OpenAI request configured to use a matching extension.
|
|
39
|
+
*/
|
|
40
|
+
type MessageContext = {
|
|
41
|
+
/**
|
|
42
|
+
* The contextual information associated with the Azure chat extensions used for a chat completions request.
|
|
43
|
+
* These messages describe the data source retrievals, plugin invocations, and other intermediate steps taken in the
|
|
44
|
+
* course of generating a chat completions response that was augmented by capabilities from Azure OpenAI chat
|
|
45
|
+
* extensions.
|
|
46
|
+
*/
|
|
47
|
+
citations?: Array<Citation>;
|
|
48
|
+
/** The detected intent from the chat history, used to pass to the next turn to carry over the context. */
|
|
49
|
+
intent?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* If the audio output modality is requested, this object contains data about the
|
|
53
|
+
* audio response from the model.
|
|
54
|
+
*/
|
|
55
|
+
type MessageAudio = {
|
|
56
|
+
/**
|
|
57
|
+
* Unique identifier for this audio response.
|
|
58
|
+
*/
|
|
59
|
+
id: string;
|
|
60
|
+
/**
|
|
61
|
+
* Base64 encoded audio bytes generated by the model, in the format specified in
|
|
62
|
+
* the request.
|
|
63
|
+
*/
|
|
64
|
+
data: string;
|
|
65
|
+
/**
|
|
66
|
+
* The Unix timestamp (in seconds) for when this audio response will no longer be
|
|
67
|
+
* accessible on the server for use in multi-turn conversations.
|
|
68
|
+
*/
|
|
69
|
+
expires_at: number;
|
|
70
|
+
/**
|
|
71
|
+
* Transcript of the audio generated by the model.
|
|
72
|
+
*/
|
|
73
|
+
transcript: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type { ContentPart, FunctionMessage, ImageContentPart, Message, MessageAudio, MessageContext, ModelMessage, SystemMessage, TextContentPart, UserMessage };
|
package/dist/message.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"message.js"}
|
package/dist/message.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"message.mjs"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type TextToAudioParams = {
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly voice: string;
|
|
5
|
+
};
|
|
6
|
+
type AudioToTextParams = {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly data: Buffer;
|
|
9
|
+
readonly prompt?: string;
|
|
10
|
+
readonly lang?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* a model that can convert text to audio
|
|
14
|
+
* or audio to text
|
|
15
|
+
*/
|
|
16
|
+
interface IAudioModel {
|
|
17
|
+
/**
|
|
18
|
+
* convert text to audio
|
|
19
|
+
*/
|
|
20
|
+
textToAudio?(params: TextToAudioParams): Promise<Buffer>;
|
|
21
|
+
/**
|
|
22
|
+
* transcribe audio to text
|
|
23
|
+
*/
|
|
24
|
+
audioToText?(params: AudioToTextParams): Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type { AudioToTextParams, IAudioModel, TextToAudioParams };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type TextToAudioParams = {
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly voice: string;
|
|
5
|
+
};
|
|
6
|
+
type AudioToTextParams = {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly data: Buffer;
|
|
9
|
+
readonly prompt?: string;
|
|
10
|
+
readonly lang?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* a model that can convert text to audio
|
|
14
|
+
* or audio to text
|
|
15
|
+
*/
|
|
16
|
+
interface IAudioModel {
|
|
17
|
+
/**
|
|
18
|
+
* convert text to audio
|
|
19
|
+
*/
|
|
20
|
+
textToAudio?(params: TextToAudioParams): Promise<Buffer>;
|
|
21
|
+
/**
|
|
22
|
+
* transcribe audio to text
|
|
23
|
+
*/
|
|
24
|
+
audioToText?(params: AudioToTextParams): Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type { AudioToTextParams, IAudioModel, TextToAudioParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"audio.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"audio.mjs"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Function } from '../function.mjs';
|
|
2
|
+
import { IMemory } from '../memory.mjs';
|
|
3
|
+
import { Message, SystemMessage, UserMessage, ModelMessage } from '../message.mjs';
|
|
4
|
+
import '../schema.mjs';
|
|
5
|
+
import '@microsoft/teams.common';
|
|
6
|
+
import '../citation.mjs';
|
|
7
|
+
|
|
8
|
+
type TextChunkHandler = (chunk: string) => void | Promise<void>;
|
|
9
|
+
type ChatSendOptions<TOptions = Record<string, any>> = {
|
|
10
|
+
/**
|
|
11
|
+
* the initial system/user message that defines
|
|
12
|
+
* model behavior
|
|
13
|
+
*/
|
|
14
|
+
readonly system?: SystemMessage | UserMessage;
|
|
15
|
+
/**
|
|
16
|
+
* the conversation history
|
|
17
|
+
*/
|
|
18
|
+
readonly messages?: IMemory;
|
|
19
|
+
/**
|
|
20
|
+
* the registered functions
|
|
21
|
+
*/
|
|
22
|
+
readonly functions?: Record<string, Function>;
|
|
23
|
+
/**
|
|
24
|
+
* the request option overrides
|
|
25
|
+
*/
|
|
26
|
+
readonly request?: TOptions;
|
|
27
|
+
/**
|
|
28
|
+
* the handler to call with each
|
|
29
|
+
* stream chunk
|
|
30
|
+
*/
|
|
31
|
+
readonly onChunk?: TextChunkHandler;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* a conversational model for sending and receiving
|
|
35
|
+
* messages
|
|
36
|
+
*/
|
|
37
|
+
interface IChatModel<TOptions = Record<string, any>> {
|
|
38
|
+
/**
|
|
39
|
+
* send a message to the model
|
|
40
|
+
* @param input the message to send
|
|
41
|
+
* @param options the send options
|
|
42
|
+
*/
|
|
43
|
+
send(input: Message, options?: ChatSendOptions<TOptions>): Promise<ModelMessage>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type { ChatSendOptions, IChatModel, TextChunkHandler };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Function } from '../function.js';
|
|
2
|
+
import { IMemory } from '../memory.js';
|
|
3
|
+
import { Message, SystemMessage, UserMessage, ModelMessage } from '../message.js';
|
|
4
|
+
import '../schema.js';
|
|
5
|
+
import '@microsoft/teams.common';
|
|
6
|
+
import '../citation.js';
|
|
7
|
+
|
|
8
|
+
type TextChunkHandler = (chunk: string) => void | Promise<void>;
|
|
9
|
+
type ChatSendOptions<TOptions = Record<string, any>> = {
|
|
10
|
+
/**
|
|
11
|
+
* the initial system/user message that defines
|
|
12
|
+
* model behavior
|
|
13
|
+
*/
|
|
14
|
+
readonly system?: SystemMessage | UserMessage;
|
|
15
|
+
/**
|
|
16
|
+
* the conversation history
|
|
17
|
+
*/
|
|
18
|
+
readonly messages?: IMemory;
|
|
19
|
+
/**
|
|
20
|
+
* the registered functions
|
|
21
|
+
*/
|
|
22
|
+
readonly functions?: Record<string, Function>;
|
|
23
|
+
/**
|
|
24
|
+
* the request option overrides
|
|
25
|
+
*/
|
|
26
|
+
readonly request?: TOptions;
|
|
27
|
+
/**
|
|
28
|
+
* the handler to call with each
|
|
29
|
+
* stream chunk
|
|
30
|
+
*/
|
|
31
|
+
readonly onChunk?: TextChunkHandler;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* a conversational model for sending and receiving
|
|
35
|
+
* messages
|
|
36
|
+
*/
|
|
37
|
+
interface IChatModel<TOptions = Record<string, any>> {
|
|
38
|
+
/**
|
|
39
|
+
* send a message to the model
|
|
40
|
+
* @param input the message to send
|
|
41
|
+
* @param options the send options
|
|
42
|
+
*/
|
|
43
|
+
send(input: Message, options?: ChatSendOptions<TOptions>): Promise<ModelMessage>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type { ChatSendOptions, IChatModel, TextChunkHandler };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chat.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chat.mjs"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type TextToImageParams = {
|
|
2
|
+
/**
|
|
3
|
+
* the prompt that defines how
|
|
4
|
+
* the image should be made
|
|
5
|
+
*/
|
|
6
|
+
readonly prompt?: string;
|
|
7
|
+
/**
|
|
8
|
+
* the desired size of the image
|
|
9
|
+
*/
|
|
10
|
+
readonly size?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* a model that can generate an image from text
|
|
14
|
+
*/
|
|
15
|
+
interface IImageModel {
|
|
16
|
+
/**
|
|
17
|
+
* generate an image from text
|
|
18
|
+
*/
|
|
19
|
+
textToImage?(params?: TextToImageParams): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type { IImageModel, TextToImageParams };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type TextToImageParams = {
|
|
2
|
+
/**
|
|
3
|
+
* the prompt that defines how
|
|
4
|
+
* the image should be made
|
|
5
|
+
*/
|
|
6
|
+
readonly prompt?: string;
|
|
7
|
+
/**
|
|
8
|
+
* the desired size of the image
|
|
9
|
+
*/
|
|
10
|
+
readonly size?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* a model that can generate an image from text
|
|
14
|
+
*/
|
|
15
|
+
interface IImageModel {
|
|
16
|
+
/**
|
|
17
|
+
* generate an image from text
|
|
18
|
+
*/
|
|
19
|
+
textToImage?(params?: TextToImageParams): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type { IImageModel, TextToImageParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"image.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"image.mjs"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IAudioModel } from './audio.mjs';
|
|
2
|
+
export { AudioToTextParams, TextToAudioParams } from './audio.mjs';
|
|
3
|
+
import { IImageModel } from './image.mjs';
|
|
4
|
+
export { TextToImageParams } from './image.mjs';
|
|
5
|
+
import { IChatModel } from './chat.mjs';
|
|
6
|
+
export { ChatSendOptions, TextChunkHandler } from './chat.mjs';
|
|
7
|
+
import '../function.mjs';
|
|
8
|
+
import '../schema.mjs';
|
|
9
|
+
import '../memory.mjs';
|
|
10
|
+
import '@microsoft/teams.common';
|
|
11
|
+
import '../message.mjs';
|
|
12
|
+
import '../citation.mjs';
|
|
13
|
+
|
|
14
|
+
type Model = IChatModel | IAudioModel | IImageModel;
|
|
15
|
+
|
|
16
|
+
export { IAudioModel, IChatModel, IImageModel, type Model };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IAudioModel } from './audio.js';
|
|
2
|
+
export { AudioToTextParams, TextToAudioParams } from './audio.js';
|
|
3
|
+
import { IImageModel } from './image.js';
|
|
4
|
+
export { TextToImageParams } from './image.js';
|
|
5
|
+
import { IChatModel } from './chat.js';
|
|
6
|
+
export { ChatSendOptions, TextChunkHandler } from './chat.js';
|
|
7
|
+
import '../function.js';
|
|
8
|
+
import '../schema.js';
|
|
9
|
+
import '../memory.js';
|
|
10
|
+
import '@microsoft/teams.common';
|
|
11
|
+
import '../message.js';
|
|
12
|
+
import '../citation.js';
|
|
13
|
+
|
|
14
|
+
type Model = IChatModel | IAudioModel | IImageModel;
|
|
15
|
+
|
|
16
|
+
export { IAudioModel, IChatModel, IImageModel, type Model };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chat = require('./chat');
|
|
4
|
+
var audio = require('./audio');
|
|
5
|
+
var image = require('./image');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(chat).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chat[k]; }
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
Object.keys(audio).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return audio[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
Object.keys(image).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return image[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs","sourcesContent":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IAudioModel, TextToAudioParams, AudioToTextParams } from '../models/audio.mjs';
|
|
2
|
+
|
|
3
|
+
type AudioPromptOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* the name of the prompt
|
|
6
|
+
*/
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* the description of the prompt
|
|
10
|
+
*/
|
|
11
|
+
readonly description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* the model to send requests to
|
|
14
|
+
*/
|
|
15
|
+
readonly model: IAudioModel;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* a prompt that can interface with
|
|
19
|
+
* an audio model
|
|
20
|
+
*/
|
|
21
|
+
interface IAudioPrompt {
|
|
22
|
+
/**
|
|
23
|
+
* the prompt name
|
|
24
|
+
*/
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/**
|
|
27
|
+
* the prompt description
|
|
28
|
+
*/
|
|
29
|
+
readonly description: string;
|
|
30
|
+
/**
|
|
31
|
+
* convert text to audio
|
|
32
|
+
*/
|
|
33
|
+
textToAudio?(params: TextToAudioParams): Promise<Buffer>;
|
|
34
|
+
/**
|
|
35
|
+
* transcribe audio to text
|
|
36
|
+
*/
|
|
37
|
+
audioToText?(params: AudioToTextParams): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* a prompt that can interface with
|
|
41
|
+
* an audio model
|
|
42
|
+
*/
|
|
43
|
+
declare class AudioPrompt implements IAudioPrompt {
|
|
44
|
+
get name(): string;
|
|
45
|
+
protected readonly _name: string;
|
|
46
|
+
get description(): string;
|
|
47
|
+
protected readonly _description: string;
|
|
48
|
+
protected readonly _model: IAudioModel;
|
|
49
|
+
constructor(options: AudioPromptOptions);
|
|
50
|
+
audioToText(params: AudioToTextParams): Promise<string>;
|
|
51
|
+
textToAudio(params: TextToAudioParams): Promise<Buffer<ArrayBufferLike>>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { AudioPrompt, type AudioPromptOptions, type IAudioPrompt };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IAudioModel, TextToAudioParams, AudioToTextParams } from '../models/audio.js';
|
|
2
|
+
|
|
3
|
+
type AudioPromptOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* the name of the prompt
|
|
6
|
+
*/
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* the description of the prompt
|
|
10
|
+
*/
|
|
11
|
+
readonly description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* the model to send requests to
|
|
14
|
+
*/
|
|
15
|
+
readonly model: IAudioModel;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* a prompt that can interface with
|
|
19
|
+
* an audio model
|
|
20
|
+
*/
|
|
21
|
+
interface IAudioPrompt {
|
|
22
|
+
/**
|
|
23
|
+
* the prompt name
|
|
24
|
+
*/
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/**
|
|
27
|
+
* the prompt description
|
|
28
|
+
*/
|
|
29
|
+
readonly description: string;
|
|
30
|
+
/**
|
|
31
|
+
* convert text to audio
|
|
32
|
+
*/
|
|
33
|
+
textToAudio?(params: TextToAudioParams): Promise<Buffer>;
|
|
34
|
+
/**
|
|
35
|
+
* transcribe audio to text
|
|
36
|
+
*/
|
|
37
|
+
audioToText?(params: AudioToTextParams): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* a prompt that can interface with
|
|
41
|
+
* an audio model
|
|
42
|
+
*/
|
|
43
|
+
declare class AudioPrompt implements IAudioPrompt {
|
|
44
|
+
get name(): string;
|
|
45
|
+
protected readonly _name: string;
|
|
46
|
+
get description(): string;
|
|
47
|
+
protected readonly _description: string;
|
|
48
|
+
protected readonly _model: IAudioModel;
|
|
49
|
+
constructor(options: AudioPromptOptions);
|
|
50
|
+
audioToText(params: AudioToTextParams): Promise<string>;
|
|
51
|
+
textToAudio(params: TextToAudioParams): Promise<Buffer<ArrayBufferLike>>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { AudioPrompt, type AudioPromptOptions, type IAudioPrompt };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class AudioPrompt {
|
|
4
|
+
get name() {
|
|
5
|
+
return this._name;
|
|
6
|
+
}
|
|
7
|
+
_name;
|
|
8
|
+
get description() {
|
|
9
|
+
return this._description;
|
|
10
|
+
}
|
|
11
|
+
_description;
|
|
12
|
+
_model;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this._name = options.name || "audio";
|
|
15
|
+
this._description = options.description || "an agent that can convert text to speech";
|
|
16
|
+
this._model = options.model;
|
|
17
|
+
}
|
|
18
|
+
audioToText(params) {
|
|
19
|
+
if (!this._model.audioToText) {
|
|
20
|
+
throw new Error("cannot transcribe audio to text");
|
|
21
|
+
}
|
|
22
|
+
return this._model.audioToText(params);
|
|
23
|
+
}
|
|
24
|
+
textToAudio(params) {
|
|
25
|
+
if (!this._model.textToAudio) {
|
|
26
|
+
throw new Error("cannot translate text to audio");
|
|
27
|
+
}
|
|
28
|
+
return this._model.textToAudio(params);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.AudioPrompt = AudioPrompt;
|
|
33
|
+
//# sourceMappingURL=audio.js.map
|
|
34
|
+
//# sourceMappingURL=audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/prompts/audio.ts"],"names":[],"mappings":";;AAiDO,MAAM,WAAoC,CAAA;AAAA,EAC/C,IAAI,IAAO,GAAA;AACT,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd,EACmB,KAAA;AAAA,EAEnB,IAAI,WAAc,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,YAAA;AAAA;AACd,EACmB,YAAA;AAAA,EAEA,MAAA;AAAA,EAEnB,YAAY,OAA6B,EAAA;AACvC,IAAK,IAAA,CAAA,KAAA,GAAQ,QAAQ,IAAQ,IAAA,OAAA;AAC7B,IAAK,IAAA,CAAA,YAAA,GAAe,QAAQ,WAAe,IAAA,0CAAA;AAC3C,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,KAAA;AAAA;AACxB,EAEA,YAAY,MAA2B,EAAA;AACrC,IAAI,IAAA,CAAC,IAAK,CAAA,MAAA,CAAO,WAAa,EAAA;AAC5B,MAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA;AAAA;AAGnD,IAAO,OAAA,IAAA,CAAK,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA;AAAA;AACvC,EAEA,YAAY,MAA2B,EAAA;AACrC,IAAI,IAAA,CAAC,IAAK,CAAA,MAAA,CAAO,WAAa,EAAA;AAC5B,MAAM,MAAA,IAAI,MAAM,gCAAgC,CAAA;AAAA;AAGlD,IAAO,OAAA,IAAA,CAAK,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA;AAAA;AAEzC","file":"audio.js","sourcesContent":["import { IAudioModel, AudioToTextParams, TextToAudioParams } from '../models';\n\nexport type AudioPromptOptions = {\n /**\n * the name of the prompt\n */\n readonly name?: string;\n\n /**\n * the description of the prompt\n */\n readonly description?: string;\n\n /**\n * the model to send requests to\n */\n readonly model: IAudioModel;\n};\n\n/**\n * a prompt that can interface with\n * an audio model\n */\nexport interface IAudioPrompt {\n /**\n * the prompt name\n */\n readonly name: string;\n\n /**\n * the prompt description\n */\n readonly description: string;\n\n /**\n * convert text to audio\n */\n textToAudio?(params: TextToAudioParams): Promise<Buffer>;\n\n /**\n * transcribe audio to text\n */\n audioToText?(params: AudioToTextParams): Promise<string>;\n}\n\n/**\n * a prompt that can interface with\n * an audio model\n */\nexport class AudioPrompt implements IAudioPrompt {\n get name() {\n return this._name;\n }\n protected readonly _name: string;\n\n get description() {\n return this._description;\n }\n protected readonly _description: string;\n\n protected readonly _model: IAudioModel;\n\n constructor(options: AudioPromptOptions) {\n this._name = options.name || 'audio';\n this._description = options.description || 'an agent that can convert text to speech';\n this._model = options.model;\n }\n\n audioToText(params: AudioToTextParams) {\n if (!this._model.audioToText) {\n throw new Error('cannot transcribe audio to text');\n }\n\n return this._model.audioToText(params);\n }\n\n textToAudio(params: TextToAudioParams) {\n if (!this._model.textToAudio) {\n throw new Error('cannot translate text to audio');\n }\n\n return this._model.textToAudio(params);\n }\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class AudioPrompt {
|
|
2
|
+
get name() {
|
|
3
|
+
return this._name;
|
|
4
|
+
}
|
|
5
|
+
_name;
|
|
6
|
+
get description() {
|
|
7
|
+
return this._description;
|
|
8
|
+
}
|
|
9
|
+
_description;
|
|
10
|
+
_model;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this._name = options.name || "audio";
|
|
13
|
+
this._description = options.description || "an agent that can convert text to speech";
|
|
14
|
+
this._model = options.model;
|
|
15
|
+
}
|
|
16
|
+
audioToText(params) {
|
|
17
|
+
if (!this._model.audioToText) {
|
|
18
|
+
throw new Error("cannot transcribe audio to text");
|
|
19
|
+
}
|
|
20
|
+
return this._model.audioToText(params);
|
|
21
|
+
}
|
|
22
|
+
textToAudio(params) {
|
|
23
|
+
if (!this._model.textToAudio) {
|
|
24
|
+
throw new Error("cannot translate text to audio");
|
|
25
|
+
}
|
|
26
|
+
return this._model.textToAudio(params);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { AudioPrompt };
|
|
31
|
+
//# sourceMappingURL=audio.mjs.map
|
|
32
|
+
//# sourceMappingURL=audio.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/prompts/audio.ts"],"names":[],"mappings":"AAiDO,MAAM,WAAoC,CAAA;AAAA,EAC/C,IAAI,IAAO,GAAA;AACT,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AACd,EACmB,KAAA;AAAA,EAEnB,IAAI,WAAc,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,YAAA;AAAA;AACd,EACmB,YAAA;AAAA,EAEA,MAAA;AAAA,EAEnB,YAAY,OAA6B,EAAA;AACvC,IAAK,IAAA,CAAA,KAAA,GAAQ,QAAQ,IAAQ,IAAA,OAAA;AAC7B,IAAK,IAAA,CAAA,YAAA,GAAe,QAAQ,WAAe,IAAA,0CAAA;AAC3C,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,KAAA;AAAA;AACxB,EAEA,YAAY,MAA2B,EAAA;AACrC,IAAI,IAAA,CAAC,IAAK,CAAA,MAAA,CAAO,WAAa,EAAA;AAC5B,MAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA;AAAA;AAGnD,IAAO,OAAA,IAAA,CAAK,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA;AAAA;AACvC,EAEA,YAAY,MAA2B,EAAA;AACrC,IAAI,IAAA,CAAC,IAAK,CAAA,MAAA,CAAO,WAAa,EAAA;AAC5B,MAAM,MAAA,IAAI,MAAM,gCAAgC,CAAA;AAAA;AAGlD,IAAO,OAAA,IAAA,CAAK,MAAO,CAAA,WAAA,CAAY,MAAM,CAAA;AAAA;AAEzC","file":"audio.mjs","sourcesContent":["import { IAudioModel, AudioToTextParams, TextToAudioParams } from '../models';\n\nexport type AudioPromptOptions = {\n /**\n * the name of the prompt\n */\n readonly name?: string;\n\n /**\n * the description of the prompt\n */\n readonly description?: string;\n\n /**\n * the model to send requests to\n */\n readonly model: IAudioModel;\n};\n\n/**\n * a prompt that can interface with\n * an audio model\n */\nexport interface IAudioPrompt {\n /**\n * the prompt name\n */\n readonly name: string;\n\n /**\n * the prompt description\n */\n readonly description: string;\n\n /**\n * convert text to audio\n */\n textToAudio?(params: TextToAudioParams): Promise<Buffer>;\n\n /**\n * transcribe audio to text\n */\n audioToText?(params: AudioToTextParams): Promise<string>;\n}\n\n/**\n * a prompt that can interface with\n * an audio model\n */\nexport class AudioPrompt implements IAudioPrompt {\n get name() {\n return this._name;\n }\n protected readonly _name: string;\n\n get description() {\n return this._description;\n }\n protected readonly _description: string;\n\n protected readonly _model: IAudioModel;\n\n constructor(options: AudioPromptOptions) {\n this._name = options.name || 'audio';\n this._description = options.description || 'an agent that can convert text to speech';\n this._model = options.model;\n }\n\n audioToText(params: AudioToTextParams) {\n if (!this._model.audioToText) {\n throw new Error('cannot transcribe audio to text');\n }\n\n return this._model.audioToText(params);\n }\n\n textToAudio(params: TextToAudioParams) {\n if (!this._model.textToAudio) {\n throw new Error('cannot translate text to audio');\n }\n\n return this._model.textToAudio(params);\n }\n}\n"]}
|