diff --git a/README.md b/README.md index 06af810..a9258b6 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,8 @@ Zep: Long-Term Memory for ‍AI Assistants.

-Quick Start | -Documentation | -LangChain and -LlamaIndex Support | +Documentation | +LangChain | Discord
www.getzep.com

diff --git a/examples/memory/memory_example.ts b/examples/memory/memory_example.ts index 2d6ee98..361343b 100644 --- a/examples/memory/memory_example.ts +++ b/examples/memory/memory_example.ts @@ -247,6 +247,14 @@ async function main() { console.error("Got error:", error); } } + + // End session - this will trigger summarization and other background tasks on the completed session + try { + await client.memory.endSession(sessionID); + console.debug("Ended session: ", sessionID); + } catch (error) { + console.debug("Got error:", error); + } } main(); diff --git a/package.json b/package.json index 30bcba6..e49fce9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getzep/zep-cloud", - "version": "1.0.1", + "version": "1.0.2", "private": false, "repository": "/~https://github.com/getzep/zep-js", "description": "Zep: Fast, scalable building blocks for production LLM apps", diff --git a/src/api/resources/document/client/Client.ts b/src/api/resources/document/client/Client.ts index 7e89d59..d736d6e 100644 --- a/src/api/resources/document/client/Client.ts +++ b/src/api/resources/document/client/Client.ts @@ -48,7 +48,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -139,7 +139,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -252,7 +252,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -366,7 +366,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -479,7 +479,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -594,7 +594,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -699,7 +699,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -804,7 +804,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -909,7 +909,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1014,7 +1014,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1117,7 +1117,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1232,7 +1232,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1351,7 +1351,7 @@ export class Document { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), diff --git a/src/api/resources/memory/client/Client.ts b/src/api/resources/memory/client/Client.ts index 1c09fa0..b08f310 100644 --- a/src/api/resources/memory/client/Client.ts +++ b/src/api/resources/memory/client/Client.ts @@ -52,7 +52,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -160,7 +160,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -247,7 +247,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -341,7 +341,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -446,7 +446,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -511,6 +511,98 @@ export class Memory { } } + /** + * End a session by ID + * + * @param {string} sessionId - Session ID + * @param {Zep.EndSessionRequest} request + * @param {Memory.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Zep.NotFoundError} + * @throws {@link Zep.InternalServerError} + * + * @example + * await zep.memory.endSession("sessionId") + */ + public async endSession( + sessionId: string, + request: Zep.EndSessionRequest = {}, + requestOptions?: Memory.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.ZepEnvironment.Default, + `sessions/${encodeURIComponent(sessionId)}/end` + ), + method: "POST", + headers: { + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "zep-cloud", + "X-Fern-SDK-Version": "1.0.2", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...(await this._getCustomAuthorizationHeaders()), + }, + contentType: "application/json", + body: await serializers.EndSessionRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.Session.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Zep.NotFoundError( + await serializers.ApiError.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new Zep.InternalServerError( + await serializers.ApiError.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.ZepError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.ZepError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.ZepTimeoutError(); + case "unknown": + throw new errors.ZepError({ + message: _response.error.errorMessage, + }); + } + } + /** * extract data from a session by session id * @@ -540,7 +632,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -642,7 +734,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -735,7 +827,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -812,7 +904,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -913,7 +1005,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1005,7 +1097,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1100,7 +1192,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1200,7 +1292,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1291,7 +1383,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -1388,7 +1480,7 @@ export class Memory { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), diff --git a/src/api/resources/memory/client/requests/EndSessionRequest.ts b/src/api/resources/memory/client/requests/EndSessionRequest.ts new file mode 100644 index 0000000..48c64b3 --- /dev/null +++ b/src/api/resources/memory/client/requests/EndSessionRequest.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface EndSessionRequest { + instruction?: string; +} diff --git a/src/api/resources/memory/client/requests/index.ts b/src/api/resources/memory/client/requests/index.ts index c56ecfd..dbea726 100644 --- a/src/api/resources/memory/client/requests/index.ts +++ b/src/api/resources/memory/client/requests/index.ts @@ -2,6 +2,7 @@ export { type CreateSessionRequest } from "./CreateSessionRequest"; export { type MemoryListSessionsRequest } from "./MemoryListSessionsRequest"; export { type UpdateSessionRequest } from "./UpdateSessionRequest"; export { type ClassifySessionRequest } from "./ClassifySessionRequest"; +export { type EndSessionRequest } from "./EndSessionRequest"; export { type ModelsExtractDataRequest } from "./ModelsExtractDataRequest"; export { type MemoryGetRequest } from "./MemoryGetRequest"; export { type AddMemoryRequest } from "./AddMemoryRequest"; diff --git a/src/api/resources/user/client/Client.ts b/src/api/resources/user/client/Client.ts index cc6bca9..e88fe5c 100644 --- a/src/api/resources/user/client/Client.ts +++ b/src/api/resources/user/client/Client.ts @@ -47,7 +47,7 @@ export class User { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -147,7 +147,7 @@ export class User { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -234,7 +234,7 @@ export class User { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -320,7 +320,7 @@ export class User { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -412,7 +412,7 @@ export class User { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), @@ -508,7 +508,7 @@ export class User { headers: { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.1", + "X-Fern-SDK-Version": "1.0.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...(await this._getCustomAuthorizationHeaders()), diff --git a/src/api/types/Session.ts b/src/api/types/Session.ts index 51caf34..f0a9a74 100644 --- a/src/api/types/Session.ts +++ b/src/api/types/Session.ts @@ -6,6 +6,7 @@ export interface Session { classifications?: Record; createdAt?: string; deletedAt?: string; + endedAt?: string; facts?: string[]; id?: number; metadata?: Record; diff --git a/src/serialization/resources/memory/client/requests/EndSessionRequest.ts b/src/serialization/resources/memory/client/requests/EndSessionRequest.ts new file mode 100644 index 0000000..d3edbea --- /dev/null +++ b/src/serialization/resources/memory/client/requests/EndSessionRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../../index"; +import * as Zep from "../../../../../api/index"; +import * as core from "../../../../../core"; + +export const EndSessionRequest: core.serialization.Schema = + core.serialization.object({ + instruction: core.serialization.string().optional(), + }); + +export declare namespace EndSessionRequest { + interface Raw { + instruction?: string | null; + } +} diff --git a/src/serialization/resources/memory/client/requests/index.ts b/src/serialization/resources/memory/client/requests/index.ts index 692b6db..2af7ec3 100644 --- a/src/serialization/resources/memory/client/requests/index.ts +++ b/src/serialization/resources/memory/client/requests/index.ts @@ -1,6 +1,7 @@ export { CreateSessionRequest } from "./CreateSessionRequest"; export { UpdateSessionRequest } from "./UpdateSessionRequest"; export { ClassifySessionRequest } from "./ClassifySessionRequest"; +export { EndSessionRequest } from "./EndSessionRequest"; export { ModelsExtractDataRequest } from "./ModelsExtractDataRequest"; export { AddMemoryRequest } from "./AddMemoryRequest"; export { ModelsMessageMetadataUpdate } from "./ModelsMessageMetadataUpdate"; diff --git a/src/serialization/types/Session.ts b/src/serialization/types/Session.ts index 1dfca8b..9c14e75 100644 --- a/src/serialization/types/Session.ts +++ b/src/serialization/types/Session.ts @@ -11,6 +11,7 @@ export const Session: core.serialization.ObjectSchema | null; created_at?: string | null; deleted_at?: string | null; + ended_at?: string | null; facts?: string[] | null; id?: number | null; metadata?: Record | null;