@getzep/zep-js
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -14,2 +14,9 @@ import { Memory, SearchPayload, SearchResult } from "./models"; | ||
/** | ||
* Initializes the ZepClient instance by checking if the server is running. | ||
* @returns {Promise<boolean>} - A promise that returns true if the server | ||
* is running, false otherwise. | ||
* @throws {Error} - Throws an error if the server is not running. | ||
*/ | ||
init(): Promise<boolean>; | ||
/** | ||
* Retrieves memory for a specific session. | ||
@@ -16,0 +23,0 @@ * @param {string} sessionID - The ID of the session to retrieve memory for. |
@@ -24,2 +24,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
/** | ||
* Initializes the ZepClient instance by checking if the server is running. | ||
* @returns {Promise<boolean>} - A promise that returns true if the server | ||
* is running, false otherwise. | ||
* @throws {Error} - Throws an error if the server is not running. | ||
*/ | ||
init() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const healthCheck = "/healthz"; | ||
const healthCheckURL = `${this.baseURL}${healthCheck}`; | ||
const response = yield this.axiosInstance.get(healthCheckURL); | ||
return response.status === 200; | ||
} | ||
catch (error) { | ||
if (error instanceof AxiosError && error.code === "ECONNREFUSED") { | ||
// The server is not accepting connections. | ||
return false; | ||
} | ||
throw error; // Rethrow other errors. | ||
} | ||
}); | ||
} | ||
/** | ||
* Retrieves memory for a specific session. | ||
@@ -43,3 +66,5 @@ * @param {string} sessionID - The ID of the session to retrieve memory for. | ||
return new Memory({ | ||
messages: response.data.messages.map((message) => new Message(message)), | ||
messages: response.data.messages.map((message) => { | ||
return new Message(message); | ||
}), | ||
summary: response.data.summary, | ||
@@ -57,2 +82,6 @@ }); | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof AxiosError && error.code === "ECONNREFUSED") { | ||
throw new UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof AxiosError && error.response) { | ||
@@ -86,2 +115,6 @@ // Handle AxiosError case | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof AxiosError && error.code === "ECONNREFUSED") { | ||
throw new UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof AxiosError && error.response) { | ||
@@ -117,2 +150,6 @@ throw new UnexpectedResponseError(`addMemoryAsync got an Unexpected status code: ${error.response.status}`); | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof AxiosError && error.code === "ECONNREFUSED") { | ||
throw new UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof AxiosError && error.response) { | ||
@@ -157,2 +194,6 @@ // Handle AxiosError case | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof AxiosError && error.code === "ECONNREFUSED") { | ||
throw new UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof AxiosError && error.response) { | ||
@@ -159,0 +200,0 @@ // Handle AxiosError case |
@@ -14,2 +14,9 @@ import { Memory, SearchPayload, SearchResult } from "./models"; | ||
/** | ||
* Initializes the ZepClient instance by checking if the server is running. | ||
* @returns {Promise<boolean>} - A promise that returns true if the server | ||
* is running, false otherwise. | ||
* @throws {Error} - Throws an error if the server is not running. | ||
*/ | ||
init(): Promise<boolean>; | ||
/** | ||
* Retrieves memory for a specific session. | ||
@@ -16,0 +23,0 @@ * @param {string} sessionID - The ID of the session to retrieve memory for. |
@@ -50,2 +50,25 @@ "use strict"; | ||
/** | ||
* Initializes the ZepClient instance by checking if the server is running. | ||
* @returns {Promise<boolean>} - A promise that returns true if the server | ||
* is running, false otherwise. | ||
* @throws {Error} - Throws an error if the server is not running. | ||
*/ | ||
init() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const healthCheck = "/healthz"; | ||
const healthCheckURL = `${this.baseURL}${healthCheck}`; | ||
const response = yield this.axiosInstance.get(healthCheckURL); | ||
return response.status === 200; | ||
} | ||
catch (error) { | ||
if (error instanceof axios_1.AxiosError && error.code === "ECONNREFUSED") { | ||
// The server is not accepting connections. | ||
return false; | ||
} | ||
throw error; // Rethrow other errors. | ||
} | ||
}); | ||
} | ||
/** | ||
* Retrieves memory for a specific session. | ||
@@ -69,3 +92,5 @@ * @param {string} sessionID - The ID of the session to retrieve memory for. | ||
return new models_1.Memory({ | ||
messages: response.data.messages.map((message) => new models_1.Message(message)), | ||
messages: response.data.messages.map((message) => { | ||
return new models_1.Message(message); | ||
}), | ||
summary: response.data.summary, | ||
@@ -83,2 +108,6 @@ }); | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof axios_1.AxiosError && error.code === "ECONNREFUSED") { | ||
throw new exceptions_1.UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof axios_1.AxiosError && error.response) { | ||
@@ -112,2 +141,6 @@ // Handle AxiosError case | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof axios_1.AxiosError && error.code === "ECONNREFUSED") { | ||
throw new exceptions_1.UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof axios_1.AxiosError && error.response) { | ||
@@ -143,2 +176,6 @@ throw new exceptions_1.UnexpectedResponseError(`addMemoryAsync got an Unexpected status code: ${error.response.status}`); | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof axios_1.AxiosError && error.code === "ECONNREFUSED") { | ||
throw new exceptions_1.UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof axios_1.AxiosError && error.response) { | ||
@@ -183,2 +220,6 @@ // Handle AxiosError case | ||
catch (error) { | ||
// Connection error | ||
if (error instanceof axios_1.AxiosError && error.code === "ECONNREFUSED") { | ||
throw new exceptions_1.UnexpectedResponseError(`Server is down or connection was refused, from Zep at ${this.baseURL}`); | ||
} | ||
if (error instanceof axios_1.AxiosError && error.response) { | ||
@@ -185,0 +226,0 @@ // Handle AxiosError case |
{ | ||
"show-config": "tsc --showConfig", | ||
"name": "@getzep/zep-js", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Zep JS Client", | ||
@@ -6,0 +6,0 @@ "private": false, |
92966
1775