openai-compatible-providers-framework
Version:
OpenAI Compatible Providers Framework with Qwen and iFlow tool calling support, OAuth authentication, dynamic module loading, and comprehensive debug logging system
123 lines • 3.45 kB
TypeScript
/**
* Standalone Debug Logging Module
* 独立调试日志模块
*
* This is a complete standalone implementation that doesn't rely on relative imports.
* 这是一个完整的独立实现,不依赖相对导入。
*/
export interface DebugConfig {
enabled: boolean;
baseDirectory: string;
paths: {
requests: string;
responses: string;
errors: string;
pipeline: string;
system: string;
};
logLevel: 'debug' | 'info' | 'warn' | 'error' | 'silent';
contentFiltering: {
enabled: boolean;
sensitiveFields: string[];
};
maxLogFiles: number;
maxLogSize: string;
}
export interface RequestContext {
requestId: string;
pipelineId: string;
startTime: number;
provider: string;
operation: string;
metadata?: any;
getRequestId: () => string;
getPipelineId: () => string;
getStartTime: () => number;
getProvider: () => string;
getOperation: () => string;
getMetadata: () => any;
}
export interface LogEntry {
type: 'success' | 'error' | 'info' | 'warn' | 'debug';
requestId: string;
provider: string;
operation: string;
timestamp: number;
request?: any;
response?: any;
error?: any;
message?: string;
duration?: number;
data?: any;
}
export interface DebugStatistics {
systemHealth: {
status: 'healthy' | 'warning' | 'error';
lastCheck: number;
issues: string[];
};
systemLogStats: {
totalLogs: number;
successCount: number;
errorCount: number;
lastActivity: number;
};
activeRequests: RequestContext[];
performanceMetrics: {
averageResponseTime: number;
maxResponseTime: number;
minResponseTime: number;
};
}
export declare const DEFAULT_DEBUG_CONFIG: DebugConfig;
export declare class SimpleDebugLogManager {
private config;
private logs;
private activeRequests;
private fileSystem;
private path;
constructor(config?: Partial<DebugConfig>);
startRequest(provider: string, operation: string, metadata?: any): RequestContext;
logSuccess(context: RequestContext, request: any, response: any): Promise<void>;
logError(context: RequestContext, request: any, error: any): Promise<void>;
info(message: string, data?: any): Promise<void>;
warn(message: string, data?: any): Promise<void>;
error(message: string, data?: any): Promise<void>;
logDebug(message: string, data?: any): Promise<void>;
getDebugStatistics(): Promise<DebugStatistics>;
destroy(): Promise<void>;
private writeLogEntry;
private filterContent;
}
export interface ProviderConfig {
name: string;
endpoint: string;
supportedModels?: string[];
defaultModel?: string;
apiKey?: string;
timeout?: number;
maxRetries?: number;
debug?: Partial<DebugConfig>;
}
export interface ChatMessage {
role: 'system' | 'user' | 'assistant';
content: string;
}
export interface ChatRequest {
messages: ChatMessage[];
model?: string;
temperature?: number;
maxTokens?: number;
stream?: boolean;
}
export interface ChatResponse {
content: string;
model: string;
totalTokens: number;
}
declare const _default: {
SimpleDebugLogManager: typeof SimpleDebugLogManager;
DEFAULT_DEBUG_CONFIG: DebugConfig;
};
export default _default;
//# sourceMappingURL=index-standalone.d.ts.map