initial commit
This commit is contained in:
+134
@@ -0,0 +1,134 @@
|
||||
export interface PluginSettings {
|
||||
ollamaUrl: string;
|
||||
model: string;
|
||||
lastIndexTime: number;
|
||||
}
|
||||
|
||||
export enum ErrorType {
|
||||
NETWORK_ERROR = 'network_error',
|
||||
API_ERROR = 'api_error',
|
||||
VALIDATION_ERROR = 'validation_error',
|
||||
STREAMING_ERROR = 'streaming_error',
|
||||
TOOL_EXECUTION_ERROR = 'tool_execution_error',
|
||||
PATH_VALIDATION_ERROR = 'path_validation_error',
|
||||
UNKNOWN_ERROR = 'unknown_error',
|
||||
}
|
||||
|
||||
export class OllamaError extends Error {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly type: ErrorType,
|
||||
public readonly details?: Record<string, any>
|
||||
) {
|
||||
super(message);
|
||||
this.name = 'OllamaError';
|
||||
}
|
||||
}
|
||||
|
||||
export class NetworkError extends OllamaError {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly statusCode?: number
|
||||
) {
|
||||
super(message, ErrorType.NETWORK_ERROR, { statusCode });
|
||||
this.name = 'NetworkError';
|
||||
}
|
||||
}
|
||||
|
||||
export class ApiError extends OllamaError {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly apiError?: any
|
||||
) {
|
||||
super(message, ErrorType.API_ERROR, { apiError });
|
||||
this.name = 'ApiError';
|
||||
}
|
||||
}
|
||||
|
||||
export class ValidationError extends OllamaError {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly validationDetails?: Record<string, string>
|
||||
) {
|
||||
super(message, ErrorType.VALIDATION_ERROR, validationDetails);
|
||||
this.name = 'ValidationError';
|
||||
}
|
||||
}
|
||||
|
||||
export class StreamingError extends OllamaError {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly chunkDetails?: any
|
||||
) {
|
||||
super(message, ErrorType.STREAMING_ERROR, chunkDetails);
|
||||
this.name = 'StreamingError';
|
||||
}
|
||||
}
|
||||
|
||||
export class ToolExecutionError extends OllamaError {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly toolName?: string
|
||||
) {
|
||||
super(message, ErrorType.TOOL_EXECUTION_ERROR, { toolName });
|
||||
this.name = 'ToolExecutionError';
|
||||
}
|
||||
}
|
||||
|
||||
export class PathValidationError extends OllamaError {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly invalidPath?: string
|
||||
) {
|
||||
super(message, ErrorType.PATH_VALIDATION_ERROR, { invalidPath });
|
||||
this.name = 'PathValidationError';
|
||||
}
|
||||
}
|
||||
|
||||
export interface OllamaMessage {
|
||||
role: 'system' | 'user' | 'assistant' | 'tool';
|
||||
content: string;
|
||||
tool_calls?: ToolCall[];
|
||||
}
|
||||
|
||||
export interface ToolCall {
|
||||
function: {
|
||||
name: string;
|
||||
arguments: string | Record<string, any>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface OllamaTool {
|
||||
type: 'function';
|
||||
function: {
|
||||
name: string;
|
||||
description: string;
|
||||
parameters: {
|
||||
type: 'object';
|
||||
properties: Record<string, { type: string }>;
|
||||
required: string[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface ToolResult {
|
||||
success: boolean;
|
||||
message: string;
|
||||
// Adding optional details field for better error reporting
|
||||
details?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface VaultIndexEntry {
|
||||
title: string;
|
||||
content: string;
|
||||
score: number;
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
id: string;
|
||||
role: 'user' | 'assistant' | 'tool';
|
||||
content: string;
|
||||
timestamp: number;
|
||||
isStreaming?: boolean;
|
||||
tool_calls?: ToolCall[];
|
||||
}
|
||||
Reference in New Issue
Block a user