Skip to content

Commit b0d1e25

Browse files
committed
Implemented Chat Completion storage management methods.
1 parent 7a8a924 commit b0d1e25

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

lib.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,49 @@ let OpenaiApi = (function () {
250250
}
251251
}
252252

253+
async getChatCompletion(parameters) {
254+
const openai = new OpenAI(this.clientParams);
255+
const { completion_id, ...options } = parameters.payload;
256+
257+
const response = await openai.chat.completions.retrieve(completion_id, options);
258+
259+
return response;
260+
}
261+
262+
async getChatMessages(parameters) {
263+
const openai = new OpenAI(this.clientParams);
264+
const { completion_id, ...options } = parameters.payload;
265+
266+
const response = await openai.chat.completions.messages.list(completion_id, options);
267+
268+
return response.data;
269+
}
270+
271+
async listChatCompletions(parameters) {
272+
const openai = new OpenAI(this.clientParams);
273+
const response = await openai.chat.completions.list(parameters.payload);
274+
275+
return response.data;
276+
}
277+
278+
async updateChatCompletion(parameters) {
279+
const openai = new OpenAI(this.clientParams);
280+
const { completion_id, ...body } = parameters.payload;
281+
282+
const response = await openai.chat.completions.update(completion_id, body);
283+
284+
return response;
285+
}
286+
287+
async deleteChatCompletion(parameters) {
288+
const openai = new OpenAI(this.clientParams);
289+
const { completion_id, ...options } = parameters.payload;
290+
291+
const response = await openai.chat.completions.del(completion_id, options);
292+
293+
return response;
294+
}
295+
253296
async createImage(parameters) {
254297
const openai = new OpenAI(this.clientParams);
255298
const response = await openai.images.generate(parameters.payload);

node.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,17 @@ <h4>msg.payload Properties</h4>
17381738
</dt>
17391739
<dd>The model used to generate the chat completions.</dd>
17401740

1741+
<dt class="optional">
1742+
metadata
1743+
<a
1744+
href="https://platform.openai.com/docs/api-reference/chat/list#chat-list-metadata"
1745+
target="_blank"
1746+
><i class="fa fa-external-link fa-sm" aria-hidden="true"></i
1747+
></a>
1748+
<span class="property-type">object</span>
1749+
</dt>
1750+
<dd>A list of metadata keys to filter the chat completions by.</dd>
1751+
17411752
<dt class="optional">
17421753
after
17431754
<a

0 commit comments

Comments
 (0)