Comparing version 1.1.3 to 1.1.4
@@ -225,4 +225,21 @@ import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream'; | ||
streamText(options: StreamOptions): Promise<StreamResponse>; | ||
/** | ||
* Creates a new pipe on Langbase. | ||
* | ||
* @param {PipeCreateOptions} options - The options for creating the pipe. | ||
* @returns {Promise<PipeCreateResponse>} A promise that resolves to the response of the pipe creation. | ||
*/ | ||
create(options: PipeCreateOptions): Promise<PipeCreateResponse>; | ||
/** | ||
* Updates a pipe on Langbase. | ||
* | ||
* @param {PipeUpdateOptions} options - The options for updating the pipe. | ||
* @returns {Promise<PipeUpdateResponse>} A promise that resolves to the response of the update operation. | ||
*/ | ||
update(options: PipeUpdateOptions): Promise<PipeUpdateResponse>; | ||
/** | ||
* Retrieves a list of pipes. | ||
* | ||
* @returns {Promise<PipeListResponse[]>} A promise that resolves to an array of PipeListResponse objects. | ||
*/ | ||
list(): Promise<PipeListResponse[]>; | ||
@@ -249,2 +266,30 @@ } | ||
} | ||
interface MemoryDeleteOptions { | ||
name: string; | ||
} | ||
interface MemoryRetrieveOptions { | ||
query: string; | ||
memory: { | ||
name: string; | ||
}[]; | ||
topK?: number; | ||
} | ||
interface MemoryListDocOptions { | ||
memoryName: string; | ||
} | ||
interface MemoryDeleteDocOptions { | ||
memoryName: string; | ||
documentName: string; | ||
} | ||
interface MemoryUploadDocOptions { | ||
memoryName: string; | ||
fileName: string; | ||
meta?: Record<string, string>; | ||
file: Buffer | File | FormData | ReadableStream; | ||
contentType: 'application/pdf' | 'text/plain' | 'text/markdown' | 'text/csv'; | ||
} | ||
interface MemoryRetryDocEmbedOptions { | ||
memoryName: string; | ||
documentName: string; | ||
} | ||
interface MemoryCreateResponse extends MemoryBaseResponse { | ||
@@ -254,9 +299,107 @@ } | ||
} | ||
interface BaseDeleteResponse { | ||
success: boolean; | ||
} | ||
interface MemoryDeleteResponse extends BaseDeleteResponse { | ||
} | ||
interface MemoryDeleteDocResponse extends BaseDeleteResponse { | ||
} | ||
interface MemoryRetryDocEmbedResponse extends BaseDeleteResponse { | ||
} | ||
interface MemoryRetrieveResponse { | ||
text: string; | ||
similarity: number; | ||
meta: Record<string, string>; | ||
} | ||
interface MemoryListDocResponse { | ||
name: string; | ||
status: 'queued' | 'in_progress' | 'completed' | 'failed'; | ||
status_message: string | null; | ||
metadata: { | ||
size: number; | ||
type: 'application/pdf' | 'text/plain' | 'text/markdown' | 'text/csv' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.ms-excel'; | ||
}; | ||
enabled: boolean; | ||
chunk_size: number; | ||
chunk_overlap: number; | ||
owner_login: string; | ||
} | ||
declare class Memory { | ||
private request; | ||
private apiKey; | ||
constructor(options: MemoryOptions); | ||
/** | ||
* Creates a new memory on Langbase. | ||
* | ||
* @param {MemoryCreateOptions} options - The options to create the memory instance. | ||
* @param {string} options.name - The name of the memory. | ||
* @param {string} options.description - The description of the memory. | ||
* @returns {Promise<MemoryCreateResponse>} A promise that resolves to the response of the memory creation. | ||
*/ | ||
create(options: MemoryCreateOptions): Promise<MemoryCreateResponse>; | ||
/** | ||
* Retrieves a list of all memories on Langbase. | ||
* | ||
* @returns {Promise<MemoryListResponse[]>} A promise that resolves to an array of memory list responses. | ||
*/ | ||
list(): Promise<MemoryListResponse[]>; | ||
/** | ||
* Deletes a memory on Langbase. | ||
* | ||
* @param {MemoryDeleteOptions} options - The options for deleting the memory resource. | ||
* @param {string} options.name - The name of the memory to delete. | ||
* @returns {Promise<MemoryDeleteResponse>} A promise that resolves to the response of the delete operation. | ||
*/ | ||
delete(options: MemoryDeleteOptions): Promise<MemoryDeleteResponse>; | ||
/** | ||
* Retrieves similar text from the memory. | ||
* | ||
* @param {MemoryRetrieveOptions} options - The options to use for retrieving memory data. | ||
* @param {string} options.query - The query text to search for. | ||
* @param {object[]} options.memory - The memory to search in. | ||
* @param {number} [options.topK] - The number of similar texts to retrieve. | ||
* @returns A promise that resolves to an array of `MemoryRetrieveResponse` objects. | ||
*/ | ||
retrieve(options: MemoryRetrieveOptions): Promise<MemoryRetrieveResponse[]>; | ||
/** | ||
* Retrieves a list of documents inside a memory. | ||
* | ||
* @param {MemoryListDocOptions} options - The options for listing documents, including the memory name. | ||
* @param {string} options.memoryName - The name of the memory to list documents from. | ||
* @returns A promise that resolves to an array of `MemoryListDocResponse` objects. | ||
*/ | ||
listDocs(options: MemoryListDocOptions): Promise<MemoryListDocResponse[]>; | ||
/** | ||
* Deletes a document from a memory. | ||
* | ||
* @param {MemoryDeleteDocOptions} options - The options for deleting the document. | ||
* @param {string} options.memoryName - The name of the memory to delete the document from. | ||
* @param {string} options.documentName - The name of the document to delete. | ||
* @returns A promise that resolves to a `MemoryDeleteDocResponse` indicating the result of the delete operation. | ||
*/ | ||
deleteDoc(options: MemoryDeleteDocOptions): Promise<MemoryDeleteDocResponse>; | ||
/** | ||
* Uploads a document to the memory. | ||
* | ||
* @param {MemoryUploadDocOptions} options - The options for uploading the document. | ||
* @param {string} options.memoryName - The name of the memory to upload the document to. | ||
* @param {string} options.fileName - The name of the file being uploaded. | ||
* @param {object} [options.meta] - Optional metadata associated with the document. | ||
* @param {string} options.contentType - The MIME type of the file being uploaded. | ||
* @param {Blob | Buffer} options.file - The file content to be uploaded. | ||
* @returns {Promise<Response>} The response from the upload request. | ||
* @throws Will throw an error if the upload fails. | ||
*/ | ||
uploadDoc(options: MemoryUploadDocOptions): Promise<Response>; | ||
/** | ||
* Retries the embedding process for a specific document in memory. | ||
* | ||
* @param options - The options required to retry the document embedding. | ||
* @param options.memoryName - The name of the memory containing the document. | ||
* @param options.documentName - The name of the document to retry embedding for. | ||
* @returns A promise that resolves to the response of the retry operation. | ||
*/ | ||
retryDocEmbed(options: MemoryRetryDocEmbedOptions): Promise<MemoryRetryDocEmbedResponse>; | ||
} | ||
export { type Function, type GenerateOptions, type GenerateResponse, Memory, type MemoryCreateOptions, type MemoryCreateResponse, type MemoryListResponse, type MemoryOptions, type Message, Pipe, type PipeCreateOptions, type PipeCreateResponse, type PipeListResponse, type PipeOptions, type PipeUpdateOptions, type PipeUpdateResponse, type Role, type StreamChunk, type StreamOptions, type StreamResponse, type StreamText, type ToolCall, type Usage, type Variable, fromReadableStream, printStreamToStdout }; | ||
export { type BaseDeleteResponse, type Function, type GenerateOptions, type GenerateResponse, Memory, type MemoryCreateOptions, type MemoryCreateResponse, type MemoryDeleteDocOptions, type MemoryDeleteDocResponse, type MemoryDeleteOptions, type MemoryDeleteResponse, type MemoryListDocOptions, type MemoryListDocResponse, type MemoryListResponse, type MemoryOptions, type MemoryRetrieveOptions, type MemoryRetrieveResponse, type MemoryRetryDocEmbedOptions, type MemoryRetryDocEmbedResponse, type MemoryUploadDocOptions, type Message, Pipe, type PipeCreateOptions, type PipeCreateResponse, type PipeListResponse, type PipeOptions, type PipeUpdateOptions, type PipeUpdateResponse, type Role, type StreamChunk, type StreamOptions, type StreamResponse, type StreamText, type ToolCall, type Usage, type Variable, fromReadableStream, printStreamToStdout }; |
@@ -719,2 +719,8 @@ "use strict"; | ||
} | ||
/** | ||
* Creates a new pipe on Langbase. | ||
* | ||
* @param {PipeCreateOptions} options - The options for creating the pipe. | ||
* @returns {Promise<PipeCreateResponse>} A promise that resolves to the response of the pipe creation. | ||
*/ | ||
async create(options) { | ||
@@ -726,2 +732,8 @@ return this.request.post({ | ||
} | ||
/** | ||
* Updates a pipe on Langbase. | ||
* | ||
* @param {PipeUpdateOptions} options - The options for updating the pipe. | ||
* @returns {Promise<PipeUpdateResponse>} A promise that resolves to the response of the update operation. | ||
*/ | ||
async update(options) { | ||
@@ -733,2 +745,7 @@ return this.request.post({ | ||
} | ||
/** | ||
* Retrieves a list of pipes. | ||
* | ||
* @returns {Promise<PipeListResponse[]>} A promise that resolves to an array of PipeListResponse objects. | ||
*/ | ||
async list() { | ||
@@ -752,4 +769,13 @@ return this.request.get({ | ||
const baseUrl = "https://api.langbase.com"; | ||
this.apiKey = options.apiKey; | ||
this.request = new Request({ apiKey: options.apiKey, baseUrl }); | ||
} | ||
/** | ||
* Creates a new memory on Langbase. | ||
* | ||
* @param {MemoryCreateOptions} options - The options to create the memory instance. | ||
* @param {string} options.name - The name of the memory. | ||
* @param {string} options.description - The description of the memory. | ||
* @returns {Promise<MemoryCreateResponse>} A promise that resolves to the response of the memory creation. | ||
*/ | ||
async create(options) { | ||
@@ -761,2 +787,7 @@ return this.request.post({ | ||
} | ||
/** | ||
* Retrieves a list of all memories on Langbase. | ||
* | ||
* @returns {Promise<MemoryListResponse[]>} A promise that resolves to an array of memory list responses. | ||
*/ | ||
async list() { | ||
@@ -767,2 +798,102 @@ return this.request.get({ | ||
} | ||
/** | ||
* Deletes a memory on Langbase. | ||
* | ||
* @param {MemoryDeleteOptions} options - The options for deleting the memory resource. | ||
* @param {string} options.name - The name of the memory to delete. | ||
* @returns {Promise<MemoryDeleteResponse>} A promise that resolves to the response of the delete operation. | ||
*/ | ||
async delete(options) { | ||
return this.request.delete({ | ||
endpoint: `/v1/memory/${options.name}` | ||
}); | ||
} | ||
/** | ||
* Retrieves similar text from the memory. | ||
* | ||
* @param {MemoryRetrieveOptions} options - The options to use for retrieving memory data. | ||
* @param {string} options.query - The query text to search for. | ||
* @param {object[]} options.memory - The memory to search in. | ||
* @param {number} [options.topK] - The number of similar texts to retrieve. | ||
* @returns A promise that resolves to an array of `MemoryRetrieveResponse` objects. | ||
*/ | ||
async retrieve(options) { | ||
return this.request.post({ | ||
endpoint: "/v1/memory/retrieve", | ||
body: options | ||
}); | ||
} | ||
/** | ||
* Retrieves a list of documents inside a memory. | ||
* | ||
* @param {MemoryListDocOptions} options - The options for listing documents, including the memory name. | ||
* @param {string} options.memoryName - The name of the memory to list documents from. | ||
* @returns A promise that resolves to an array of `MemoryListDocResponse` objects. | ||
*/ | ||
async listDocs(options) { | ||
return this.request.get({ | ||
endpoint: `/v1/memory/${options.memoryName}/documents` | ||
}); | ||
} | ||
/** | ||
* Deletes a document from a memory. | ||
* | ||
* @param {MemoryDeleteDocOptions} options - The options for deleting the document. | ||
* @param {string} options.memoryName - The name of the memory to delete the document from. | ||
* @param {string} options.documentName - The name of the document to delete. | ||
* @returns A promise that resolves to a `MemoryDeleteDocResponse` indicating the result of the delete operation. | ||
*/ | ||
async deleteDoc(options) { | ||
return this.request.delete({ | ||
endpoint: `/v1/memory/${options.memoryName}/documents/${options.documentName}` | ||
}); | ||
} | ||
/** | ||
* Uploads a document to the memory. | ||
* | ||
* @param {MemoryUploadDocOptions} options - The options for uploading the document. | ||
* @param {string} options.memoryName - The name of the memory to upload the document to. | ||
* @param {string} options.fileName - The name of the file being uploaded. | ||
* @param {object} [options.meta] - Optional metadata associated with the document. | ||
* @param {string} options.contentType - The MIME type of the file being uploaded. | ||
* @param {Blob | Buffer} options.file - The file content to be uploaded. | ||
* @returns {Promise<Response>} The response from the upload request. | ||
* @throws Will throw an error if the upload fails. | ||
*/ | ||
async uploadDoc(options) { | ||
try { | ||
const response = await this.request.post({ | ||
endpoint: `/v1/memory/documents`, | ||
body: { | ||
memoryName: options.memoryName, | ||
fileName: options.fileName, | ||
meta: options.meta | ||
} | ||
}); | ||
const uploadUrl = response.signedUrl; | ||
return await fetch(uploadUrl, { | ||
method: "PUT", | ||
headers: { | ||
Authorization: `Bearer ${this.apiKey}`, | ||
"Content-Type": options.contentType | ||
}, | ||
body: options.file | ||
}); | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
/** | ||
* Retries the embedding process for a specific document in memory. | ||
* | ||
* @param options - The options required to retry the document embedding. | ||
* @param options.memoryName - The name of the memory containing the document. | ||
* @param options.documentName - The name of the document to retry embedding for. | ||
* @returns A promise that resolves to the response of the retry operation. | ||
*/ | ||
async retryDocEmbed(options) { | ||
return this.request.get({ | ||
endpoint: `/v1/memory/${options.memoryName}/documents/${options.documentName}/embeddings/retry` | ||
}); | ||
} | ||
}; | ||
@@ -769,0 +900,0 @@ |
{ | ||
"name": "langbase", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"license": "Apache-2.0", | ||
@@ -29,4 +29,4 @@ "sideEffects": false, | ||
"vitest": "1.6.0", | ||
"@langbase/tsconfig": "1.0.0", | ||
"@langbase/eslint-config": "1.0.0" | ||
"@langbase/eslint-config": "1.0.0", | ||
"@langbase/tsconfig": "1.0.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195990
2164
4