@agentionai/agents 0.12.0-beta → 0.13.0
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 +63 -7
- package/dist/agents/Agent.d.ts +15 -3
- package/dist/agents/Agent.js +8 -0
- package/dist/agents/AgentConfig.d.ts +38 -2
- package/dist/agents/anthropic/ClaudeAgent.d.ts +19 -1
- package/dist/agents/anthropic/ClaudeAgent.js +27 -8
- package/dist/agents/llamacpp/LlamaCppAgent.d.ts +60 -0
- package/dist/agents/llamacpp/LlamaCppAgent.js +262 -0
- package/dist/agents/model-types.d.ts +14 -1
- package/dist/agents/ollama/OllamaAgent.d.ts +91 -0
- package/dist/agents/ollama/OllamaAgent.js +317 -0
- package/dist/chunkers/index.d.ts +0 -1
- package/dist/chunkers/index.js +1 -3
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/history/transformers.d.ts +100 -0
- package/dist/history/transformers.js +195 -1
- package/dist/history/types.d.ts +15 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -1
- package/dist/ingestion/IngestionPipeline.d.ts +1 -73
- package/dist/ingestion/IngestionPipeline.js +1 -110
- package/dist/llamacpp.d.ts +4 -0
- package/dist/llamacpp.js +24 -0
- package/dist/ollama.d.ts +4 -0
- package/dist/ollama.js +24 -0
- package/dist/tools/BuiltInTool.d.ts +72 -0
- package/dist/tools/BuiltInTool.js +53 -0
- package/dist/viz/types.d.ts +1 -1
- package/package.json +10 -42
- package/dist/chunkers/ElementChunker.d.ts +0 -100
- package/dist/chunkers/ElementChunker.js +0 -242
- package/dist/parsers/DocumentParser.d.ts +0 -36
- package/dist/parsers/DocumentParser.js +0 -35
- package/dist/parsers/LlamaIndexParser.d.ts +0 -58
- package/dist/parsers/LlamaIndexParser.js +0 -71
- package/dist/parsers/OllamaOCRParser.d.ts +0 -98
- package/dist/parsers/OllamaOCRParser.js +0 -203
- package/dist/parsers/UnstructuredAPIParser.d.ts +0 -57
- package/dist/parsers/UnstructuredAPIParser.js +0 -131
- package/dist/parsers/UnstructuredLocalParser.d.ts +0 -42
- package/dist/parsers/UnstructuredLocalParser.js +0 -118
- package/dist/parsers/index.d.ts +0 -3
- package/dist/parsers/index.js +0 -6
- package/dist/parsers/types.d.ts +0 -50
- package/dist/parsers/types.js +0 -3
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LlamaCppAgent = void 0;
|
|
7
|
+
const openai_1 = __importDefault(require("openai"));
|
|
8
|
+
const BaseAgent_1 = require("../BaseAgent");
|
|
9
|
+
const AgentEvent_1 = require("../AgentEvent");
|
|
10
|
+
const AgentError_1 = require("../errors/AgentError");
|
|
11
|
+
const transformers_1 = require("../../history/transformers");
|
|
12
|
+
const VizReporter_1 = require("../../viz/VizReporter");
|
|
13
|
+
const VizConfig_1 = require("../../viz/VizConfig");
|
|
14
|
+
/**
|
|
15
|
+
* Agent for locally-hosted models served by a llama.cpp server (`llama-server`),
|
|
16
|
+
* which exposes an OpenAI-compatible `/v1/chat/completions` API.
|
|
17
|
+
*
|
|
18
|
+
* Requires the `openai` package as a peer dependency and a running llama.cpp server.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const agent = new LlamaCppAgent({
|
|
23
|
+
* id: "1",
|
|
24
|
+
* name: "Assistant",
|
|
25
|
+
* description: "A helpful assistant",
|
|
26
|
+
* apiKey: "",
|
|
27
|
+
* baseURL: "http://localhost:8080/v1",
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const response = await agent.execute("Hello!");
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example List available models
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const models = await agent.listModels();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class LlamaCppAgent extends BaseAgent_1.BaseAgent {
|
|
39
|
+
constructor(config, history) {
|
|
40
|
+
super({ ...config, vendor: "llamacpp" }, history);
|
|
41
|
+
/** Count of tool calls in current execution */
|
|
42
|
+
this.currentToolCallCount = 0;
|
|
43
|
+
const vendorConfig = config.vendorConfig?.llamacpp || {};
|
|
44
|
+
const baseURL = config.baseURL ?? vendorConfig.baseURL ?? "http://localhost:8080/v1";
|
|
45
|
+
this.client = new openai_1.default({
|
|
46
|
+
apiKey: config.apiKey || "not-needed",
|
|
47
|
+
baseURL,
|
|
48
|
+
});
|
|
49
|
+
this.config = {
|
|
50
|
+
model: config.model || "default",
|
|
51
|
+
baseURL,
|
|
52
|
+
maxTokens: config.maxTokens,
|
|
53
|
+
temperature: config.temperature,
|
|
54
|
+
topP: config.topP,
|
|
55
|
+
stopSequences: config.stopSequences,
|
|
56
|
+
seed: config.seed,
|
|
57
|
+
presencePenalty: config.presencePenalty,
|
|
58
|
+
frequencyPenalty: config.frequencyPenalty,
|
|
59
|
+
apiKey: config.apiKey,
|
|
60
|
+
};
|
|
61
|
+
this.addSystemMessage(this.getSystemMessage());
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* List the models currently available on the llama.cpp server (via its
|
|
65
|
+
* OpenAI-compatible `/v1/models` endpoint).
|
|
66
|
+
*/
|
|
67
|
+
async listModels() {
|
|
68
|
+
try {
|
|
69
|
+
const page = await this.client.models.list();
|
|
70
|
+
return page.data;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new AgentError_1.ExecutionError(`Failed to list llama.cpp models: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
getToolDefinitions() {
|
|
77
|
+
return Array.from(this.tools.values()).map((tool) => {
|
|
78
|
+
const prompt = tool.getPrompt();
|
|
79
|
+
return {
|
|
80
|
+
type: "function",
|
|
81
|
+
function: {
|
|
82
|
+
name: prompt.name,
|
|
83
|
+
description: prompt.description,
|
|
84
|
+
parameters: prompt.input_schema,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async process(_input) {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
async execute(input) {
|
|
93
|
+
this.emit(AgentEvent_1.AgentEvent.BEFORE_EXECUTE, input);
|
|
94
|
+
this.lastTokenUsage = undefined;
|
|
95
|
+
this.currentToolCallCount = 0;
|
|
96
|
+
const inputPreview = typeof input === "string" ? input : JSON.stringify(input);
|
|
97
|
+
if (VizConfig_1.vizConfig.isEnabled()) {
|
|
98
|
+
this.vizEventId = VizReporter_1.vizReporter.agentStart(this.id, this.name, this.config.model, "llamacpp", inputPreview);
|
|
99
|
+
}
|
|
100
|
+
if (this.history.transient) {
|
|
101
|
+
this.history.clear();
|
|
102
|
+
this.addSystemMessage(this.getSystemMessage());
|
|
103
|
+
}
|
|
104
|
+
if (typeof input === "string") {
|
|
105
|
+
this.addTextToHistory("user", input);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.addMessageToHistory("user", input);
|
|
109
|
+
}
|
|
110
|
+
this.history.setSessionAnchor();
|
|
111
|
+
this.history.beginExecution();
|
|
112
|
+
try {
|
|
113
|
+
const response = await this.callLlamaCpp();
|
|
114
|
+
this.emit(AgentEvent_1.AgentEvent.AFTER_EXECUTE, response);
|
|
115
|
+
return await this.handleResponse(response);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof openai_1.default.APIError) {
|
|
119
|
+
const apiError = new AgentError_1.ApiError(`llama.cpp API error: ${error.message}`, error.status, error);
|
|
120
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, apiError);
|
|
121
|
+
if (this.vizEventId) {
|
|
122
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, "ApiError", apiError.message, error.status === 429);
|
|
123
|
+
this.vizEventId = undefined;
|
|
124
|
+
}
|
|
125
|
+
throw apiError;
|
|
126
|
+
}
|
|
127
|
+
if (error instanceof AgentError_1.ExecutionError || error instanceof AgentError_1.ApiError) {
|
|
128
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, error);
|
|
129
|
+
if (this.vizEventId) {
|
|
130
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, error.constructor.name, error.message, false);
|
|
131
|
+
this.vizEventId = undefined;
|
|
132
|
+
}
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
const executionError = new AgentError_1.ExecutionError(`llama.cpp error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
136
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, executionError);
|
|
137
|
+
if (this.vizEventId) {
|
|
138
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, "ExecutionError", executionError.message, false);
|
|
139
|
+
this.vizEventId = undefined;
|
|
140
|
+
}
|
|
141
|
+
throw executionError;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
this.history.endExecution();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async callLlamaCpp() {
|
|
148
|
+
const messages = transformers_1.chatCompletionsTransformer.toProvider(this.history.getEntries());
|
|
149
|
+
const tools = this.tools.size > 0 ? this.getToolDefinitions() : undefined;
|
|
150
|
+
return this.client.chat.completions.create({
|
|
151
|
+
model: this.config.model,
|
|
152
|
+
messages,
|
|
153
|
+
tools,
|
|
154
|
+
stream: false,
|
|
155
|
+
max_tokens: this.config.maxTokens,
|
|
156
|
+
temperature: this.config.temperature,
|
|
157
|
+
top_p: this.config.topP,
|
|
158
|
+
stop: this.config.stopSequences,
|
|
159
|
+
seed: this.config.seed,
|
|
160
|
+
presence_penalty: this.config.presencePenalty,
|
|
161
|
+
frequency_penalty: this.config.frequencyPenalty,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
async handleResponse(response) {
|
|
165
|
+
const usage = this.parseUsage(response);
|
|
166
|
+
if (this.lastTokenUsage) {
|
|
167
|
+
this.lastTokenUsage.input_tokens += usage.input_tokens;
|
|
168
|
+
this.lastTokenUsage.output_tokens += usage.output_tokens;
|
|
169
|
+
this.lastTokenUsage.total_tokens += usage.total_tokens;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this.lastTokenUsage = { ...usage };
|
|
173
|
+
}
|
|
174
|
+
const choice = response.choices[0];
|
|
175
|
+
const message = choice.message;
|
|
176
|
+
if (choice.finish_reason === "length") {
|
|
177
|
+
const error = new AgentError_1.MaxTokensExceededError("Response exceeded maximum token limit", this.config.maxTokens || 1024);
|
|
178
|
+
this.emit(AgentEvent_1.AgentEvent.MAX_TOKENS_EXCEEDED, error);
|
|
179
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, error);
|
|
180
|
+
if (this.vizEventId) {
|
|
181
|
+
VizReporter_1.vizReporter.agentError(this.vizEventId, "MaxTokensExceededError", error.message, false);
|
|
182
|
+
this.vizEventId = undefined;
|
|
183
|
+
}
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
const hasToolCalls = message.tool_calls && message.tool_calls.length > 0;
|
|
187
|
+
if (!hasToolCalls) {
|
|
188
|
+
const textContent = message.content || "";
|
|
189
|
+
const entry = transformers_1.chatCompletionsTransformer.fromProviderMessage(message);
|
|
190
|
+
this.addToHistory(entry);
|
|
191
|
+
this.emit(AgentEvent_1.AgentEvent.DONE, message, usage);
|
|
192
|
+
if (this.vizEventId) {
|
|
193
|
+
VizReporter_1.vizReporter.agentComplete(this.vizEventId, {
|
|
194
|
+
input: this.lastTokenUsage?.input_tokens || 0,
|
|
195
|
+
output: this.lastTokenUsage?.output_tokens || 0,
|
|
196
|
+
total: this.lastTokenUsage?.total_tokens || 0,
|
|
197
|
+
}, "end_turn", this.currentToolCallCount > 0, this.currentToolCallCount, textContent);
|
|
198
|
+
this.vizEventId = undefined;
|
|
199
|
+
}
|
|
200
|
+
return textContent;
|
|
201
|
+
}
|
|
202
|
+
// Tool calls detected
|
|
203
|
+
const toolCalls = message.tool_calls;
|
|
204
|
+
this.emit(AgentEvent_1.AgentEvent.TOOL_USE, toolCalls);
|
|
205
|
+
this.currentToolCallCount += toolCalls.length;
|
|
206
|
+
const assistantEntry = transformers_1.chatCompletionsTransformer.fromProviderMessage(message);
|
|
207
|
+
this.addToHistory(assistantEntry);
|
|
208
|
+
const toolResults = await this.handleToolCalls(toolCalls);
|
|
209
|
+
for (const result of toolResults) {
|
|
210
|
+
const resultEntry = transformers_1.chatCompletionsTransformer.toolResultEntry(result.toolCallId, result.content);
|
|
211
|
+
this.addToHistory(resultEntry);
|
|
212
|
+
}
|
|
213
|
+
// Continue conversation with tool results
|
|
214
|
+
try {
|
|
215
|
+
const newResponse = await this.callLlamaCpp();
|
|
216
|
+
this.emit(AgentEvent_1.AgentEvent.AFTER_EXECUTE, newResponse);
|
|
217
|
+
return this.handleResponse(newResponse);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
const executionError = new AgentError_1.ExecutionError(`llama.cpp error during tool response: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
221
|
+
this.emit(AgentEvent_1.AgentEvent.ERROR, executionError);
|
|
222
|
+
throw executionError;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async handleToolCalls(toolCalls) {
|
|
226
|
+
return Promise.all(toolCalls.map(async (toolCall) => {
|
|
227
|
+
const toolName = toolCall.type === "function" ? toolCall.function.name : "";
|
|
228
|
+
const tool = this.tools.get(toolName);
|
|
229
|
+
const toolCallId = toolCall.id;
|
|
230
|
+
if (toolCall.type !== "function" || !tool) {
|
|
231
|
+
const errorMessage = `Tool '${toolName}' not found`;
|
|
232
|
+
const error = new AgentError_1.ToolExecutionError(errorMessage, toolName, toolCall.type === "function" ? toolCall.function.arguments : undefined);
|
|
233
|
+
this.emit(AgentEvent_1.AgentEvent.TOOL_ERROR, error);
|
|
234
|
+
return { toolCallId, content: errorMessage };
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const args = JSON.parse(toolCall.function.arguments || "{}");
|
|
238
|
+
const result = await tool.execute(this.getId(), this.getName(), args, toolCallId, this.config.model, "llamacpp");
|
|
239
|
+
return { toolCallId, content: JSON.stringify(result) };
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
const errorMessage = `Error executing tool '${toolName}': ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
243
|
+
if (this.debug) {
|
|
244
|
+
console.error(errorMessage);
|
|
245
|
+
}
|
|
246
|
+
const toolError = new AgentError_1.ToolExecutionError(errorMessage, toolName, toolCall.function.arguments);
|
|
247
|
+
this.emit(AgentEvent_1.AgentEvent.TOOL_ERROR, toolError);
|
|
248
|
+
return { toolCallId, content: errorMessage };
|
|
249
|
+
}
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
parseUsage(response) {
|
|
253
|
+
const usage = response.usage;
|
|
254
|
+
return {
|
|
255
|
+
input_tokens: usage?.prompt_tokens ?? 0,
|
|
256
|
+
output_tokens: usage?.completion_tokens ?? 0,
|
|
257
|
+
total_tokens: usage?.total_tokens ?? 0,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.LlamaCppAgent = LlamaCppAgent;
|
|
262
|
+
//# sourceMappingURL=LlamaCppAgent.js.map
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* You can also provide any custom string for newer models not yet listed.
|
|
9
9
|
* @see https://docs.anthropic.com/en/docs/about-claude/models
|
|
10
10
|
*/
|
|
11
|
-
export type ClaudeModel = "claude-opus-4-5" | "claude-sonnet-4-5" | "claude-haiku-4-5" | (string & Record<never, never>);
|
|
11
|
+
export type ClaudeModel = "claude-opus-4-7" | "claude-opus-4-6" | "claude-sonnet-4-6" | "claude-opus-4-5" | "claude-sonnet-4-5" | "claude-haiku-4-5" | "claude-haiku-4-5-20251001" | (string & Record<never, never>);
|
|
12
12
|
/**
|
|
13
13
|
* Supported Google Gemini models.
|
|
14
14
|
* You can also provide any custom string for newer models not yet listed.
|
|
@@ -21,6 +21,19 @@ export type GeminiModel = "gemini-flash-latest" | "gemini-flash-lite-latest" | "
|
|
|
21
21
|
* @see https://docs.mistral.ai/getting-started/models/
|
|
22
22
|
*/
|
|
23
23
|
export type MistralModel = "mistral-large-latest" | "mistral-small-latest" | "ministral-8b-latest" | "ministral-8b-2410" | "ministral-3b-latest" | "ministral-3b-2410" | "codestral-latest" | "codestral-2405" | "mistral-embed" | "mistral-moderation-latest" | "mistral-moderation-2411" | (string & {});
|
|
24
|
+
/**
|
|
25
|
+
* Popular Ollama models (locally hosted).
|
|
26
|
+
* You can also provide any custom string for models you have pulled.
|
|
27
|
+
* @see https://ollama.com/library
|
|
28
|
+
*/
|
|
29
|
+
export type OllamaModel = "llama3.2" | "llama3.2:1b" | "llama3.1" | "llama3.1:70b" | "llama3" | "mistral" | "mistral-nemo" | "mixtral" | "qwen2.5" | "qwen2.5:7b" | "qwen2.5:72b" | "qwen2.5-coder" | "gemma2" | "gemma2:27b" | "phi3" | "phi4" | "deepseek-r1" | "deepseek-r1:7b" | "deepseek-r1:14b" | "deepseek-r1:70b" | "codellama" | (string & {});
|
|
30
|
+
/**
|
|
31
|
+
* Models served by a local llama.cpp server (`llama-server`).
|
|
32
|
+
* The model is identified by the GGUF file/alias loaded by the server, so any
|
|
33
|
+
* string is accepted — the values below are common conventions.
|
|
34
|
+
* @see https://github.com/ggml-org/llama.cpp/tree/master/tools/server
|
|
35
|
+
*/
|
|
36
|
+
export type LlamaCppModel = "default" | "gpt-oss-20b" | "gpt-oss-120b" | "llama-3.1-8b-instruct" | "llama-3.2-3b-instruct" | "qwen2.5-7b-instruct" | "qwen2.5-coder-7b-instruct" | "mistral-7b-instruct" | "phi-4" | "deepseek-r1-distill-qwen-7b" | (string & {});
|
|
24
37
|
/**
|
|
25
38
|
* Supported OpenAI models.
|
|
26
39
|
* You can also provide any custom string for newer models not yet listed.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { BaseAgent, BaseAgentConfig, TokenUsage } from "../BaseAgent";
|
|
2
|
+
import { History, MessageContent } from "../../history/History";
|
|
3
|
+
import { OllamaModel } from "../model-types";
|
|
4
|
+
type AgentConfig = BaseAgentConfig & {
|
|
5
|
+
/** Ollama server URL (default: `http://localhost:11434`) */
|
|
6
|
+
host?: string;
|
|
7
|
+
model?: OllamaModel;
|
|
8
|
+
maxTokens?: number;
|
|
9
|
+
think?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type OllamaToolDefinition = {
|
|
12
|
+
type: "function";
|
|
13
|
+
function: {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: object;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Agent for locally-hosted Ollama models.
|
|
21
|
+
*
|
|
22
|
+
* Requires the `ollama` package as a peer dependency and Ollama running locally.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const agent = new OllamaAgent({
|
|
27
|
+
* id: "1",
|
|
28
|
+
* name: "Assistant",
|
|
29
|
+
* description: "A helpful assistant",
|
|
30
|
+
* model: "llama3.2",
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* const response = await agent.execute("Hello!");
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example With tools
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const agent = new OllamaAgent({
|
|
39
|
+
* id: "1",
|
|
40
|
+
* name: "Assistant",
|
|
41
|
+
* description: "A helpful assistant",
|
|
42
|
+
* model: "qwen2.5", // Qwen models have strong tool-use support
|
|
43
|
+
* tools: [myTool],
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class OllamaAgent extends BaseAgent {
|
|
48
|
+
protected config: Partial<AgentConfig>;
|
|
49
|
+
/** Token usage from the last execution (for metrics tracking) */
|
|
50
|
+
lastTokenUsage?: TokenUsage;
|
|
51
|
+
/** Current visualization event ID */
|
|
52
|
+
private vizEventId?;
|
|
53
|
+
/** Count of tool calls in current execution */
|
|
54
|
+
private currentToolCallCount;
|
|
55
|
+
/** Cached Ollama client instance */
|
|
56
|
+
private _client;
|
|
57
|
+
constructor(config: Omit<AgentConfig, "vendor">, history?: History);
|
|
58
|
+
private getClient;
|
|
59
|
+
/**
|
|
60
|
+
* List the models currently available on the Ollama server.
|
|
61
|
+
*/
|
|
62
|
+
listModels(): Promise<OllamaModelInfo[]>;
|
|
63
|
+
protected getToolDefinitions(): OllamaToolDefinition[];
|
|
64
|
+
protected process(_input: string): Promise<string>;
|
|
65
|
+
execute(input: string | MessageContent[]): Promise<string>;
|
|
66
|
+
private buildOptions;
|
|
67
|
+
private callOllama;
|
|
68
|
+
protected handleResponse(response: unknown): Promise<string>;
|
|
69
|
+
private handleToolCalls;
|
|
70
|
+
protected parseUsage(input: unknown): TokenUsage;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A model available on the Ollama server, as returned by `client.list()`.
|
|
74
|
+
*/
|
|
75
|
+
export type OllamaModelInfo = {
|
|
76
|
+
name: string;
|
|
77
|
+
model: string;
|
|
78
|
+
modified_at: Date;
|
|
79
|
+
size: number;
|
|
80
|
+
digest: string;
|
|
81
|
+
details: {
|
|
82
|
+
parent_model: string;
|
|
83
|
+
format: string;
|
|
84
|
+
family: string;
|
|
85
|
+
families: string[];
|
|
86
|
+
parameter_size: string;
|
|
87
|
+
quantization_level: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=OllamaAgent.d.ts.map
|