Skip to content

Commit b0f476b

Browse files
Task management API (#166)
* SDK regeneration * chore: Version bump * chore: Version bump * SDK regeneration * wip * chore: Add support for user and graph specific entity/edge types * chore: Add support for ontology target * SDK regeneration * chore: Add support for multiple ontology targets * SDK regeneration * fix: redundant default to empty list * fix: comment * fix: comment * chore: Bump version * SDK regeneration * feat: Update context string utility to include entity attributes and episodes * SDK regeneration * chore: Version bump * SDK regeneration * chore: Version bump * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * chore: Version bump * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * SDK regeneration * chore: Version bump * SDK regeneration * SDK regeneration * SDK regeneration * SDK regeneration * chore: Version bump * SDK regeneration --------- Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 7c3ebe7 commit b0f476b

32 files changed

+442
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@getzep/zep-cloud",
3-
"version": "3.12.0",
3+
"version": "3.13.0",
44
"private": false,
55
"repository": "https://github.com/getzep/zep-js",
66
"description": "Zep: Fast, scalable building blocks for production LLM apps",

reference.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ Add a fact triple for a user or group
620620
await client.graph.addFactTriple({
621621
fact: "fact",
622622
factName: "fact_name",
623+
sourceNodeName: "source_node_name",
623624
targetNodeName: "target_node_name",
624625
});
625626
```
@@ -1169,6 +1170,71 @@ await client.project.get();
11691170
</dl>
11701171
</details>
11711172

1173+
## Task
1174+
1175+
<details><summary><code>client.task.<a href="/src/api/resources/task/client/Client.ts">get</a>(taskId) -> Zep.GetTaskResponse</code></summary>
1176+
<dl>
1177+
<dd>
1178+
1179+
#### 📝 Description
1180+
1181+
<dl>
1182+
<dd>
1183+
1184+
<dl>
1185+
<dd>
1186+
1187+
Gets a task by its ID
1188+
1189+
</dd>
1190+
</dl>
1191+
</dd>
1192+
</dl>
1193+
1194+
#### 🔌 Usage
1195+
1196+
<dl>
1197+
<dd>
1198+
1199+
<dl>
1200+
<dd>
1201+
1202+
```typescript
1203+
await client.task.get("task_id");
1204+
```
1205+
1206+
</dd>
1207+
</dl>
1208+
</dd>
1209+
</dl>
1210+
1211+
#### ⚙️ Parameters
1212+
1213+
<dl>
1214+
<dd>
1215+
1216+
<dl>
1217+
<dd>
1218+
1219+
**taskId:** `string` — Task ID
1220+
1221+
</dd>
1222+
</dl>
1223+
1224+
<dl>
1225+
<dd>
1226+
1227+
**requestOptions:** `Task.RequestOptions`
1228+
1229+
</dd>
1230+
</dl>
1231+
</dd>
1232+
</dl>
1233+
1234+
</dd>
1235+
</dl>
1236+
</details>
1237+
11721238
## Thread
11731239

11741240
<details><summary><code>client.thread.<a href="/src/api/resources/thread/client/Client.ts">listAll</a>({ ...params }) -> Zep.ThreadListResponse</code></summary>

src/Client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { mergeHeaders } from "./core/headers.js";
88
import { Context } from "./api/resources/context/client/Client.js";
99
import { Graph } from "./api/resources/graph/client/Client.js";
1010
import { Project } from "./api/resources/project/client/Client.js";
11+
import { Task } from "./api/resources/task/client/Client.js";
1112
import { Thread } from "./api/resources/thread/client/Client.js";
1213
import { User } from "./api/resources/user/client/Client.js";
1314

@@ -39,6 +40,7 @@ export class ZepClient {
3940
protected _context: Context | undefined;
4041
protected _graph: Graph | undefined;
4142
protected _project: Project | undefined;
43+
protected _task: Task | undefined;
4244
protected _thread: Thread | undefined;
4345
protected _user: User | undefined;
4446

@@ -49,8 +51,8 @@ export class ZepClient {
4951
{
5052
"X-Fern-Language": "JavaScript",
5153
"X-Fern-SDK-Name": "zep-cloud",
52-
"X-Fern-SDK-Version": "3.12.0",
53-
"User-Agent": "zep-cloud/3.12.0",
54+
"X-Fern-SDK-Version": "3.13.0",
55+
"User-Agent": "zep-cloud/3.13.0",
5456
"X-Fern-Runtime": core.RUNTIME.type,
5557
"X-Fern-Runtime-Version": core.RUNTIME.version,
5658
},
@@ -71,6 +73,10 @@ export class ZepClient {
7173
return (this._project ??= new Project(this._options));
7274
}
7375

76+
public get task(): Task {
77+
return (this._task ??= new Task(this._options));
78+
}
79+
7480
public get thread(): Thread {
7581
return (this._thread ??= new Thread(this._options));
7682
}

src/api/resources/graph/client/Client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ export class Graph {
534534
* await client.graph.addFactTriple({
535535
* fact: "fact",
536536
* factName: "fact_name",
537+
* sourceNodeName: "source_node_name",
537538
* targetNodeName: "target_node_name"
538539
* })
539540
*/

src/api/resources/graph/client/requests/AddTripleRequest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* {
88
* fact: "fact",
99
* factName: "fact_name",
10+
* sourceNodeName: "source_node_name",
1011
* targetNodeName: "target_node_name"
1112
* }
1213
*/
@@ -25,7 +26,7 @@ export interface AddTripleRequest {
2526
/** The time (if any) at which the fact stops being true */
2627
invalidAt?: string;
2728
/** The name of the source node to add */
28-
sourceNodeName?: string;
29+
sourceNodeName: string;
2930
/** The summary of the source node to add */
3031
sourceNodeSummary?: string;
3132
/** The source node uuid */

src/api/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export * from "./thread/types/index.js";
33
export * as context from "./context/index.js";
44
export * as graph from "./graph/index.js";
55
export * as project from "./project/index.js";
6+
export * as task from "./task/index.js";
67
export * as user from "./user/index.js";
78
export * from "./context/client/requests/index.js";
89
export * from "./graph/client/requests/index.js";
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
import * as environments from "../../../../environments.js";
6+
import * as core from "../../../../core/index.js";
7+
import * as Zep from "../../../index.js";
8+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
9+
import * as serializers from "../../../../serialization/index.js";
10+
import * as errors from "../../../../errors/index.js";
11+
12+
export declare namespace Task {
13+
export interface Options {
14+
environment?: core.Supplier<environments.ZepEnvironment | string>;
15+
/** Specify a custom URL to connect the client to. */
16+
baseUrl?: core.Supplier<string>;
17+
apiKey?: core.Supplier<string | undefined>;
18+
/** Additional headers to include in requests. */
19+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
20+
fetcher?: core.FetchFunction;
21+
}
22+
23+
export interface RequestOptions {
24+
/** The maximum time to wait for a response in seconds. */
25+
timeoutInSeconds?: number;
26+
/** The number of times to retry the request. Defaults to 2. */
27+
maxRetries?: number;
28+
/** A hook to abort the request. */
29+
abortSignal?: AbortSignal;
30+
/** Additional headers to include in the request. */
31+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
32+
}
33+
}
34+
35+
export class Task {
36+
protected readonly _options: Task.Options;
37+
38+
constructor(_options: Task.Options = {}) {
39+
this._options = _options;
40+
}
41+
42+
/**
43+
* Gets a task by its ID
44+
*
45+
* @param {string} taskId - Task ID
46+
* @param {Task.RequestOptions} requestOptions - Request-specific configuration.
47+
*
48+
* @throws {@link Zep.NotFoundError}
49+
* @throws {@link Zep.InternalServerError}
50+
*
51+
* @example
52+
* await client.task.get("task_id")
53+
*/
54+
public get(taskId: string, requestOptions?: Task.RequestOptions): core.HttpResponsePromise<Zep.GetTaskResponse> {
55+
return core.HttpResponsePromise.fromPromise(this.__get(taskId, requestOptions));
56+
}
57+
58+
private async __get(
59+
taskId: string,
60+
requestOptions?: Task.RequestOptions,
61+
): Promise<core.WithRawResponse<Zep.GetTaskResponse>> {
62+
const _response = await (this._options.fetcher ?? core.fetcher)({
63+
url: core.url.join(
64+
(await core.Supplier.get(this._options.baseUrl)) ??
65+
(await core.Supplier.get(this._options.environment)) ??
66+
environments.ZepEnvironment.Default,
67+
`tasks/${encodeURIComponent(taskId)}`,
68+
),
69+
method: "GET",
70+
headers: mergeHeaders(
71+
this._options?.headers,
72+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
73+
requestOptions?.headers,
74+
),
75+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
76+
maxRetries: requestOptions?.maxRetries,
77+
abortSignal: requestOptions?.abortSignal,
78+
});
79+
if (_response.ok) {
80+
return {
81+
data: serializers.GetTaskResponse.parseOrThrow(_response.body, {
82+
unrecognizedObjectKeys: "passthrough",
83+
allowUnrecognizedUnionMembers: true,
84+
allowUnrecognizedEnumValues: true,
85+
skipValidation: true,
86+
breadcrumbsPrefix: ["response"],
87+
}),
88+
rawResponse: _response.rawResponse,
89+
};
90+
}
91+
92+
if (_response.error.reason === "status-code") {
93+
switch (_response.error.statusCode) {
94+
case 404:
95+
throw new Zep.NotFoundError(
96+
serializers.ApiError.parseOrThrow(_response.error.body, {
97+
unrecognizedObjectKeys: "passthrough",
98+
allowUnrecognizedUnionMembers: true,
99+
allowUnrecognizedEnumValues: true,
100+
skipValidation: true,
101+
breadcrumbsPrefix: ["response"],
102+
}),
103+
_response.rawResponse,
104+
);
105+
case 500:
106+
throw new Zep.InternalServerError(
107+
serializers.ApiError.parseOrThrow(_response.error.body, {
108+
unrecognizedObjectKeys: "passthrough",
109+
allowUnrecognizedUnionMembers: true,
110+
allowUnrecognizedEnumValues: true,
111+
skipValidation: true,
112+
breadcrumbsPrefix: ["response"],
113+
}),
114+
_response.rawResponse,
115+
);
116+
default:
117+
throw new errors.ZepError({
118+
statusCode: _response.error.statusCode,
119+
body: _response.error.body,
120+
rawResponse: _response.rawResponse,
121+
});
122+
}
123+
}
124+
125+
switch (_response.error.reason) {
126+
case "non-json":
127+
throw new errors.ZepError({
128+
statusCode: _response.error.statusCode,
129+
body: _response.error.rawBody,
130+
rawResponse: _response.rawResponse,
131+
});
132+
case "timeout":
133+
throw new errors.ZepTimeoutError("Timeout exceeded when calling GET /tasks/{task_id}.");
134+
case "unknown":
135+
throw new errors.ZepError({
136+
message: _response.error.errorMessage,
137+
rawResponse: _response.rawResponse,
138+
});
139+
}
140+
}
141+
142+
protected async _getCustomAuthorizationHeaders() {
143+
const apiKeyValue = (await core.Supplier.get(this._options.apiKey)) ?? process?.env["ZEP_API_KEY"];
144+
return { Authorization: `Api-Key ${apiKeyValue}` };
145+
}
146+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

src/api/resources/task/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./client/index.js";

src/api/types/AddThreadMessagesResponse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
export interface AddThreadMessagesResponse {
66
context?: string;
77
messageUuids?: string[];
8+
taskId?: string;
89
}

0 commit comments

Comments
 (0)