@hashbrownai/writer
Version:
Writer provider for Hashbrown AI
39 lines (38 loc) • 1.32 kB
TypeScript
import Writer from 'writer-sdk';
import { Chat } from '@hashbrownai/core';
/**
* The options for the Writer text stream.
*/
type BaseWriterTextStreamOptions = {
/**
* The API Key for the Writer API.
*/
apiKey: string;
/**
* The request for the stream.
*/
request: Chat.Api.CompletionCreateParams;
/**
* A function to transform the request options.
*/
transformRequestOptions?: (options: Writer.Chat.ChatChatParams) => Writer.Chat.ChatChatParams | Promise<Writer.Chat.ChatChatParams>;
};
type ThreadPersistenceOptions = {
loadThread: (threadId: string) => Promise<Chat.Api.Message[]>;
saveThread: (thread: Chat.Api.Message[], threadId?: string) => Promise<string>;
};
type ThreadlessOptions = BaseWriterTextStreamOptions & {
loadThread?: undefined;
saveThread?: undefined;
};
type ThreadfulOptions = BaseWriterTextStreamOptions & ThreadPersistenceOptions;
export type WriterTextStreamOptions = ThreadlessOptions | ThreadfulOptions;
/**
* Streams text from the Writer API.
*
* @param options - The options for the stream.
* @returns An async iterable of Uint8Arrays.
*/
export declare function text(options: ThreadfulOptions): AsyncIterable<Uint8Array>;
export declare function text(options: ThreadlessOptions): AsyncIterable<Uint8Array>;
export {};