Skip to content

Commit

Permalink
Add end session method (#71)
Browse files Browse the repository at this point in the history
* chore: Version bump

* SDK regeneration

* chore: Update documentation links

* SDK regeneration

* chore: Version bump

* chore: Add end session example

* chore: cleanup

* chore: cleanup

---------

Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
paul-paliychuk and fern-api[bot] authored May 14, 2024
1 parent cfb1093 commit 85dbee3
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 39 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ Zep: Long-Term Memory for ‍AI Assistants.
<br />

<p align="center">
<a href="https://docs.getzep.com/deployment/quickstart/">Quick Start</a> |
<a href="https://docs.getzep.com/">Documentation</a> |
<a href="https://docs.getzep.com/sdk/langchain/">LangChain</a> and
<a href="https://docs.getzep.com/sdk/langchain/">LlamaIndex</a> Support |
<a href="https://help.getzep.com">Documentation</a> |
<a href="https://help.getzep.com/langchain/overview">LangChain</a> |
<a href="https://discord.gg/W8Kw6bsgXQ">Discord</a><br />
<a href="https://www.getzep.com">www.getzep.com</a>
</p>
Expand Down
8 changes: 8 additions & 0 deletions examples/memory/memory_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
26 changes: 13 additions & 13 deletions src/api/resources/document/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down
122 changes: 107 additions & 15 deletions src/api/resources/memory/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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<Zep.Session> {
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
*
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down
11 changes: 11 additions & 0 deletions src/api/resources/memory/client/requests/EndSessionRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

/**
* @example
* {}
*/
export interface EndSessionRequest {
instruction?: string;
}
Loading

0 comments on commit 85dbee3

Please sign in to comment.