UNPKG

askexperts

Version:

AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol

86 lines (85 loc) 2.09 kB
import { RagDB } from "../rag/interfaces.js"; import { OpenaiProxyExpertBase } from "./OpenaiProxyExpertBase.js"; import { DocStoreClient } from "../docstore/interfaces.js"; /** * NostrExpert implementation for NIP-174 * Provides an expert that imitates a Nostr user based on their profile and posts */ export declare class NostrExpert { /** * OpenaiExpertBase instance */ private openaiExpert; /** * Public key of the Nostr user to imitate */ private pubkey; /** * Crawled profile data */ private profile?; private posts; /** * RAG embeddings provider */ private ragEmbeddings?; /** * RAG database */ private ragDB; /** * Sync process */ private docstoreToRag; /** * DocStore client */ private docStoreClient; /** * Docstore ID */ private docstoreId; /** * Creates a new NostrExpert instance * * @param options - Configuration options */ constructor(options: { openaiExpert: OpenaiProxyExpertBase; pubkey: string; ragDB: RagDB; docStoreClient: DocStoreClient; docstoreId: string; }); private pubkeyNickname; /** * Starts the expert and crawls the Nostr profile */ start(): Promise<void>; /** * Handles ask events * * @param ask - The ask event * @returns Promise resolving to a bid if interested, or undefined to ignore */ private onAsk; private getDescription; /** * Disposes of resources when the expert is no longer needed */ [Symbol.asyncDispose](): Promise<void>; /** * Extracts hashtags from profile information using OpenAI * * @returns Promise resolving to an array of hashtags */ private extractHashtags; private ragCollectionName; /** * Callback for OpenaiExpert to get context for prompts * * @param prompt - The prompt to get context for * @returns Promise resolving to context string */ private onGetContext; }