noosphere 0.8.0 → 0.9.1
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 +126 -8
- package/dist/index.cjs +712 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -1
- package/dist/index.d.ts +88 -1
- package/dist/index.js +688 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { AgentContext, AgentEvent, AgentLoopConfig, AgentTool, ApiOptionsMap, AssistantMessageEvent, AssistantMessageEventStream, KnownProvider, OptionsForApi, Api as PiApi, AssistantMessage as PiAssistantMessage, Context as PiContext, ImageContent as PiImageContent, Message as PiMessage, Model as PiModel, Provider as PiProvider, StreamOptions as PiStreamOptions, ToolResultMessage as PiToolResultMessage, Usage as PiUsage, UserMessage as PiUserMessage, QueuedMessage, ReasoningEffort, SimpleStreamOptions, StopReason, StreamFunction, TextContent, ThinkingContent, ToolCall, agentLoop, calculateCost, getApiKey, getModel as getPiModel, getModels as getPiModels, getProviders as getPiProviders, complete as piComplete, completeSimple as piCompleteSimple, stream as piStream, streamSimple as piStreamSimple, setApiKey } from '@mariozechner/pi-ai';
|
|
2
|
+
|
|
1
3
|
type Modality = 'llm' | 'image' | 'video' | 'tts' | 'stt' | 'music' | 'embedding';
|
|
2
4
|
type ModelStatus = 'installed' | 'available' | 'downloading' | 'running' | 'error';
|
|
3
5
|
interface LocalModelInfo {
|
|
@@ -302,6 +304,59 @@ declare class OllamaProvider implements NoosphereProvider {
|
|
|
302
304
|
getRunningModels(): Promise<OllamaRunningModel[]>;
|
|
303
305
|
}
|
|
304
306
|
|
|
307
|
+
type TokenCountProvider = 'openai' | 'google' | 'anthropic' | 'mistral' | 'groq' | 'xai' | 'cerebras' | 'openrouter' | 'ollama' | 'unknown';
|
|
308
|
+
interface TokenCountResult {
|
|
309
|
+
tokens: number;
|
|
310
|
+
model: string;
|
|
311
|
+
provider: TokenCountProvider;
|
|
312
|
+
method: 'tiktoken' | 'api' | 'estimate';
|
|
313
|
+
}
|
|
314
|
+
interface TokenCountOptions {
|
|
315
|
+
messages: Array<{
|
|
316
|
+
role: string;
|
|
317
|
+
content: string;
|
|
318
|
+
}>;
|
|
319
|
+
model?: string;
|
|
320
|
+
provider?: string;
|
|
321
|
+
}
|
|
322
|
+
declare function countTokensOpenAI(messages: Array<{
|
|
323
|
+
role: string;
|
|
324
|
+
content: string;
|
|
325
|
+
}>, model?: string): number;
|
|
326
|
+
declare function countTokensGoogle(messages: Array<{
|
|
327
|
+
role: string;
|
|
328
|
+
content: string;
|
|
329
|
+
}>, apiKey: string, model?: string): Promise<number>;
|
|
330
|
+
declare function countTokensAnthropic(messages: Array<{
|
|
331
|
+
role: string;
|
|
332
|
+
content: string;
|
|
333
|
+
}>, apiKey: string, model?: string): Promise<number>;
|
|
334
|
+
declare function countTokensGroq(messages: Array<{
|
|
335
|
+
role: string;
|
|
336
|
+
content: string;
|
|
337
|
+
}>, model?: string): number;
|
|
338
|
+
declare function countTokensMistral(messages: Array<{
|
|
339
|
+
role: string;
|
|
340
|
+
content: string;
|
|
341
|
+
}>, model?: string): number;
|
|
342
|
+
declare function countTokensXai(messages: Array<{
|
|
343
|
+
role: string;
|
|
344
|
+
content: string;
|
|
345
|
+
}>, model?: string): number;
|
|
346
|
+
declare function countTokensCerebras(messages: Array<{
|
|
347
|
+
role: string;
|
|
348
|
+
content: string;
|
|
349
|
+
}>, model?: string): number;
|
|
350
|
+
declare function countTokensOpenRouter(messages: Array<{
|
|
351
|
+
role: string;
|
|
352
|
+
content: string;
|
|
353
|
+
}>, model?: string): number;
|
|
354
|
+
declare function countTokensOllama(messages: Array<{
|
|
355
|
+
role: string;
|
|
356
|
+
content: string;
|
|
357
|
+
}>, model?: string): number;
|
|
358
|
+
declare function countTokens(options: TokenCountOptions, apiKeys?: Record<string, string>): Promise<TokenCountResult>;
|
|
359
|
+
|
|
305
360
|
declare class Noosphere {
|
|
306
361
|
private config;
|
|
307
362
|
private registry;
|
|
@@ -320,6 +375,7 @@ declare class Noosphere {
|
|
|
320
375
|
getModel(provider: string, modelId: string): Promise<ModelInfo | null>;
|
|
321
376
|
syncModels(modality?: Modality): Promise<SyncResult>;
|
|
322
377
|
getUsage(options?: UsageQueryOptions): UsageSummary;
|
|
378
|
+
countTokens(options: TokenCountOptions): Promise<TokenCountResult>;
|
|
323
379
|
installModel(name: string): Promise<AsyncGenerator<OllamaPullProgress>>;
|
|
324
380
|
uninstallModel(name: string): Promise<void>;
|
|
325
381
|
getHardware(): Promise<{
|
|
@@ -407,6 +463,37 @@ declare class OpenAICompatProvider implements NoosphereProvider {
|
|
|
407
463
|
/** Auto-detect running OpenAI-compatible servers on common ports */
|
|
408
464
|
declare function detectOpenAICompatServers(): Promise<OpenAICompatProvider[]>;
|
|
409
465
|
|
|
466
|
+
declare class OpenAIMediaProvider implements NoosphereProvider {
|
|
467
|
+
private apiKey;
|
|
468
|
+
readonly id = "openai-media";
|
|
469
|
+
readonly name = "OpenAI (Image, Video, TTS, STT)";
|
|
470
|
+
readonly modalities: Modality[];
|
|
471
|
+
readonly isLocal = false;
|
|
472
|
+
private modelsCache;
|
|
473
|
+
constructor(apiKey: string);
|
|
474
|
+
ping(): Promise<boolean>;
|
|
475
|
+
listModels(modality?: Modality): Promise<ModelInfo[]>;
|
|
476
|
+
image(options: ImageOptions): Promise<NoosphereResult>;
|
|
477
|
+
speak(options: SpeakOptions): Promise<NoosphereResult>;
|
|
478
|
+
video(options: VideoOptions): Promise<NoosphereResult>;
|
|
479
|
+
private getCapabilities;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
declare class GoogleMediaProvider implements NoosphereProvider {
|
|
483
|
+
private apiKey;
|
|
484
|
+
readonly id = "google-media";
|
|
485
|
+
readonly name = "Google (Image, Video, TTS)";
|
|
486
|
+
readonly modalities: Modality[];
|
|
487
|
+
readonly isLocal = false;
|
|
488
|
+
private modelsCache;
|
|
489
|
+
constructor(apiKey: string);
|
|
490
|
+
ping(): Promise<boolean>;
|
|
491
|
+
listModels(modality?: Modality): Promise<ModelInfo[]>;
|
|
492
|
+
image(options: ImageOptions): Promise<NoosphereResult>;
|
|
493
|
+
speak(options: SpeakOptions): Promise<NoosphereResult>;
|
|
494
|
+
video(options: VideoOptions): Promise<NoosphereResult>;
|
|
495
|
+
}
|
|
496
|
+
|
|
410
497
|
interface ProviderLogo {
|
|
411
498
|
svg?: string;
|
|
412
499
|
png?: string;
|
|
@@ -425,4 +512,4 @@ declare function getProviderLogo(providerId: string | undefined | null): Provide
|
|
|
425
512
|
declare function getAllProviderLogos(): Record<string, ProviderLogo>;
|
|
426
513
|
declare const PROVIDER_LOGOS: Record<string, ProviderLogo>;
|
|
427
514
|
|
|
428
|
-
export { AudioCraftProvider, type BaseOptions, type ChatOptions, HfLocalProvider, type ImageOptions, type LocalModelInfo, type LocalServiceConfig, type Modality, type ModelInfo, type ModelStatus, type MusicOptions, Noosphere, type NoosphereConfig, NoosphereError, type NoosphereErrorCode, type NoosphereProvider, type NoosphereResult, type NoosphereStream, type OllamaModelDetail, OllamaProvider, type OllamaPullProgress, type OllamaRunningModel, type OpenAICompatConfig, OpenAICompatProvider, PROVIDER_IDS, PROVIDER_LOGOS, type ProviderInfo, type ProviderLogo$1 as ProviderLogo, type SpeakOptions, type StreamEvent, type SyncResult, type TranscriptionOptions, type TranscriptionResult, type UsageEvent, type UsageQueryOptions, type UsageSummary, type VideoOptions, WhisperLocalProvider, detectOpenAICompatServers, getAllProviderLogos, getProviderLogo };
|
|
515
|
+
export { AudioCraftProvider, type BaseOptions, type ChatOptions, GoogleMediaProvider, HfLocalProvider, type ImageOptions, type LocalModelInfo, type LocalServiceConfig, type Modality, type ModelInfo, type ModelStatus, type MusicOptions, Noosphere, type NoosphereConfig, NoosphereError, type NoosphereErrorCode, type NoosphereProvider, type NoosphereResult, type NoosphereStream, type OllamaModelDetail, OllamaProvider, type OllamaPullProgress, type OllamaRunningModel, type OpenAICompatConfig, OpenAICompatProvider, OpenAIMediaProvider, PROVIDER_IDS, PROVIDER_LOGOS, type ProviderInfo, type ProviderLogo$1 as ProviderLogo, type SpeakOptions, type StreamEvent, type SyncResult, type TokenCountOptions, type TokenCountProvider, type TokenCountResult, type TranscriptionOptions, type TranscriptionResult, type UsageEvent, type UsageQueryOptions, type UsageSummary, type VideoOptions, WhisperLocalProvider, countTokens, countTokensAnthropic, countTokensCerebras, countTokensGoogle, countTokensGroq, countTokensMistral, countTokensOllama, countTokensOpenAI, countTokensOpenRouter, countTokensXai, detectOpenAICompatServers, getAllProviderLogos, getProviderLogo };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { AgentContext, AgentEvent, AgentLoopConfig, AgentTool, ApiOptionsMap, AssistantMessageEvent, AssistantMessageEventStream, KnownProvider, OptionsForApi, Api as PiApi, AssistantMessage as PiAssistantMessage, Context as PiContext, ImageContent as PiImageContent, Message as PiMessage, Model as PiModel, Provider as PiProvider, StreamOptions as PiStreamOptions, ToolResultMessage as PiToolResultMessage, Usage as PiUsage, UserMessage as PiUserMessage, QueuedMessage, ReasoningEffort, SimpleStreamOptions, StopReason, StreamFunction, TextContent, ThinkingContent, ToolCall, agentLoop, calculateCost, getApiKey, getModel as getPiModel, getModels as getPiModels, getProviders as getPiProviders, complete as piComplete, completeSimple as piCompleteSimple, stream as piStream, streamSimple as piStreamSimple, setApiKey } from '@mariozechner/pi-ai';
|
|
2
|
+
|
|
1
3
|
type Modality = 'llm' | 'image' | 'video' | 'tts' | 'stt' | 'music' | 'embedding';
|
|
2
4
|
type ModelStatus = 'installed' | 'available' | 'downloading' | 'running' | 'error';
|
|
3
5
|
interface LocalModelInfo {
|
|
@@ -302,6 +304,59 @@ declare class OllamaProvider implements NoosphereProvider {
|
|
|
302
304
|
getRunningModels(): Promise<OllamaRunningModel[]>;
|
|
303
305
|
}
|
|
304
306
|
|
|
307
|
+
type TokenCountProvider = 'openai' | 'google' | 'anthropic' | 'mistral' | 'groq' | 'xai' | 'cerebras' | 'openrouter' | 'ollama' | 'unknown';
|
|
308
|
+
interface TokenCountResult {
|
|
309
|
+
tokens: number;
|
|
310
|
+
model: string;
|
|
311
|
+
provider: TokenCountProvider;
|
|
312
|
+
method: 'tiktoken' | 'api' | 'estimate';
|
|
313
|
+
}
|
|
314
|
+
interface TokenCountOptions {
|
|
315
|
+
messages: Array<{
|
|
316
|
+
role: string;
|
|
317
|
+
content: string;
|
|
318
|
+
}>;
|
|
319
|
+
model?: string;
|
|
320
|
+
provider?: string;
|
|
321
|
+
}
|
|
322
|
+
declare function countTokensOpenAI(messages: Array<{
|
|
323
|
+
role: string;
|
|
324
|
+
content: string;
|
|
325
|
+
}>, model?: string): number;
|
|
326
|
+
declare function countTokensGoogle(messages: Array<{
|
|
327
|
+
role: string;
|
|
328
|
+
content: string;
|
|
329
|
+
}>, apiKey: string, model?: string): Promise<number>;
|
|
330
|
+
declare function countTokensAnthropic(messages: Array<{
|
|
331
|
+
role: string;
|
|
332
|
+
content: string;
|
|
333
|
+
}>, apiKey: string, model?: string): Promise<number>;
|
|
334
|
+
declare function countTokensGroq(messages: Array<{
|
|
335
|
+
role: string;
|
|
336
|
+
content: string;
|
|
337
|
+
}>, model?: string): number;
|
|
338
|
+
declare function countTokensMistral(messages: Array<{
|
|
339
|
+
role: string;
|
|
340
|
+
content: string;
|
|
341
|
+
}>, model?: string): number;
|
|
342
|
+
declare function countTokensXai(messages: Array<{
|
|
343
|
+
role: string;
|
|
344
|
+
content: string;
|
|
345
|
+
}>, model?: string): number;
|
|
346
|
+
declare function countTokensCerebras(messages: Array<{
|
|
347
|
+
role: string;
|
|
348
|
+
content: string;
|
|
349
|
+
}>, model?: string): number;
|
|
350
|
+
declare function countTokensOpenRouter(messages: Array<{
|
|
351
|
+
role: string;
|
|
352
|
+
content: string;
|
|
353
|
+
}>, model?: string): number;
|
|
354
|
+
declare function countTokensOllama(messages: Array<{
|
|
355
|
+
role: string;
|
|
356
|
+
content: string;
|
|
357
|
+
}>, model?: string): number;
|
|
358
|
+
declare function countTokens(options: TokenCountOptions, apiKeys?: Record<string, string>): Promise<TokenCountResult>;
|
|
359
|
+
|
|
305
360
|
declare class Noosphere {
|
|
306
361
|
private config;
|
|
307
362
|
private registry;
|
|
@@ -320,6 +375,7 @@ declare class Noosphere {
|
|
|
320
375
|
getModel(provider: string, modelId: string): Promise<ModelInfo | null>;
|
|
321
376
|
syncModels(modality?: Modality): Promise<SyncResult>;
|
|
322
377
|
getUsage(options?: UsageQueryOptions): UsageSummary;
|
|
378
|
+
countTokens(options: TokenCountOptions): Promise<TokenCountResult>;
|
|
323
379
|
installModel(name: string): Promise<AsyncGenerator<OllamaPullProgress>>;
|
|
324
380
|
uninstallModel(name: string): Promise<void>;
|
|
325
381
|
getHardware(): Promise<{
|
|
@@ -407,6 +463,37 @@ declare class OpenAICompatProvider implements NoosphereProvider {
|
|
|
407
463
|
/** Auto-detect running OpenAI-compatible servers on common ports */
|
|
408
464
|
declare function detectOpenAICompatServers(): Promise<OpenAICompatProvider[]>;
|
|
409
465
|
|
|
466
|
+
declare class OpenAIMediaProvider implements NoosphereProvider {
|
|
467
|
+
private apiKey;
|
|
468
|
+
readonly id = "openai-media";
|
|
469
|
+
readonly name = "OpenAI (Image, Video, TTS, STT)";
|
|
470
|
+
readonly modalities: Modality[];
|
|
471
|
+
readonly isLocal = false;
|
|
472
|
+
private modelsCache;
|
|
473
|
+
constructor(apiKey: string);
|
|
474
|
+
ping(): Promise<boolean>;
|
|
475
|
+
listModels(modality?: Modality): Promise<ModelInfo[]>;
|
|
476
|
+
image(options: ImageOptions): Promise<NoosphereResult>;
|
|
477
|
+
speak(options: SpeakOptions): Promise<NoosphereResult>;
|
|
478
|
+
video(options: VideoOptions): Promise<NoosphereResult>;
|
|
479
|
+
private getCapabilities;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
declare class GoogleMediaProvider implements NoosphereProvider {
|
|
483
|
+
private apiKey;
|
|
484
|
+
readonly id = "google-media";
|
|
485
|
+
readonly name = "Google (Image, Video, TTS)";
|
|
486
|
+
readonly modalities: Modality[];
|
|
487
|
+
readonly isLocal = false;
|
|
488
|
+
private modelsCache;
|
|
489
|
+
constructor(apiKey: string);
|
|
490
|
+
ping(): Promise<boolean>;
|
|
491
|
+
listModels(modality?: Modality): Promise<ModelInfo[]>;
|
|
492
|
+
image(options: ImageOptions): Promise<NoosphereResult>;
|
|
493
|
+
speak(options: SpeakOptions): Promise<NoosphereResult>;
|
|
494
|
+
video(options: VideoOptions): Promise<NoosphereResult>;
|
|
495
|
+
}
|
|
496
|
+
|
|
410
497
|
interface ProviderLogo {
|
|
411
498
|
svg?: string;
|
|
412
499
|
png?: string;
|
|
@@ -425,4 +512,4 @@ declare function getProviderLogo(providerId: string | undefined | null): Provide
|
|
|
425
512
|
declare function getAllProviderLogos(): Record<string, ProviderLogo>;
|
|
426
513
|
declare const PROVIDER_LOGOS: Record<string, ProviderLogo>;
|
|
427
514
|
|
|
428
|
-
export { AudioCraftProvider, type BaseOptions, type ChatOptions, HfLocalProvider, type ImageOptions, type LocalModelInfo, type LocalServiceConfig, type Modality, type ModelInfo, type ModelStatus, type MusicOptions, Noosphere, type NoosphereConfig, NoosphereError, type NoosphereErrorCode, type NoosphereProvider, type NoosphereResult, type NoosphereStream, type OllamaModelDetail, OllamaProvider, type OllamaPullProgress, type OllamaRunningModel, type OpenAICompatConfig, OpenAICompatProvider, PROVIDER_IDS, PROVIDER_LOGOS, type ProviderInfo, type ProviderLogo$1 as ProviderLogo, type SpeakOptions, type StreamEvent, type SyncResult, type TranscriptionOptions, type TranscriptionResult, type UsageEvent, type UsageQueryOptions, type UsageSummary, type VideoOptions, WhisperLocalProvider, detectOpenAICompatServers, getAllProviderLogos, getProviderLogo };
|
|
515
|
+
export { AudioCraftProvider, type BaseOptions, type ChatOptions, GoogleMediaProvider, HfLocalProvider, type ImageOptions, type LocalModelInfo, type LocalServiceConfig, type Modality, type ModelInfo, type ModelStatus, type MusicOptions, Noosphere, type NoosphereConfig, NoosphereError, type NoosphereErrorCode, type NoosphereProvider, type NoosphereResult, type NoosphereStream, type OllamaModelDetail, OllamaProvider, type OllamaPullProgress, type OllamaRunningModel, type OpenAICompatConfig, OpenAICompatProvider, OpenAIMediaProvider, PROVIDER_IDS, PROVIDER_LOGOS, type ProviderInfo, type ProviderLogo$1 as ProviderLogo, type SpeakOptions, type StreamEvent, type SyncResult, type TokenCountOptions, type TokenCountProvider, type TokenCountResult, type TranscriptionOptions, type TranscriptionResult, type UsageEvent, type UsageQueryOptions, type UsageSummary, type VideoOptions, WhisperLocalProvider, countTokens, countTokensAnthropic, countTokensCerebras, countTokensGoogle, countTokensGroq, countTokensMistral, countTokensOllama, countTokensOpenAI, countTokensOpenRouter, countTokensXai, detectOpenAICompatServers, getAllProviderLogos, getProviderLogo };
|