askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
67 lines (66 loc) • 2.44 kB
TypeScript
import { AskExpertsClient } from "./AskExpertsClient.js";
import { ExpertPaymentManager } from "../payments/ExpertPaymentManager.js";
import { Proof, Quote, Prompt } from "../common/types.js";
/**
* AskExpertsPayingClient class that extends AskExpertsClient with payment capabilities
* This class abstracts payment handling logic that was duplicated in AskExpertsSmartClient and AskExpertsChatClient
*/
export declare class AskExpertsPayingClient extends AskExpertsClient {
#private;
/**
* Creates a new AskExpertsPayingClient instance
*
* @param paymentManager - Payment manager for handling payments
* @param options - Optional configuration
* @param options.maxAmountSats - Maximum amount to pay in satoshis
* @param options.discoveryRelays - Array of discovery relay URLs to use as fallback
*/
constructor(paymentManager: ExpertPaymentManager, options?: {
maxAmountSats?: number;
discoveryRelays?: string[];
onPaid?: (prompt: Prompt, quote: Quote, proof: Proof) => Promise<void>;
});
/**
* Sets the maximum amount to pay in satoshis
*
* @param maxAmountSats - Maximum amount to pay in satoshis
*/
/**
* Gets the maximum amount to pay in satoshis
*/
get maxAmountSats(): number;
/**
* Sets the maximum amount to pay in satoshis
*/
set maxAmountSats(value: number);
/**
* Gets the current onPaid callback function
*/
get onPaid(): ((prompt: Prompt, quote: Quote, proof: Proof) => Promise<void>) | undefined;
/**
* Sets the onPaid callback function
*/
set onPaid(callback: (prompt: Prompt, quote: Quote, proof: Proof) => Promise<void>);
/**
* Handles quote events from experts
*
* @param quote - Quote from expert
* @param prompt - Prompt sent to expert
* @returns Promise resolving to boolean indicating whether to proceed with payment
* @protected
*/
protected handleQuote(quote: Quote, prompt: Prompt): Promise<boolean>;
/**
* Handles payment for quotes
*
* @param quote - Quote from expert
* @param prompt - Prompt sent to expert
* @returns Promise resolving to Proof object
* @protected
*/
protected handlePayment(quote: Quote, prompt: Prompt): Promise<Proof>;
/**
* Disposes of resources when the client is no longer needed
*/
[Symbol.dispose](): void;
}