Skip to content

Commit

Permalink
v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem-K-Koltunov committed May 23, 2024
1 parent baae6a1 commit a6f0cbe
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 31 deletions.
12 changes: 6 additions & 6 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quickblox-react-ui-kit",
"version": "0.4.0-beta.1",
"version": "0.4.0",
"main": "dist/index-ui.js",
"license": "MIT",
"dependencies": {
Expand All @@ -12,7 +12,7 @@
"qb-ai-core": "^0.1.3",
"qb-ai-rephrase": "^0.1.2",
"qb-ai-translate": "^0.1.2",
"quickblox": "^2.17.0-beta.1",
"quickblox": "^2.17.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.1",
Expand Down
2 changes: 1 addition & 1 deletion src/Data/DefaultConfigurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class DefaultConfigurations {
organizationName: 'Quickblox',
openAIModel: 'gpt-3.5-turbo',
smartChatAssistantId: '',
apiKey: '6633a1300fea600001bd6e71',
apiKey: '',
maxTokens: 3584,
useDefault: true,
defaultTone: 'Professional',
Expand Down
6 changes: 1 addition & 5 deletions src/Data/source/remote/IRemoteDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { ChatMessage } from 'qb-ai-core';
import { AIAnswerAssistantSettings } from 'qb-ai-answer-assistant';
import { AITranslateSettings } from 'qb-ai-translate';
import {AIChatHistory, AIChatMessage} from 'quickblox';
import { AIChatHistory, AIAnswerResponse } from 'quickblox';
import { RemoteDialogDTO } from '../../dto/dialog/RemoteDialogDTO';
import { RemoteDialogsDTO } from '../../dto/dialog/RemoteDialogsDTO';
import { RemoteUserDTO } from '../../dto/user/RemoteUserDTO';
Expand All @@ -12,7 +9,6 @@ import { RemoteFileDTO } from '../../dto/file/RemoteFileDTO';
import { Pagination } from '../../../Domain/repository/Pagination';
import { CallBackFunction } from '../../../Domain/use_cases/base/IUseCase';
import { NotificationTypes } from '../../../Domain/entity/NotificationTypes';
import {AIAnswerResponse} from "../../../qb-api-calls";
// todo list of all actions - for what we need to create tests
/*
0!!! не реализованы эксепшены для createDialog RemouteDataSource и
Expand Down
2 changes: 1 addition & 1 deletion src/Data/source/remote/RemoteDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import QB, {
QBUser,
QBMessageStatusParams,
AIChatHistory,
AIAnswerResponse,
} from 'quickblox/quickblox';
import { RemoteDialogDTO } from '../../dto/dialog/RemoteDialogDTO';
import {
Expand All @@ -35,7 +36,6 @@ import { DialogDTOMapper } from './Mapper/DialogDTOMapper';
import { IDTOMapper } from './Mapper/IDTOMapper';
import { Stubs } from '../../Stubs';
import {
AIAnswerResponse,
QBAnswerAssist,
QBChatConnect,
QBChatDisconnect,
Expand Down
14 changes: 6 additions & 8 deletions src/Domain/use_cases/ai/AIAnswerAssistWithSDKUseCase.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// eslint-disable-next-line import/extensions
import { AIChatMessage, AIRole } from 'quickblox';
import { AIAnswerResponse, AIChatMessage, AIRole } from 'quickblox';
import { IChatMessage } from '../../../Data/source/AISource';
import { IUseCase } from '../base/IUseCase';
import { IRemoteDataSource } from '../../../Data/source/remote/IRemoteDataSource';
import { AIAnswerResponse } from '../../../qb-api-calls';

interface AIChatMessageEx extends AIChatMessage {
content: string;
}
// interface AIChatMessageEx extends AIChatMessage {
// content: string;
// } // artik 19.05.2024
export class AIAnswerAssistWithSDKUseCase implements IUseCase<void, string> {
private textToSend: string;

Expand All @@ -32,13 +31,12 @@ export class AIAnswerAssistWithSDKUseCase implements IUseCase<void, string> {

async execute(): Promise<string> {
console.log('execute AIAnswerAssistWithSDKUseCase');
const history: AIChatMessageEx[] = this.dialogMessages.map(
const history: AIChatMessage[] = this.dialogMessages.map(
(msg: IChatMessage) => {
return {
role: msg.role as AIRole,
message: msg.content,
content: msg.content,
} as AIChatMessageEx;
} as AIChatMessage;
},
);
const response: AIAnswerResponse = await this.dataSource.createAnswer(
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/use_cases/ai/AITranslateWithSDKUseCase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line import/extensions
import { AIAnswerResponse } from 'quickblox/quickblox';
import { IUseCase } from '../base/IUseCase';
import { IRemoteDataSource } from '../../../Data/source/remote/IRemoteDataSource';
import { AIAnswerResponse } from '../../../qb-api-calls';

export class AITranslateWithSDKUseCase implements IUseCase<void, string> {
private languageCodes: { [key: string]: string } = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ export default function UseDefaultAIAssistAnswerWidgetWithSDK(
);

// eslint-disable-next-line no-return-await
return await useCaseAIAnswerAssist.execute().then((data) => {
setTextFromWidgetToContent(data);
return await useCaseAIAnswerAssist
.execute()
.then((data) => {
setTextFromWidgetToContent(data);

return data;
});
return data;
})
.catch((reason) => {
console.log('SDK: ai answer assist error: ', reason);
setTextFromWidgetToContent(JSON.stringify(reason));

return reason;
});
}

return '';
Expand Down
7 changes: 4 additions & 3 deletions src/qb-api-calls/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import QB, {
AIAnswerResponse,
AIChatHistory,
ChatConnectParams,
GetMessagesResult,
Expand Down Expand Up @@ -620,9 +621,9 @@ export function QBWebRTCSessionGetUserMedia(
});
});
}
export interface AIAnswerResponse {
answer: string;
}
// export interface AIAnswerResponse {
// answer: string;
// } // artim 19.05.2024

export function QBAnswerAssist(
smartChatAssistantId: string,
Expand Down

0 comments on commit a6f0cbe

Please sign in to comment.