binario 0.1.0 → 0.2.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 +1175 -1140
- package/dist/index.cjs +187 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +183 -2
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +465 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +201 -8
- package/dist/react.d.ts +201 -8
- package/dist/react.js +461 -2
- package/dist/react.js.map +1 -1
- package/package.json +103 -104
package/dist/react.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import * as react from 'react';
|
|
2
3
|
|
|
3
4
|
type Provider = 'openai' | 'anthropic' | 'google' | 'mistral' | 'cohere' | 'cloudflare' | 'lovable';
|
|
4
5
|
interface Message {
|
|
@@ -31,7 +32,7 @@ interface StreamCallbacks {
|
|
|
31
32
|
onComplete?: (response: ChatResponse) => void;
|
|
32
33
|
onError?: (error: Error) => void;
|
|
33
34
|
}
|
|
34
|
-
interface ChatOptions {
|
|
35
|
+
interface ChatOptions$1 {
|
|
35
36
|
provider?: Provider;
|
|
36
37
|
model?: string;
|
|
37
38
|
temperature?: number;
|
|
@@ -147,9 +148,9 @@ declare class BinarioAI {
|
|
|
147
148
|
private retryWithBackoff;
|
|
148
149
|
private formatMessagesForProvider;
|
|
149
150
|
private parseProviderResponse;
|
|
150
|
-
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
151
|
+
chat(messages: Message[], options?: ChatOptions$1): Promise<ChatResponse>;
|
|
151
152
|
private handleStructuredOutput;
|
|
152
|
-
streamChat(messages: Message[], options?: ChatOptions, callbacks?: StreamCallbacks): AsyncGenerator<string, ChatResponse, unknown>;
|
|
153
|
+
streamChat(messages: Message[], options?: ChatOptions$1, callbacks?: StreamCallbacks): AsyncGenerator<string, ChatResponse, unknown>;
|
|
153
154
|
clearCache(): void;
|
|
154
155
|
}
|
|
155
156
|
|
|
@@ -296,7 +297,7 @@ interface EmbeddingsProvider {
|
|
|
296
297
|
embedMany(texts: string[]): Promise<BatchEmbeddingResult>;
|
|
297
298
|
}
|
|
298
299
|
|
|
299
|
-
interface UseBinarioChatOptions extends ChatOptions {
|
|
300
|
+
interface UseBinarioChatOptions extends ChatOptions$1 {
|
|
300
301
|
initialMessages?: Message[];
|
|
301
302
|
onFinish?: (response: ChatResponse) => void;
|
|
302
303
|
onError?: (error: Error) => void;
|
|
@@ -314,7 +315,7 @@ interface UseBinarioChatReturn {
|
|
|
314
315
|
lastResponse: ChatResponse | null;
|
|
315
316
|
}
|
|
316
317
|
declare function useBinarioChat(binario: BinarioAI, options?: UseBinarioChatOptions): UseBinarioChatReturn;
|
|
317
|
-
interface UseBinarioStreamOptions extends ChatOptions {
|
|
318
|
+
interface UseBinarioStreamOptions extends ChatOptions$1 {
|
|
318
319
|
initialMessages?: Message[];
|
|
319
320
|
onToken?: (token: string) => void;
|
|
320
321
|
onFinish?: (response: ChatResponse) => void;
|
|
@@ -332,7 +333,7 @@ interface UseBinarioStreamReturn {
|
|
|
332
333
|
setMessages: (messages: Message[]) => void;
|
|
333
334
|
}
|
|
334
335
|
declare function useBinarioStream(binario: BinarioAI, options?: UseBinarioStreamOptions): UseBinarioStreamReturn;
|
|
335
|
-
interface UseBinarioCompletionOptions extends ChatOptions {
|
|
336
|
+
interface UseBinarioCompletionOptions extends ChatOptions$1 {
|
|
336
337
|
onFinish?: (response: ChatResponse) => void;
|
|
337
338
|
onError?: (error: Error) => void;
|
|
338
339
|
}
|
|
@@ -367,7 +368,7 @@ interface UseBinarioAgentReturn<TContext> {
|
|
|
367
368
|
stop: () => void;
|
|
368
369
|
}
|
|
369
370
|
declare function useBinarioAgent<TContext = unknown, TDeps = unknown>(agent: Agent<TContext, TDeps>, options?: UseBinarioAgentOptions): UseBinarioAgentReturn<TContext>;
|
|
370
|
-
interface UseBinarioStructuredOptions<T> extends ChatOptions {
|
|
371
|
+
interface UseBinarioStructuredOptions<T> extends ChatOptions$1 {
|
|
371
372
|
schema: z.ZodType<T>;
|
|
372
373
|
onFinish?: (data: T) => void;
|
|
373
374
|
onError?: (error: Error) => void;
|
|
@@ -552,4 +553,196 @@ interface UseBinarioSemanticSearchReturn {
|
|
|
552
553
|
}
|
|
553
554
|
declare function useBinarioSemanticSearch(options?: UseBinarioSemanticSearchOptions): UseBinarioSemanticSearchReturn;
|
|
554
555
|
|
|
555
|
-
|
|
556
|
+
interface BinarioOptions {
|
|
557
|
+
baseUrl?: string;
|
|
558
|
+
timeout?: number;
|
|
559
|
+
maxRetries?: number;
|
|
560
|
+
}
|
|
561
|
+
interface ChatOptions {
|
|
562
|
+
model?: string;
|
|
563
|
+
temperature?: number;
|
|
564
|
+
maxTokens?: number;
|
|
565
|
+
systemPrompt?: string;
|
|
566
|
+
tools?: Tool[];
|
|
567
|
+
stream?: boolean;
|
|
568
|
+
}
|
|
569
|
+
interface StreamOptions extends ChatOptions {
|
|
570
|
+
onToken?: (token: string) => void;
|
|
571
|
+
onComplete?: (response: ChatResponse) => void;
|
|
572
|
+
onError?: (error: Error) => void;
|
|
573
|
+
}
|
|
574
|
+
interface AgentOptions {
|
|
575
|
+
name?: string;
|
|
576
|
+
systemPrompt?: string;
|
|
577
|
+
tools: Tool[];
|
|
578
|
+
maxIterations?: number;
|
|
579
|
+
model?: string;
|
|
580
|
+
}
|
|
581
|
+
interface UsageInfo {
|
|
582
|
+
requestsUsed: number;
|
|
583
|
+
requestsLimit: number;
|
|
584
|
+
tokensUsed: number;
|
|
585
|
+
plan: 'free' | 'pro' | 'enterprise';
|
|
586
|
+
resetAt: string;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Binario - Ultra-simple AI SDK
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* import { Binario } from 'binario';
|
|
594
|
+
*
|
|
595
|
+
* const ai = new Binario('bsk_your_api_key');
|
|
596
|
+
*
|
|
597
|
+
* // Simple chat
|
|
598
|
+
* const response = await ai.chat('Hello!');
|
|
599
|
+
* console.log(response.content);
|
|
600
|
+
*
|
|
601
|
+
* // Streaming
|
|
602
|
+
* for await (const token of ai.stream('Tell me a story')) {
|
|
603
|
+
* process.stdout.write(token);
|
|
604
|
+
* }
|
|
605
|
+
*
|
|
606
|
+
* // Agent with tools
|
|
607
|
+
* const agent = ai.agent({
|
|
608
|
+
* tools: [searchTool, calculatorTool],
|
|
609
|
+
* systemPrompt: 'You are a helpful assistant'
|
|
610
|
+
* });
|
|
611
|
+
* const result = await agent.run('Search for weather in Madrid');
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
declare class Binario {
|
|
615
|
+
private apiKey;
|
|
616
|
+
private baseUrl;
|
|
617
|
+
private timeout;
|
|
618
|
+
private maxRetries;
|
|
619
|
+
constructor(apiKey: string, options?: BinarioOptions);
|
|
620
|
+
/**
|
|
621
|
+
* Simple chat completion
|
|
622
|
+
*/
|
|
623
|
+
chat(messageOrMessages: string | Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
624
|
+
/**
|
|
625
|
+
* Streaming chat - returns async iterator
|
|
626
|
+
*/
|
|
627
|
+
stream(messageOrMessages: string | Message[], options?: ChatOptions): AsyncGenerator<string, ChatResponse, unknown>;
|
|
628
|
+
/**
|
|
629
|
+
* Stream with callbacks (alternative API)
|
|
630
|
+
*/
|
|
631
|
+
streamWithCallbacks(messageOrMessages: string | Message[], options: StreamOptions): Promise<ChatResponse>;
|
|
632
|
+
/**
|
|
633
|
+
* Create an agent with tools
|
|
634
|
+
*/
|
|
635
|
+
agent(options: AgentOptions): BinarioAgent;
|
|
636
|
+
/**
|
|
637
|
+
* Get current usage
|
|
638
|
+
*/
|
|
639
|
+
getUsage(): Promise<UsageInfo>;
|
|
640
|
+
/**
|
|
641
|
+
* List available models
|
|
642
|
+
*/
|
|
643
|
+
listModels(): Promise<{
|
|
644
|
+
id: string;
|
|
645
|
+
name: string;
|
|
646
|
+
free: boolean;
|
|
647
|
+
}[]>;
|
|
648
|
+
private normalizeMessages;
|
|
649
|
+
private getHeaders;
|
|
650
|
+
private request;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Binario Agent - Multi-step reasoning with tools
|
|
654
|
+
*/
|
|
655
|
+
declare class BinarioAgent {
|
|
656
|
+
private client;
|
|
657
|
+
private options;
|
|
658
|
+
constructor(client: Binario, options: AgentOptions);
|
|
659
|
+
/**
|
|
660
|
+
* Run the agent with a user message
|
|
661
|
+
*/
|
|
662
|
+
run(message: string): Promise<AgentResult>;
|
|
663
|
+
/**
|
|
664
|
+
* Run agent with streaming
|
|
665
|
+
*/
|
|
666
|
+
runStream(message: string): AsyncGenerator<{
|
|
667
|
+
type: 'thinking' | 'tool_call' | 'tool_result' | 'response';
|
|
668
|
+
content: string;
|
|
669
|
+
tool?: string;
|
|
670
|
+
}>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
interface BinarioProviderProps {
|
|
674
|
+
apiKey: string;
|
|
675
|
+
baseUrl?: string;
|
|
676
|
+
children: React.ReactNode;
|
|
677
|
+
}
|
|
678
|
+
declare function BinarioProvider({ apiKey, baseUrl, children }: BinarioProviderProps): react.ReactNode;
|
|
679
|
+
declare function useBinarioClient(): Binario;
|
|
680
|
+
interface UseChatOptions {
|
|
681
|
+
model?: string;
|
|
682
|
+
temperature?: number;
|
|
683
|
+
maxTokens?: number;
|
|
684
|
+
systemPrompt?: string;
|
|
685
|
+
initialMessages?: Message[];
|
|
686
|
+
onFinish?: (response: any) => void;
|
|
687
|
+
onError?: (error: Error) => void;
|
|
688
|
+
}
|
|
689
|
+
interface UseChatReturn {
|
|
690
|
+
messages: Message[];
|
|
691
|
+
input: string;
|
|
692
|
+
setInput: (input: string) => void;
|
|
693
|
+
isLoading: boolean;
|
|
694
|
+
error: Error | null;
|
|
695
|
+
send: (content?: string) => Promise<void>;
|
|
696
|
+
setMessages: (messages: Message[]) => void;
|
|
697
|
+
stop: () => void;
|
|
698
|
+
}
|
|
699
|
+
declare function useChat(client: Binario, options?: UseChatOptions): UseChatReturn;
|
|
700
|
+
interface UseStreamOptions extends UseChatOptions {
|
|
701
|
+
onToken?: (token: string) => void;
|
|
702
|
+
}
|
|
703
|
+
interface UseStreamReturn {
|
|
704
|
+
messages: Message[];
|
|
705
|
+
input: string;
|
|
706
|
+
setInput: (input: string) => void;
|
|
707
|
+
isStreaming: boolean;
|
|
708
|
+
error: Error | null;
|
|
709
|
+
streamingContent: string;
|
|
710
|
+
send: (content?: string) => Promise<void>;
|
|
711
|
+
setMessages: (messages: Message[]) => void;
|
|
712
|
+
stop: () => void;
|
|
713
|
+
}
|
|
714
|
+
declare function useStream(client: Binario, options?: UseStreamOptions): UseStreamReturn;
|
|
715
|
+
interface UseAgentOptions {
|
|
716
|
+
name?: string;
|
|
717
|
+
systemPrompt?: string;
|
|
718
|
+
tools: AgentOptions['tools'];
|
|
719
|
+
maxIterations?: number;
|
|
720
|
+
model?: string;
|
|
721
|
+
onToolCall?: (tool: string, args: unknown) => void;
|
|
722
|
+
onError?: (error: Error) => void;
|
|
723
|
+
}
|
|
724
|
+
interface UseAgentReturn {
|
|
725
|
+
output: string;
|
|
726
|
+
isRunning: boolean;
|
|
727
|
+
error: Error | null;
|
|
728
|
+
toolCalls: Array<{
|
|
729
|
+
tool: string;
|
|
730
|
+
args: unknown;
|
|
731
|
+
}>;
|
|
732
|
+
run: (message: string) => Promise<string | null>;
|
|
733
|
+
stop: () => void;
|
|
734
|
+
}
|
|
735
|
+
declare function useAgent(client: Binario, options: UseAgentOptions): UseAgentReturn;
|
|
736
|
+
interface UseUsageReturn {
|
|
737
|
+
usage: {
|
|
738
|
+
requestsUsed: number;
|
|
739
|
+
tokensUsed: number;
|
|
740
|
+
plan: string;
|
|
741
|
+
} | null;
|
|
742
|
+
isLoading: boolean;
|
|
743
|
+
error: Error | null;
|
|
744
|
+
refresh: () => Promise<void>;
|
|
745
|
+
}
|
|
746
|
+
declare function useUsage(client: Binario): UseUsageReturn;
|
|
747
|
+
|
|
748
|
+
export { BinarioProvider, type BinarioProviderProps, type EmbeddingsProviderType, type HookTool, type MemoryType, type SearchDocument, type SearchResult, type UseAgentOptions, type UseAgentReturn, type UseBinarioAgentOptions, type UseBinarioAgentReturn, type UseBinarioChatOptions, type UseBinarioChatReturn, type UseBinarioChatWithMemoryOptions, type UseBinarioChatWithMemoryReturn, type UseBinarioCompletionOptions, type UseBinarioEmbedOptions, type UseBinarioEmbedReturn, type UseBinarioMemoryOptions, type UseBinarioMemoryReturn, type UseBinarioSemanticSearchOptions, type UseBinarioSemanticSearchReturn, type UseBinarioStreamOptions, type UseBinarioStreamReturn, type UseBinarioStructuredOptions, type UseBinarioStructuredReturn, type UseBinarioToolsOptions, type UseBinarioToolsReturn, type UseChatOptions, type UseChatReturn, type UseStreamOptions, type UseStreamReturn, type UseUsageReturn, useAgent, useBinarioAgent, useBinarioChat, useBinarioChatWithMemory, useBinarioClient, useBinarioCompletion, useBinarioEmbed, useBinarioMemory, useBinarioSemanticSearch, useBinarioStream, useBinarioStructured, useBinarioTools, useChat, useStream, useUsage };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import * as react from 'react';
|
|
2
3
|
|
|
3
4
|
type Provider = 'openai' | 'anthropic' | 'google' | 'mistral' | 'cohere' | 'cloudflare' | 'lovable';
|
|
4
5
|
interface Message {
|
|
@@ -31,7 +32,7 @@ interface StreamCallbacks {
|
|
|
31
32
|
onComplete?: (response: ChatResponse) => void;
|
|
32
33
|
onError?: (error: Error) => void;
|
|
33
34
|
}
|
|
34
|
-
interface ChatOptions {
|
|
35
|
+
interface ChatOptions$1 {
|
|
35
36
|
provider?: Provider;
|
|
36
37
|
model?: string;
|
|
37
38
|
temperature?: number;
|
|
@@ -147,9 +148,9 @@ declare class BinarioAI {
|
|
|
147
148
|
private retryWithBackoff;
|
|
148
149
|
private formatMessagesForProvider;
|
|
149
150
|
private parseProviderResponse;
|
|
150
|
-
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
151
|
+
chat(messages: Message[], options?: ChatOptions$1): Promise<ChatResponse>;
|
|
151
152
|
private handleStructuredOutput;
|
|
152
|
-
streamChat(messages: Message[], options?: ChatOptions, callbacks?: StreamCallbacks): AsyncGenerator<string, ChatResponse, unknown>;
|
|
153
|
+
streamChat(messages: Message[], options?: ChatOptions$1, callbacks?: StreamCallbacks): AsyncGenerator<string, ChatResponse, unknown>;
|
|
153
154
|
clearCache(): void;
|
|
154
155
|
}
|
|
155
156
|
|
|
@@ -296,7 +297,7 @@ interface EmbeddingsProvider {
|
|
|
296
297
|
embedMany(texts: string[]): Promise<BatchEmbeddingResult>;
|
|
297
298
|
}
|
|
298
299
|
|
|
299
|
-
interface UseBinarioChatOptions extends ChatOptions {
|
|
300
|
+
interface UseBinarioChatOptions extends ChatOptions$1 {
|
|
300
301
|
initialMessages?: Message[];
|
|
301
302
|
onFinish?: (response: ChatResponse) => void;
|
|
302
303
|
onError?: (error: Error) => void;
|
|
@@ -314,7 +315,7 @@ interface UseBinarioChatReturn {
|
|
|
314
315
|
lastResponse: ChatResponse | null;
|
|
315
316
|
}
|
|
316
317
|
declare function useBinarioChat(binario: BinarioAI, options?: UseBinarioChatOptions): UseBinarioChatReturn;
|
|
317
|
-
interface UseBinarioStreamOptions extends ChatOptions {
|
|
318
|
+
interface UseBinarioStreamOptions extends ChatOptions$1 {
|
|
318
319
|
initialMessages?: Message[];
|
|
319
320
|
onToken?: (token: string) => void;
|
|
320
321
|
onFinish?: (response: ChatResponse) => void;
|
|
@@ -332,7 +333,7 @@ interface UseBinarioStreamReturn {
|
|
|
332
333
|
setMessages: (messages: Message[]) => void;
|
|
333
334
|
}
|
|
334
335
|
declare function useBinarioStream(binario: BinarioAI, options?: UseBinarioStreamOptions): UseBinarioStreamReturn;
|
|
335
|
-
interface UseBinarioCompletionOptions extends ChatOptions {
|
|
336
|
+
interface UseBinarioCompletionOptions extends ChatOptions$1 {
|
|
336
337
|
onFinish?: (response: ChatResponse) => void;
|
|
337
338
|
onError?: (error: Error) => void;
|
|
338
339
|
}
|
|
@@ -367,7 +368,7 @@ interface UseBinarioAgentReturn<TContext> {
|
|
|
367
368
|
stop: () => void;
|
|
368
369
|
}
|
|
369
370
|
declare function useBinarioAgent<TContext = unknown, TDeps = unknown>(agent: Agent<TContext, TDeps>, options?: UseBinarioAgentOptions): UseBinarioAgentReturn<TContext>;
|
|
370
|
-
interface UseBinarioStructuredOptions<T> extends ChatOptions {
|
|
371
|
+
interface UseBinarioStructuredOptions<T> extends ChatOptions$1 {
|
|
371
372
|
schema: z.ZodType<T>;
|
|
372
373
|
onFinish?: (data: T) => void;
|
|
373
374
|
onError?: (error: Error) => void;
|
|
@@ -552,4 +553,196 @@ interface UseBinarioSemanticSearchReturn {
|
|
|
552
553
|
}
|
|
553
554
|
declare function useBinarioSemanticSearch(options?: UseBinarioSemanticSearchOptions): UseBinarioSemanticSearchReturn;
|
|
554
555
|
|
|
555
|
-
|
|
556
|
+
interface BinarioOptions {
|
|
557
|
+
baseUrl?: string;
|
|
558
|
+
timeout?: number;
|
|
559
|
+
maxRetries?: number;
|
|
560
|
+
}
|
|
561
|
+
interface ChatOptions {
|
|
562
|
+
model?: string;
|
|
563
|
+
temperature?: number;
|
|
564
|
+
maxTokens?: number;
|
|
565
|
+
systemPrompt?: string;
|
|
566
|
+
tools?: Tool[];
|
|
567
|
+
stream?: boolean;
|
|
568
|
+
}
|
|
569
|
+
interface StreamOptions extends ChatOptions {
|
|
570
|
+
onToken?: (token: string) => void;
|
|
571
|
+
onComplete?: (response: ChatResponse) => void;
|
|
572
|
+
onError?: (error: Error) => void;
|
|
573
|
+
}
|
|
574
|
+
interface AgentOptions {
|
|
575
|
+
name?: string;
|
|
576
|
+
systemPrompt?: string;
|
|
577
|
+
tools: Tool[];
|
|
578
|
+
maxIterations?: number;
|
|
579
|
+
model?: string;
|
|
580
|
+
}
|
|
581
|
+
interface UsageInfo {
|
|
582
|
+
requestsUsed: number;
|
|
583
|
+
requestsLimit: number;
|
|
584
|
+
tokensUsed: number;
|
|
585
|
+
plan: 'free' | 'pro' | 'enterprise';
|
|
586
|
+
resetAt: string;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Binario - Ultra-simple AI SDK
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* import { Binario } from 'binario';
|
|
594
|
+
*
|
|
595
|
+
* const ai = new Binario('bsk_your_api_key');
|
|
596
|
+
*
|
|
597
|
+
* // Simple chat
|
|
598
|
+
* const response = await ai.chat('Hello!');
|
|
599
|
+
* console.log(response.content);
|
|
600
|
+
*
|
|
601
|
+
* // Streaming
|
|
602
|
+
* for await (const token of ai.stream('Tell me a story')) {
|
|
603
|
+
* process.stdout.write(token);
|
|
604
|
+
* }
|
|
605
|
+
*
|
|
606
|
+
* // Agent with tools
|
|
607
|
+
* const agent = ai.agent({
|
|
608
|
+
* tools: [searchTool, calculatorTool],
|
|
609
|
+
* systemPrompt: 'You are a helpful assistant'
|
|
610
|
+
* });
|
|
611
|
+
* const result = await agent.run('Search for weather in Madrid');
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
declare class Binario {
|
|
615
|
+
private apiKey;
|
|
616
|
+
private baseUrl;
|
|
617
|
+
private timeout;
|
|
618
|
+
private maxRetries;
|
|
619
|
+
constructor(apiKey: string, options?: BinarioOptions);
|
|
620
|
+
/**
|
|
621
|
+
* Simple chat completion
|
|
622
|
+
*/
|
|
623
|
+
chat(messageOrMessages: string | Message[], options?: ChatOptions): Promise<ChatResponse>;
|
|
624
|
+
/**
|
|
625
|
+
* Streaming chat - returns async iterator
|
|
626
|
+
*/
|
|
627
|
+
stream(messageOrMessages: string | Message[], options?: ChatOptions): AsyncGenerator<string, ChatResponse, unknown>;
|
|
628
|
+
/**
|
|
629
|
+
* Stream with callbacks (alternative API)
|
|
630
|
+
*/
|
|
631
|
+
streamWithCallbacks(messageOrMessages: string | Message[], options: StreamOptions): Promise<ChatResponse>;
|
|
632
|
+
/**
|
|
633
|
+
* Create an agent with tools
|
|
634
|
+
*/
|
|
635
|
+
agent(options: AgentOptions): BinarioAgent;
|
|
636
|
+
/**
|
|
637
|
+
* Get current usage
|
|
638
|
+
*/
|
|
639
|
+
getUsage(): Promise<UsageInfo>;
|
|
640
|
+
/**
|
|
641
|
+
* List available models
|
|
642
|
+
*/
|
|
643
|
+
listModels(): Promise<{
|
|
644
|
+
id: string;
|
|
645
|
+
name: string;
|
|
646
|
+
free: boolean;
|
|
647
|
+
}[]>;
|
|
648
|
+
private normalizeMessages;
|
|
649
|
+
private getHeaders;
|
|
650
|
+
private request;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Binario Agent - Multi-step reasoning with tools
|
|
654
|
+
*/
|
|
655
|
+
declare class BinarioAgent {
|
|
656
|
+
private client;
|
|
657
|
+
private options;
|
|
658
|
+
constructor(client: Binario, options: AgentOptions);
|
|
659
|
+
/**
|
|
660
|
+
* Run the agent with a user message
|
|
661
|
+
*/
|
|
662
|
+
run(message: string): Promise<AgentResult>;
|
|
663
|
+
/**
|
|
664
|
+
* Run agent with streaming
|
|
665
|
+
*/
|
|
666
|
+
runStream(message: string): AsyncGenerator<{
|
|
667
|
+
type: 'thinking' | 'tool_call' | 'tool_result' | 'response';
|
|
668
|
+
content: string;
|
|
669
|
+
tool?: string;
|
|
670
|
+
}>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
interface BinarioProviderProps {
|
|
674
|
+
apiKey: string;
|
|
675
|
+
baseUrl?: string;
|
|
676
|
+
children: React.ReactNode;
|
|
677
|
+
}
|
|
678
|
+
declare function BinarioProvider({ apiKey, baseUrl, children }: BinarioProviderProps): react.ReactNode;
|
|
679
|
+
declare function useBinarioClient(): Binario;
|
|
680
|
+
interface UseChatOptions {
|
|
681
|
+
model?: string;
|
|
682
|
+
temperature?: number;
|
|
683
|
+
maxTokens?: number;
|
|
684
|
+
systemPrompt?: string;
|
|
685
|
+
initialMessages?: Message[];
|
|
686
|
+
onFinish?: (response: any) => void;
|
|
687
|
+
onError?: (error: Error) => void;
|
|
688
|
+
}
|
|
689
|
+
interface UseChatReturn {
|
|
690
|
+
messages: Message[];
|
|
691
|
+
input: string;
|
|
692
|
+
setInput: (input: string) => void;
|
|
693
|
+
isLoading: boolean;
|
|
694
|
+
error: Error | null;
|
|
695
|
+
send: (content?: string) => Promise<void>;
|
|
696
|
+
setMessages: (messages: Message[]) => void;
|
|
697
|
+
stop: () => void;
|
|
698
|
+
}
|
|
699
|
+
declare function useChat(client: Binario, options?: UseChatOptions): UseChatReturn;
|
|
700
|
+
interface UseStreamOptions extends UseChatOptions {
|
|
701
|
+
onToken?: (token: string) => void;
|
|
702
|
+
}
|
|
703
|
+
interface UseStreamReturn {
|
|
704
|
+
messages: Message[];
|
|
705
|
+
input: string;
|
|
706
|
+
setInput: (input: string) => void;
|
|
707
|
+
isStreaming: boolean;
|
|
708
|
+
error: Error | null;
|
|
709
|
+
streamingContent: string;
|
|
710
|
+
send: (content?: string) => Promise<void>;
|
|
711
|
+
setMessages: (messages: Message[]) => void;
|
|
712
|
+
stop: () => void;
|
|
713
|
+
}
|
|
714
|
+
declare function useStream(client: Binario, options?: UseStreamOptions): UseStreamReturn;
|
|
715
|
+
interface UseAgentOptions {
|
|
716
|
+
name?: string;
|
|
717
|
+
systemPrompt?: string;
|
|
718
|
+
tools: AgentOptions['tools'];
|
|
719
|
+
maxIterations?: number;
|
|
720
|
+
model?: string;
|
|
721
|
+
onToolCall?: (tool: string, args: unknown) => void;
|
|
722
|
+
onError?: (error: Error) => void;
|
|
723
|
+
}
|
|
724
|
+
interface UseAgentReturn {
|
|
725
|
+
output: string;
|
|
726
|
+
isRunning: boolean;
|
|
727
|
+
error: Error | null;
|
|
728
|
+
toolCalls: Array<{
|
|
729
|
+
tool: string;
|
|
730
|
+
args: unknown;
|
|
731
|
+
}>;
|
|
732
|
+
run: (message: string) => Promise<string | null>;
|
|
733
|
+
stop: () => void;
|
|
734
|
+
}
|
|
735
|
+
declare function useAgent(client: Binario, options: UseAgentOptions): UseAgentReturn;
|
|
736
|
+
interface UseUsageReturn {
|
|
737
|
+
usage: {
|
|
738
|
+
requestsUsed: number;
|
|
739
|
+
tokensUsed: number;
|
|
740
|
+
plan: string;
|
|
741
|
+
} | null;
|
|
742
|
+
isLoading: boolean;
|
|
743
|
+
error: Error | null;
|
|
744
|
+
refresh: () => Promise<void>;
|
|
745
|
+
}
|
|
746
|
+
declare function useUsage(client: Binario): UseUsageReturn;
|
|
747
|
+
|
|
748
|
+
export { BinarioProvider, type BinarioProviderProps, type EmbeddingsProviderType, type HookTool, type MemoryType, type SearchDocument, type SearchResult, type UseAgentOptions, type UseAgentReturn, type UseBinarioAgentOptions, type UseBinarioAgentReturn, type UseBinarioChatOptions, type UseBinarioChatReturn, type UseBinarioChatWithMemoryOptions, type UseBinarioChatWithMemoryReturn, type UseBinarioCompletionOptions, type UseBinarioEmbedOptions, type UseBinarioEmbedReturn, type UseBinarioMemoryOptions, type UseBinarioMemoryReturn, type UseBinarioSemanticSearchOptions, type UseBinarioSemanticSearchReturn, type UseBinarioStreamOptions, type UseBinarioStreamReturn, type UseBinarioStructuredOptions, type UseBinarioStructuredReturn, type UseBinarioToolsOptions, type UseBinarioToolsReturn, type UseChatOptions, type UseChatReturn, type UseStreamOptions, type UseStreamReturn, type UseUsageReturn, useAgent, useBinarioAgent, useBinarioChat, useBinarioChatWithMemory, useBinarioClient, useBinarioCompletion, useBinarioEmbed, useBinarioMemory, useBinarioSemanticSearch, useBinarioStream, useBinarioStructured, useBinarioTools, useChat, useStream, useUsage };
|