weaviate-agents
Version:
JS/TS client for Weaviate Agents
84 lines (83 loc) • 3.49 kB
TypeScript
import { WeaviateClient } from "weaviate-client";
import { QueryAgentResponse, ProgressMessage, StreamedTokens } from "./response/response.js";
import { QueryAgentCollectionConfig } from "./collection.js";
/**
* An agent for executing agentic queries against Weaviate.
*
* Warning:
* Weaviate Agents - Query Agent is an early stage alpha product.
* The API is subject to breaking changes. Please ensure you are using the latest version of the client.
*
* For more information, see the [Weaviate Query Agent Docs](https://weaviate.io/developers/agents/query)
*/
export declare class QueryAgent {
private client;
private collections?;
private systemPrompt?;
private agentsHost;
/**
* Creates a new QueryAgent instance.
*
* @param client - The Weaviate client instance.
* @param options - Additional options for the QueryAgent.
*/
constructor(client: WeaviateClient, { collections, systemPrompt, agentsHost, }?: QueryAgentOptions);
/**
* Run the query agent.
*
* @param query - The natural language query string for the agent.
* @param options - Additional options for the run.
* @returns The response from the query agent.
*/
run(query: string, { collections, context }?: QueryAgentRunOptions): Promise<QueryAgentResponse>;
/**
* Stream responses from the query agent.
*
* @param query - The natural language query string for the agent.
* @param options - Additional options for the run.
* @returns The response from the query agent.
*/
stream(query: string, options: QueryAgentStreamOptions & {
includeProgress: false;
includeFinalState: false;
}): AsyncGenerator<StreamedTokens>;
stream(query: string, options: QueryAgentStreamOptions & {
includeProgress: false;
includeFinalState?: true;
}): AsyncGenerator<StreamedTokens | QueryAgentResponse>;
stream(query: string, options: QueryAgentStreamOptions & {
includeProgress?: true;
includeFinalState: false;
}): AsyncGenerator<ProgressMessage | StreamedTokens>;
stream(query: string, options?: QueryAgentStreamOptions & {
includeProgress?: true;
includeFinalState?: true;
}): AsyncGenerator<ProgressMessage | StreamedTokens | QueryAgentResponse>;
}
/** Options for the QueryAgent. */
export type QueryAgentOptions = {
/** List of collections to query. Will be overriden if passed in the `run` method. */
collections?: (string | QueryAgentCollectionConfig)[];
/** System prompt to guide the agent's behavior. */
systemPrompt?: string;
/** Host of the agents service. */
agentsHost?: string;
};
/** Options for the QueryAgent run. */
export type QueryAgentRunOptions = {
/** List of collections to query. Will override any collections if passed in the constructor. */
collections?: (string | QueryAgentCollectionConfig)[];
/** Previous response from the agent. */
context?: QueryAgentResponse;
};
/** Options for the QueryAgent stream. */
export type QueryAgentStreamOptions = {
/** List of collections to query. Will override any collections if passed in the constructor. */
collections?: (string | QueryAgentCollectionConfig)[];
/** Previous response from the agent. */
context?: QueryAgentResponse;
/** Include progress messages in the stream. */
includeProgress?: boolean;
/** Include final state in the stream. */
includeFinalState?: boolean;
};