@output.ai/llm 0.0.13 → 0.0.14
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/package.json +2 -1
- package/src/index.d.ts +53 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@output.ai/llm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Framework abstraction to interact with LLM models",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@ai-sdk/azure": "2.0.53",
|
|
14
14
|
"@ai-sdk/openai": "2.0.52",
|
|
15
15
|
"@output.ai/core": ">=0.0.1",
|
|
16
|
+
"@output.ai/prompt": ">=0.0.1",
|
|
16
17
|
"ai": "5.0.48"
|
|
17
18
|
},
|
|
18
19
|
"license": "UNLICENSED"
|
package/src/index.d.ts
CHANGED
|
@@ -1,44 +1,60 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
GenerateObjectOptions
|
|
4
|
-
} from 'ai';
|
|
1
|
+
import type * as AiTypes from 'ai';
|
|
2
|
+
import type { Prompt } from '@output.ai/prompt';
|
|
5
3
|
|
|
6
|
-
export
|
|
7
|
-
config: {
|
|
8
|
-
provider: 'anthropic' | 'openai' | 'azure' ;
|
|
9
|
-
model: string;
|
|
10
|
-
temperature?: number;
|
|
11
|
-
max_tokens?: number;
|
|
12
|
-
};
|
|
13
|
-
messages: Array<{
|
|
14
|
-
role: string;
|
|
15
|
-
content: string;
|
|
16
|
-
}>;
|
|
17
|
-
}
|
|
4
|
+
export type { Prompt };
|
|
18
5
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
GenerateTextOptions,
|
|
22
|
-
'prompt' | 'messages' | 'model'
|
|
23
|
-
> & {
|
|
24
|
-
prompt: Prompt,
|
|
25
|
-
};
|
|
6
|
+
type NativeGenerateTextArgs = Parameters<typeof AiTypes.generateText>[0];
|
|
7
|
+
type NativeGenerateObjectArgs = Parameters<typeof AiTypes.generateObject>[0];
|
|
26
8
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
> & {
|
|
31
|
-
prompt: Prompt,
|
|
32
|
-
schema: Record<string, unknown> | object,
|
|
33
|
-
schemaName?: string,
|
|
34
|
-
schemaDescription?: string,
|
|
35
|
-
output?: 'object' | 'array',
|
|
36
|
-
};
|
|
9
|
+
/**
|
|
10
|
+
* Simplify types into a plain object
|
|
11
|
+
*/
|
|
12
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
37
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Text generation arguments
|
|
16
|
+
* Include all native AI SDK generateText options and a Prompt object from `@output.ai/prompt`
|
|
17
|
+
*/
|
|
18
|
+
export type GenerateTextArgs = Simplify<
|
|
19
|
+
Partial<Omit<NativeGenerateTextArgs, 'prompt'>> & { prompt: Prompt }
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Object generation arguments
|
|
24
|
+
* Include all native AI SDK generateObject options and a Prompt object from `@output.ai/prompt`
|
|
25
|
+
*/
|
|
26
|
+
export type GenerateObjectArgs = Simplify<
|
|
27
|
+
Partial<Omit<NativeGenerateObjectArgs, 'prompt'>> & { prompt: Prompt }
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Use a LLM Model to generate text
|
|
32
|
+
*
|
|
33
|
+
* This function a wrapper over AI SDK's generateText function.
|
|
34
|
+
*
|
|
35
|
+
* It accepts the same arguments of the the original function, plus a "Prompt" object, generated using the `output.ai/prompt`.
|
|
36
|
+
*
|
|
37
|
+
* The Prompt object will set `model`, `messages`, `temperature` and `max_tokens`, however all these can be overwritten by their AI SDK native argument values.
|
|
38
|
+
*
|
|
39
|
+
* @param {GenerateTextArgs} args - Generation arguments
|
|
40
|
+
* @returns {Promise<string>}
|
|
41
|
+
*/
|
|
38
42
|
export function generateText(
|
|
39
|
-
|
|
43
|
+
args: GenerateTextArgs
|
|
40
44
|
): Promise<string>;
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Use a LLM Model to generate object
|
|
48
|
+
*
|
|
49
|
+
* This function a wrapper over AI SDK's generateObject function.
|
|
50
|
+
*
|
|
51
|
+
* It accepts the same arguments of the the original function, plus a "Prompt" object, generated using the `output.ai/prompt`.
|
|
52
|
+
*
|
|
53
|
+
* The Prompt object will set `model`, `messages`, `temperature` and `max_tokens`, however all these can be overwritten by their AI SDK native argument values.
|
|
54
|
+
*
|
|
55
|
+
* @param {GenerateObjectArgs} args - Generation arguments
|
|
56
|
+
* @returns {Promise<object>}
|
|
57
|
+
*/
|
|
58
|
+
export function generateObject(
|
|
59
|
+
args: GenerateObjectArgs
|
|
60
|
+
): Promise<object>;
|