trieve-ts-sdk
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -10,3 +10,5 @@ declare const _default: { | ||
editMessage(this: import("..").TrieveSDK, data: import("..").EditMessageReqPayload, signal?: AbortSignal): Promise<unknown>; | ||
editMessageReader(this: import("..").TrieveSDK, data: import("..").EditMessageReqPayload, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>; | ||
regenerateMessage(this: import("..").TrieveSDK, data: import("..").RegenerateMessageReqPayload, signal?: AbortSignal): Promise<string>; | ||
regenerateMessageReader(this: import("..").TrieveSDK, data: import("..").RegenerateMessageReqPayload, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>; | ||
getAllMessagesForTopic(this: import("..").TrieveSDK, data: Omit<import("..").GetAllTopicMessagesData, "trDataset">, signal?: AbortSignal): Promise<import("..").Message[]>; | ||
@@ -13,0 +15,0 @@ createTopic(this: import("..").TrieveSDK, data: import("..").CreateTopicReqPayload, signal?: AbortSignal): Promise<import("..").Topic>; |
@@ -52,2 +52,17 @@ /** | ||
/** | ||
* Edit message which exists within the topic’s chat history as a stream and returns a reader. This will delete the message and replace it with a new message. The new message will be generated by the AI based on the new content provided in the request body. The response will include Chunks first on the stream if the topic is using RAG. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization. | ||
* | ||
* Example: | ||
* ```js | ||
*const reader = await trieve.editMessageReader({ | ||
topic_id: "3c90c3cc-1d76-27198-8888-8dd25736052a", | ||
new_message_content: "a new message", | ||
message_sort_order: 1 | ||
}); | ||
* ``` | ||
*/ | ||
export declare function editMessageReader( | ||
/** @hidden */ | ||
this: TrieveSDK, data: EditMessageReqPayload, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>; | ||
/** | ||
* Regenerate the assistant response to the last user message of a topic. This will delete the last message and replace it with a new message. The response will include Chunks first on the stream if the topic is using RAG. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization. | ||
@@ -66,2 +81,15 @@ * | ||
/** | ||
* Regenerate the assistant response to the last user message of a topic as a stream and returns a reader. This will delete the last message and replace it with a new message. The response will include Chunks first on the stream if the topic is using RAG. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information. Auth’ed user or api key must have an admin or owner role for the specified dataset’s organization. | ||
* | ||
* Example: | ||
* ```js | ||
*const reader = await trieve.regenerateMessageReader({ | ||
topic_id: "3c90c3cc-1d76-27198-8888-8dd25736052a", | ||
}); | ||
* ``` | ||
*/ | ||
export declare function regenerateMessageReader( | ||
/** @hidden */ | ||
this: TrieveSDK, data: RegenerateMessageReqPayload, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>; | ||
/** | ||
* Get all messages for a given topic. If the topic is a RAG topic then the response will include Chunks first on each message. The structure will look like [chunks]||mesage. See docs.trieve.ai for more information. | ||
@@ -68,0 +96,0 @@ * |
@@ -634,4 +634,6 @@ var __defProp = Object.defineProperty; | ||
editMessage: () => editMessage, | ||
editMessageReader: () => editMessageReader, | ||
getAllMessagesForTopic: () => getAllMessagesForTopic, | ||
regenerateMessage: () => regenerateMessage | ||
regenerateMessage: () => regenerateMessage, | ||
regenerateMessageReader: () => regenerateMessageReader | ||
}); | ||
@@ -677,2 +679,19 @@ async function createMessage(data, signal) { | ||
} | ||
async function editMessageReader(data, signal) { | ||
const response = await fetch(this.trieve.baseUrl + "/api/message", { | ||
method: "put", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"TR-Dataset": this.datasetId, | ||
Authorization: `Bearer ${this.trieve.apiKey}` | ||
}, | ||
body: JSON.stringify(data), | ||
signal | ||
}); | ||
const reader = response.body?.getReader(); | ||
if (!reader) { | ||
throw new Error("Failed to get reader from response body"); | ||
} | ||
return reader; | ||
} | ||
async function regenerateMessage(data, signal) { | ||
@@ -689,2 +708,19 @@ return await this.trieve.fetch( | ||
} | ||
async function regenerateMessageReader(data, signal) { | ||
const response = await fetch(this.trieve.baseUrl + "/api/message", { | ||
method: "delete", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"TR-Dataset": this.datasetId, | ||
Authorization: `Bearer ${this.trieve.apiKey}` | ||
}, | ||
body: JSON.stringify(data), | ||
signal | ||
}); | ||
const reader = response.body?.getReader(); | ||
if (!reader) { | ||
throw new Error("Failed to get reader from response body"); | ||
} | ||
return reader; | ||
} | ||
async function getAllMessagesForTopic(data, signal) { | ||
@@ -691,0 +727,0 @@ return await this.trieve.fetch( |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"license": "MIT", | ||
@@ -12,0 +12,0 @@ "scripts": { |
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 too big to display
Sorry, the diff of this file is not supported yet
397877
6592
4