Skip to content

Commit 483cccc

Browse files
authored
Package (#2)
* prepare package for publishing * add jscods * bump node version
1 parent c534a27 commit 483cccc

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Weaviate Agents JS/TS client <img alt='Weaviate logo' src='https://weaviate.io/img/site/weaviate-logo-light.png' width='148' align='right' />
2+
3+
JS/TS client for Weaviate Agents.
4+
5+
<br>
6+
7+
> ⚠️ **Alpha Release**: Weaviate Agents is currently in alpha and is subject to change. Features may be modified or removed without notice. Please check that you are using the latest version of the package.
8+
9+
[Documentation](https://weaviate.io/developers/agents)

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@
44
"description": "JS/TS client for Weaviate Agents",
55
"exports": "./dist/index.js",
66
"type": "module",
7+
"engines": {
8+
"node": ">=20.0.0"
9+
},
710
"scripts": {
8-
"build": "tsc"
11+
"build": "tsc",
12+
"prepack": "pnpm build"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/weaviate/agents-typescript-client.git"
917
},
1018
"keywords": [
1119
"weaviate"
1220
],
1321
"author": "Weaviate",
1422
"license": "SEE LICENSE IN LICENSE",
23+
"files": [
24+
"dist"
25+
],
1526
"peerDependencies": {
16-
"weaviate-client": "^3.5.2"
27+
"weaviate-client": "^3.5.4"
1728
},
1829
"devDependencies": {
1930
"typescript": "^5.8.3"

src/query/agent.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@ import { WeaviateClient } from "weaviate-client";
22
import { QueryAgentResponse } from "./response/response.js";
33
import { mapResponse } from "./response/response-mapping.js";
44

5+
/**
6+
* An agent for executing agentic queries against Weaviate.
7+
*
8+
* Warning:
9+
* Weaviate Agents - Query Agent is an early stage alpha product.
10+
* The API is subject to breaking changes. Please ensure you are using the latest version of the client.
11+
*
12+
* For more information, see the [Weaviate Query Agent Docs](https://weaviate.io/developers/agents/query)
13+
*/
514
export class QueryAgent {
615
private systemPrompt?: string;
716
private agentsHost: string;
817

18+
/**
19+
* Creates a new QueryAgent instance.
20+
*
21+
* @param client - The Weaviate client instance.
22+
* @param collections - The collections to query.
23+
* @param options - Additional options for the QueryAgent.
24+
*/
925
constructor(
1026
private client: WeaviateClient,
1127
private collections: string[],
@@ -18,6 +34,13 @@ export class QueryAgent {
1834
this.agentsHost = agentsHost;
1935
}
2036

37+
/**
38+
* Run the query agent.
39+
*
40+
* @param query - The natural language query string for the agent.
41+
* @param options - Additional options for the run.
42+
* @returns The response from the query agent.
43+
*/
2144
async run(
2245
query: string,
2346
{ viewProperties }: QueryAgentRunOptions = {}
@@ -51,11 +74,16 @@ export class QueryAgent {
5174
}
5275
}
5376

77+
/** Options for the QueryAgent. */
5478
export type QueryAgentOptions = {
79+
/** System prompt to guide the agent's behavior. */
5580
systemPrompt?: string;
81+
/** Host of the agents service. */
5682
agentsHost?: string;
5783
};
5884

85+
/** Options for the QueryAgent run. */
5986
export type QueryAgentRunOptions = {
87+
/** List of of property names the agent has the ability to view across all collections. */
6088
viewProperties?: string[];
6189
};

src/query/response/response.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ type PropertyFilterBase = {
3232
operator: ComparisonOperator;
3333
};
3434

35+
/** Filter numeric properties using comparison operators */
3536
export type IntegerPropertyFilter = PropertyFilterBase & {
3637
value: number;
3738
};
3839

40+
/** Filter text properties using equality or LIKE operators */
3941
export type TextPropertyFilter = PropertyFilterBase & {
4042
value: string;
4143
};
4244

45+
/** Filter boolean properties using equality operators */
4346
export type BooleanPropertyFilter = PropertyFilterBase & {
4447
value: boolean;
4548
};
@@ -54,6 +57,12 @@ export enum ComparisonOperator {
5457
Like = "LIKE",
5558
}
5659

60+
/**
61+
* The aggregations performed on a collection in a vector database.
62+
*
63+
* They should be based on the original user query and can include multiple
64+
* aggregations across different properties and metrics.
65+
*/
5766
export type AggregationResult = {
5867
collection: string;
5968
searchQuery?: string;
@@ -71,15 +80,18 @@ type PropertyAggregationBase = {
7180
propertyName: string;
7281
};
7382

83+
/** Aggregate numeric properties using statistical functions */
7484
export type IntegerPropertyAggregation = PropertyAggregationBase & {
7585
metrics: NumericMetrics;
7686
};
7787

88+
/** Aggregate text properties using frequency analysis */
7889
export type TextPropertyAggregation = PropertyAggregationBase & {
7990
metrics: TextMetrics;
8091
topOccurrencesLimit?: number;
8192
};
8293

94+
/** Aggregate boolean properties using statistical functions */
8395
export type BooleanPropertyAggregation = PropertyAggregationBase & {
8496
metrics: BooleanMetrics;
8597
};

0 commit comments

Comments
 (0)