gcloud-sonar-ai
Version:
A production-ready NPM package that provides a Perplexity Sonar alternative using Google Cloud Vertex AI and Gemini models.
76 lines • 1.96 kB
TypeScript
import { GroundingMetadata as VertexGroundingMetadata } from '@google-cloud/vertexai';
export interface SonarConfig {
apiKey?: string;
projectId?: string;
location?: string;
dataStoreId?: string;
searchEngineId?: string;
useGoogleSearch?: boolean;
maxSearchResults?: number;
searchTimeout?: number;
model?: string;
thinkingBudget?: number;
maxOutputTokens?: number;
temperature?: number;
topP?: number;
topK?: number;
enableSafetySettings?: boolean;
customInstructions?: string;
debugMode?: boolean;
}
export interface SearchResult {
title: string;
url: string;
snippet: string;
relevanceScore?: number;
publishedDate?: string;
domain?: string;
}
export type GroundingMetadata = VertexGroundingMetadata;
export interface SonarResponse {
text: string;
sources: SearchResult[];
groundingMetadata?: GroundingMetadata;
searchQueries: string[];
responseTime: number;
tokensUsed: {
input: number;
output: number;
thinking?: number;
total: number;
};
model: string;
timestamp: string;
}
export interface StreamChunk {
text: string;
isComplete: boolean;
sources?: SearchResult[];
tokensUsed?: {
input: number;
output: number;
thinking?: number;
total: number;
};
}
export interface ChatSession {
sendMessage(message: string): Promise<SonarResponse>;
sendMessageStream(message: string): AsyncGenerator<StreamChunk, SonarResponse>;
getHistory(): Array<{
role: string;
content: string;
timestamp: string;
}>;
clearHistory(): void;
}
export interface HealthStatus {
status: 'healthy' | 'unhealthy' | 'degraded';
details: {
responseTime?: number;
tokensUsed?: number;
sourcesFound?: number;
error?: string;
lastChecked: string;
};
}
//# sourceMappingURL=types.d.ts.map