modality-ai 0.7.0 → 0.7.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ollama
|
|
2
|
+
* Ollama Provider (V4 spec, native for ai@7.x)
|
|
3
3
|
*
|
|
4
4
|
* Standalone provider for Ollama that talks to the Ollama REST API directly
|
|
5
5
|
* (no `ollama-ai-provider` dependency). Implements the LanguageModelV4 and
|
|
@@ -8,7 +8,76 @@
|
|
|
8
8
|
* API reference: https://github.com/ollama/ollama/blob/main/docs/api.md
|
|
9
9
|
* (message conversion modeled after https://github.com/sgomez/ollama-ai-provider)
|
|
10
10
|
*/
|
|
11
|
-
import type { EmbeddingModelV4, LanguageModelV4 } from "@ai-sdk/provider";
|
|
11
|
+
import type { EmbeddingModelV4, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4FinishReason, LanguageModelV4Prompt, LanguageModelV4Usage, SharedV4Warning } from "@ai-sdk/provider";
|
|
12
|
+
/**
|
|
13
|
+
* Ollama REST API wire types (subset used by this provider)
|
|
14
|
+
*/
|
|
15
|
+
interface OllamaToolCall {
|
|
16
|
+
function: {
|
|
17
|
+
name: string;
|
|
18
|
+
arguments: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** @internal exported for testing */
|
|
22
|
+
export interface OllamaMessage {
|
|
23
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
24
|
+
content: string;
|
|
25
|
+
images?: string[];
|
|
26
|
+
tool_calls?: OllamaToolCall[];
|
|
27
|
+
}
|
|
28
|
+
/** @internal exported for testing */
|
|
29
|
+
export interface OllamaChatResponse {
|
|
30
|
+
model?: string;
|
|
31
|
+
created_at?: string;
|
|
32
|
+
message?: {
|
|
33
|
+
role?: string;
|
|
34
|
+
content?: string;
|
|
35
|
+
tool_calls?: OllamaToolCall[];
|
|
36
|
+
};
|
|
37
|
+
done?: boolean;
|
|
38
|
+
done_reason?: string;
|
|
39
|
+
prompt_eval_count?: number;
|
|
40
|
+
eval_count?: number;
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
/** @internal exported for testing */
|
|
44
|
+
export interface OllamaEmbedResponse {
|
|
45
|
+
embeddings: number[][];
|
|
46
|
+
prompt_eval_count?: number;
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Accept both `http://host:11434` and `http://host:11434/api` forms.
|
|
51
|
+
* @internal exported for testing
|
|
52
|
+
*/
|
|
53
|
+
export declare function normalizeBaseURL(baseURL?: string): string;
|
|
54
|
+
/** @internal exported for testing */
|
|
55
|
+
export declare function toBase64(data: Uint8Array | string | URL): string;
|
|
56
|
+
/**
|
|
57
|
+
* Safely parse JSON — returns `fallback` on failure instead of throwing.
|
|
58
|
+
* @internal exported for testing
|
|
59
|
+
*/
|
|
60
|
+
export declare function safeParseJson(input: string, fallback?: unknown): unknown;
|
|
61
|
+
/** @internal exported for testing */
|
|
62
|
+
export declare function mapFinishReason(doneReason?: string): LanguageModelV4FinishReason;
|
|
63
|
+
/** @internal exported for testing */
|
|
64
|
+
export declare function mapUsage(response: OllamaChatResponse): LanguageModelV4Usage;
|
|
65
|
+
/**
|
|
66
|
+
* Convert an AI SDK V4 prompt into Ollama chat messages.
|
|
67
|
+
* @internal exported for testing
|
|
68
|
+
*/
|
|
69
|
+
export declare function convertToOllamaMessages(prompt: LanguageModelV4Prompt): {
|
|
70
|
+
messages: OllamaMessage[];
|
|
71
|
+
warnings: SharedV4Warning[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Convert AI SDK V4 call options into an Ollama /api/chat request body.
|
|
75
|
+
* @internal exported for testing
|
|
76
|
+
*/
|
|
77
|
+
export declare function buildChatRequest(modelId: string, options: LanguageModelV4CallOptions, stream: boolean): {
|
|
78
|
+
body: Record<string, unknown>;
|
|
79
|
+
warnings: SharedV4Warning[];
|
|
80
|
+
};
|
|
12
81
|
/**
|
|
13
82
|
* Ollama Provider (V4 spec, native for ai@7.x)
|
|
14
83
|
*/
|
|
@@ -33,3 +102,4 @@ export declare class OllamaV2Provider {
|
|
|
33
102
|
* Create an Ollama provider
|
|
34
103
|
*/
|
|
35
104
|
export declare function createOllamaV2(options?: OllamaV2ProviderOptions): OllamaV2Provider;
|
|
105
|
+
export {};
|
|
@@ -147,3 +147,11 @@ export declare function mergeToolCallsAndResults(response: any): {
|
|
|
147
147
|
call: any;
|
|
148
148
|
result: any;
|
|
149
149
|
}[];
|
|
150
|
+
/**
|
|
151
|
+
* AI SDK v7 standard: system instructions are a separate `system` parameter,
|
|
152
|
+
* not embedded in the messages array. Google Gemini rejects system messages in `contents`.
|
|
153
|
+
*/
|
|
154
|
+
export declare function extractSystemMessage(messages: ModelMessage[]): {
|
|
155
|
+
system: string | undefined;
|
|
156
|
+
contentMessages: ModelMessage[];
|
|
157
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.2",
|
|
3
3
|
"name": "modality-ai",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
15
|
-
"modality-mcp-kit": "^2.0.
|
|
15
|
+
"modality-mcp-kit": "^2.0.2"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@ai-sdk/google": "^4.0.10",
|
|
@@ -40,8 +40,5 @@
|
|
|
40
40
|
"test": "npm run build && bun test",
|
|
41
41
|
"prepublishOnly": "npm t"
|
|
42
42
|
},
|
|
43
|
-
"files": ["package.json", "README.md", "dist"]
|
|
44
|
-
"patchedDependencies": {
|
|
45
|
-
"sury@11.0.0-alpha.9": "patches/sury@11.0.0-alpha.9.patch"
|
|
46
|
-
}
|
|
43
|
+
"files": ["package.json", "README.md", "dist"]
|
|
47
44
|
}
|