Skip to content

Commit

Permalink
2.0.1 - OpenAI Assistant history message order fix and Vite security …
Browse files Browse the repository at this point in the history
…fixes
  • Loading branch information
OvidijusParsiunas committed Jul 29, 2024
1 parent ba378e5 commit d07a477
Show file tree
Hide file tree
Showing 18 changed files with 8,627 additions and 7,982 deletions.
9,522 changes: 4,928 additions & 4,594 deletions component/custom-elements.json

Large diffs are not rendered by default.

2,793 changes: 1,502 additions & 1,291 deletions component/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deep-chat",
"version": "2.0.0",
"version": "2.0.1",
"description": "Customizable chat component for AI APIs",
"main": "./dist/deepChat.js",
"module": "./dist/deepChat.js",
Expand Down Expand Up @@ -61,7 +61,7 @@
"rollup-plugin-terser": "^7.0.2",
"typescript": "~5.3.3",
"vite": "^5.1.5",
"vite-plugin-dts": "^3.7.3"
"vite-plugin-dts": "^2.3.0"
},
"customElements": "custom-elements.json",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions component/src/services/openAI/openAIAssistantIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class OpenAIAssistantIO extends DirectServiceIO {
try {
const threadMessages = await this.getThreadMessages(this.sessionId as string, true);
this.deepChat.disableSubmitButton(false);
return threadMessages.reverse();
return threadMessages;
} catch (e) {
return [{error: 'failed to fetch thread history'}];
}
Expand Down Expand Up @@ -256,7 +256,7 @@ export class OpenAIAssistantIO extends DirectServiceIO {

private async getThreadMessages(thread_id: string, isHistory = false) {
// https://platform.openai.com/docs/api-reference/messages/listMessages
this.url = `${OpenAIAssistantIO.THREAD_PREFIX}/${thread_id}/messages`;
this.url = `${OpenAIAssistantIO.THREAD_PREFIX}/${thread_id}/messages?order=desc`;
let threadMessages = (await OpenAIUtils.directFetch(this, {}, 'GET')) as OpenAIAssistantMessagesResult;
if (!isHistory && this.deepChat.responseInterceptor) {
threadMessages = (await this.deepChat.responseInterceptor?.(threadMessages)) as OpenAIAssistantMessagesResult;
Expand Down
5 changes: 3 additions & 2 deletions component/src/views/chat/messages/messagesHistory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {HistoryMessage, LoadHistory} from '../../../types/history';
import {ElementUtils} from '../../../utils/element/elementUtils';
import {MessageContentI} from '../../../types/messagesInternal';
import {MessageContent} from '../../../types/messages';
import {ServiceIO} from '../../../services/serviceIO';
import {Legacy} from '../../../utils/legacy/legacy';
Expand All @@ -22,7 +23,7 @@ export class MessagesHistory {
const messages = await loadHistory(0);
this._isComplete = !messages.find((message) => !message);
const messageContent = messages.filter((message) => !!message);
this.populateHistory(deepChat, messageContent);
this.populateHistory(deepChat, messageContent as MessageContent[]);
}

private processLoadedHistory(historyMessages: HistoryMessage[]) {
Expand All @@ -42,7 +43,7 @@ export class MessagesHistory {
})
.filter((message) => !!message)
.reverse()
.forEach((messageContent) => this._messages.sendClientUpdate(messageContent, true));
.forEach((message) => this._messages.sendClientUpdate(message as MessageContentI, true));
if (firstMessageEl) this._messages.elementRef.scrollTop = currentScrollTop + firstMessageEl.offsetTop;
this._isLoading = false;
}
Expand Down
16 changes: 8 additions & 8 deletions example-servers/nextjs/app-router/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example-servers/nextjs/app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "next lint"
},
"dependencies": {
"deep-chat-react": "^2.0.0",
"deep-chat-react": "^2.0.1",
"eventsource-parser": "^1.1.2",
"next": "14.1.4",
"react": "^18",
Expand Down
16 changes: 8 additions & 8 deletions example-servers/nextjs/pages-router/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example-servers/nextjs/pages-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": {
"axios": "^1.6.7",
"deep-chat-react": "^2.0.0",
"deep-chat-react": "^2.0.1",
"eventsource-parser": "^1.1.2",
"next": "14.1.3",
"react": "^18.2.0",
Expand Down
8 changes: 4 additions & 4 deletions example-servers/sveltekit/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example-servers/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"type": "module",
"dependencies": {
"deep-chat": "^2.0.0",
"deep-chat": "^2.0.1",
"eventsource-parser": "^1.1.2"
}
}
16 changes: 8 additions & 8 deletions example-servers/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example-servers/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@types/node": "^20.11.26",
"@types/react": "^18.2.65",
"@types/react-dom": "^18.2.21",
"deep-chat-react": "^2.0.0",
"deep-chat-react": "^2.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
Expand Down
12 changes: 6 additions & 6 deletions other-packages/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions other-packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deep-chat-react",
"version": "2.0.0",
"version": "2.0.1",
"description": "Customizable chat component for AI APIs",
"main": "./dist/deepChat.js",
"module": "./dist/deepChat.js",
Expand Down Expand Up @@ -32,7 +32,7 @@
"license": "MIT",
"dependencies": {
"@lit-labs/react": "^2.1.3",
"deep-chat": "2.0.0"
"deep-chat": "2.0.1"
},
"devDependencies": {
"@types/react": "^18.2.64",
Expand Down
2 changes: 1 addition & 1 deletion website/docs/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ npm install deep-chat-react
Access the component via CDN:

```
https://unpkg.com/deep-chat@2.0.0/dist/deepChat.bundle.js
https://unpkg.com/deep-chat@2.0.1/dist/deepChat.bundle.js
```
Loading

0 comments on commit d07a477

Please sign in to comment.