Skip to content

Commit

Permalink
Merge branch 'master-pre' into features/ds-bugs-PRE
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Panico committed Nov 6, 2024
2 parents b5ecb88 + 65bc384 commit 26d337a
Show file tree
Hide file tree
Showing 63 changed files with 416 additions and 158 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,37 @@
### **Copyrigth**:
*Tiledesk SRL*

# 1.22.0-rc.4
- **added**: uploaded control in audio base element

# 1.22.0-rc.3
- **bug-fixed**: minor fix action gpt-task on preview

# 1.22.0-rc.2
- **added**: fileUploadAccept env variable
- **added**: uploaded control after file is loaded

# 1.22.0-rc.1
- **added**: role guard to main root

# 1.21.0

# 1.21.0-rc.16
- **added**: doc for new actions

# 1.21.0-rc.15
- **added**: image preload resolve for doc images
- **changed**: info-tooltip doc component UI

# 1.21.0-rc.14
- **added**: changed: min value for max_tokens if citations checkbox is enabled

# 1.21.0-rc.13
- **added**: 'connect_block', 'move_to_unassigned' and 'clear_transcript' actions
- **added**: chatbot_id system-defined variable
- **added**: enable 'connect_block' action only if present in project.profile


# 1.21.0-rc.12
- **added**: formatType checkbox in action gpt-task
- **added**: citations in action askkbv2
Expand Down
4 changes: 2 additions & 2 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tiledesk/cds",
"author": "Tiledesk SRL",
"version": "1.21.0-rc.13",
"version": "1.22.0-rc.4",
"license": "MIT",
"homepage": "https://www.tiledesk.com",
"repository": {
Expand Down
3 changes: 2 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const routes: Routes = [

{ path: 'project/:projectid/chatbot/:faqkbid',
loadChildren: () => import('./chatbot-design-studio/cds-dashboard/cds-dashboard.module').then( m => m.CdsDashboardModule),
canActivate:[AuthGuard, RoleGuard]
canActivate:[AuthGuard, RoleGuard],
data: [ { roles: ['owner', 'admin']}]
},

// Wildcard route for a 404 page
Expand Down
9 changes: 9 additions & 0 deletions src/app/chatbot-design-studio/BrandResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ export class BrandResources {
var icon = document.querySelector("link[rel~='icon']") as HTMLElement;
icon.setAttribute('href', this.brand['FAVICON_URL'])

/** META sharing ELEMENTS */
if(this.brand['META_SHARE_INFO'] && this.brand['META_SHARE_INFO'].length > 0){
Object.keys(this.brand['META_SHARE_INFO']).forEach(key => {
var meta = document.querySelector("meta[property^='og:"+key.toLowerCase()+"']") as HTMLElement;
meta.setAttribute('content', this.brand['META_SHARE_INFO'][key])
})
}


/** CSS */
document.documentElement.style.setProperty('--base-brand-color', this.brand['BRAND_PRIMARY_COLOR']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ <h3 class="card_title__underlined">
<div class="col-sm-10">
<!-- [ngStyle]="{'margin-left':botType === 'dialogflow' ? '35px' : 0 }" -->
<div class="card-avatar" style="display: flex;align-items: center;">
<div class="bot_avatar">
<img class="bot-profile-img" [src]="selectedChatbot?.imageURL" onerror="this.src='assets/images/avatar_bot_tiledesk.svg'"/>
<div class="bot_avatar">
<img class="bot-profile-img" [src]="imageURL" onerror="this.src='assets/images/avatar_bot_tiledesk.svg'"/>
<!-- <img class="bot-profile-img" [src]="selectedChatbot?.imageURL"/> -->
</div>

Expand All @@ -40,8 +40,7 @@ <h3 class="card_title__underlined">
<i class="fa fa-spinner fa-spin"></i>
</span>
</label>
<input #fileInputBotProfileImage (change)="upload($event)" id="file-upload" type="file"
accept=".jpg, .JPEG, .png" />
<input #fileInputBotProfileImage (change)="upload($event)" id="file-upload" type="file" [accept]="fileUploadAccept" />

<button id="cds-delete-bot-img-btn" class="btn btn-primary cds-blue-button"
(click)="deleteBotProfileImage()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk
import { UserModel } from 'src/chat21-core/models/user';
import { UploadModel } from 'src/chat21-core/models/upload';
import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service';
import { checkAcceptedFile, filterImageMimeTypesAndExtensions } from '../../utils';
const swal = require('sweetalert');

@Component({
Expand All @@ -37,6 +38,7 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On

selectedFiles: FileList;
isFilePendingToUpload = false;
fileUploadAccept: string;
// botProfileImageurl: string;
// timeStamp: any;

Expand Down Expand Up @@ -67,6 +69,7 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
selected_dept_name: string;

user: UserModel
imageURL: string;

private logger: LoggerService = LoggerInstance.getInstance()
constructor(
Expand All @@ -82,7 +85,8 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On

ngOnInit(): void {
this.getDeptsByProjectId();
this.user = this.tiledeskAuthService.getCurrentUser()
this.user = this.tiledeskAuthService.getCurrentUser();
this.fileUploadAccept = filterImageMimeTypesAndExtensions(this.appConfigService.getConfig().fileUploadAccept).join(',');
// this.checkBotImageUploadIsComplete();
}

Expand Down Expand Up @@ -253,7 +257,7 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
if (this.selectedChatbot._id) {
let url = this.imageRepoService.getImagePhotoUrl(this.selectedChatbot._id)
this.checkImageExists(url, (existImage)=> {
existImage? this.selectedChatbot.imageURL = url: null;
existImage? this.selectedChatbot.imageURL = url: null;
})
}

Expand Down Expand Up @@ -385,7 +389,7 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
// this.timeStamp = new Date().getTime();
// }

// getBotProfileImage(): SafeUrl {
// getBotProfileImage(): SafeUrl {
// if (this.timeStamp) {
// return this.sanitizer.bypassSecurityTrustUrl(this.botProfileImageurl + '&' + this.timeStamp);
// }
Expand Down Expand Up @@ -417,6 +421,14 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On

const that = this;
if (event.target.files && event.target.files[0]) {

const canUploadFile = checkAcceptedFile(event.target.files[0].type, this.fileUploadAccept)
if(!canUploadFile){
this.logger.error('[IMAGE-UPLOAD] detectFiles: can not upload current file type--> NOT ALLOWED', this.fileUploadAccept)
this.isFilePendingToUpload = false;
return;
}

const nameFile = event.target.files[0].name;
const typeFile = event.target.files[0].type;
const reader = new FileReader();
Expand Down Expand Up @@ -458,13 +470,15 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
that.logger.debug('[IMAGE-UPLOAD] AppComponent::uploadSingle::', file);
// const file = this.selectedFiles.item(0);
const currentUpload = new UploadModel(file);

this.imageURL = null;
this.uploadService.uploadProfile(this.selectedChatbot._id, currentUpload).then(downloadURL => {
that.logger.debug(`[IMAGE-UPLOAD] Successfully uploaded file and got download link - ${downloadURL}`);

let url = this.imageRepoService.getImagePhotoUrl(this.selectedChatbot._id)
this.checkImageExists(url, (existImage)=> {
existImage? this.selectedChatbot.imageURL = url: null;
let timestamp = new Date().getTime();
existImage? this.imageURL = url + '&' + timestamp : null;
this.selectedChatbot.imageURL = url;
})
that.isFilePendingToUpload = false;
// return downloadURL;
Expand All @@ -487,6 +501,7 @@ export class CDSDetailBotDetailComponent extends BotsBaseComponent implements On
this.uploadService.deleteProfile(this.selectedChatbot._id, this.selectedChatbot.imageURL).then((result)=>{
// this.botProfileImageExist = false;
this.selectedChatbot.imageURL = null
this.imageURL = null;
const delete_bot_image_btn = <HTMLElement>document.querySelector('#cds-delete-bot-img-btn');
delete_bot_image_btn.blur();
}).catch((error)=> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div> -->

<div class="action-row">
<label class="action-row-right">{{'CDSCanvas.HumanHandOver' | translate}}</label>
<label class="action-row-right">{{'CDSCanvas.TransferToAHuman' | translate}}</label>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,18 @@
<div class="action-wait-content">

<div class="action-wait-slider">
<div class="action-wait-range">1</div>
<div class="action-wait-range">{{ai_setting['temperature'].min}}</div>
<mat-slider
class="wait-slider"
thumbLabel
[displayWith]="formatLabel"
step="1" min="1" max="10"
[step]="ai_setting['top_k'].step"
[min]="ai_setting['top_k'].min"
[max]="ai_setting['top_k'].max"
[(ngModel)]="action.top_k"
(change)="updateSliderValue($event.value, 'top_k')" aria-label="units">
</mat-slider>
<div class="action-wait-range">10</div>
<div class="action-wait-range">{{ai_setting['top_k'].max}}</div>
</div>
<!-- // doesn't work propely -->
<!-- <cds-text [text]="action.temperature.toString()" [inputType]="'number'" [maxlength]="4" [min]="0" [max]="1" (onChange)="updateSliderValue($event, 'temperature')" class="slider-input"></cds-text> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export class CdsActionAskgptV2Component implements OnInit {
model_list: Array<{ name: string, value: string, multiplier: string}>;
ai_setting: { [key: string] : {name: string, min: number, max: number, step: number}} = {
"max_tokens": { name: "max_tokens", min: 10, max: 2048, step: 1},
"temperature" : { name: "temperature", min: 0, max: 1, step: 0.05}
"temperature" : { name: "temperature", min: 0, max: 1, step: 0.05},
"top_k": { name: "top_k", min: 1, max: 10, step: 1 }
}

BRAND_BASE_INFO = BRAND_BASE_INFO;
Expand Down Expand Up @@ -237,7 +238,7 @@ export class CdsActionAskgptV2Component implements OnInit {
this.action.top_k = 5;
}
if(!this.action.hasOwnProperty('max_tokens')){
this.action.max_tokens = 512;
this.action.max_tokens = 256;
}
if(!this.action.hasOwnProperty('temperature')){
this.action.temperature = 0.7;
Expand Down Expand Up @@ -332,6 +333,14 @@ export class CdsActionAskgptV2Component implements OnInit {
} else {
this.action.namespace = await this.nameToId(this.action.namespace);
}
}else if(target === 'citations'){
if (this.action[target]) {
this.ai_setting['max_tokens'].min=1024;
this.action.max_tokens = 1024
}else{
this.ai_setting['max_tokens'].min=10;
this.action.max_tokens = 256
}
}
this.updateAndSaveAction.emit({type: TYPE_UPDATE_ACTION.ACTION, element: this.action});

Expand Down Expand Up @@ -483,6 +492,7 @@ export class CdsActionAskgptV2Component implements OnInit {
element.classList.add('preview-container-extended')
}, 200)
this.showAiError = true;
this.ai_error = this.translate.instant('CDSCanvas.AiError')
if(err.error.error_code === 13001){
this.ai_error = this.translate.instant('CDSCanvas.AiQuotaExceeded')
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ export class CdsActionGPTTaskComponent implements OnInit {
context: this.action.context,
model: this.action.model,
max_tokens: this.action.max_tokens,
temperature: this.action.temperature
temperature: this.action.temperature,
formatType: this.action.formatType
}

this.showAiError = false;
Expand Down
Loading

0 comments on commit 26d337a

Please sign in to comment.