Skip to content

Commit

Permalink
added: error message if token quotes exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Panico committed Jun 19, 2024
1 parent b4c8e2e commit e335859
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
</div>

<!-- // system context textarea -->
<!-- <div class="field-box">
<div class="field-box">
<label class="title-label">{{'CDSCanvas.SystemContext' | translate }}</label>
<cds-textarea id="context"
[textLimitBtn]="false"
Expand All @@ -268,7 +268,7 @@
(blur)="onBlur($event)"
(changeTextarea)="onChangeTextarea($event, 'context')">
</cds-textarea>
</div> -->
</div>

</div>
</mat-expansion-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class CdsActionAskgptV2Component implements OnInit {

let data = {
question: question,
context: this.action.context,
system_context: this.action.context,
model: this.action.model,
max_tokens: this.action.max_tokens,
temperature: this.action.temperature,
Expand All @@ -377,14 +377,19 @@ export class CdsActionAskgptV2Component implements OnInit {
element.classList.add('preview-container-extended')
}, 200)
this.ai_response = ai_response.answer;
}, (error) => {
}, (err) => {
this.searching = false;
this.logger.error("[ACTION GPT-TASK] previewPrompt error: ", error);
this.logger.error("[ACTION GPT-TASK] previewPrompt error: ", err);
setTimeout(() => {
let element = document.getElementById("preview-container");
element.classList.add('preview-container-extended')
}, 200)
this.showAiError = true;
if(err.error.error_code === 13001){
this.ai_error = this.translate.instant('CDSCanvas.AiQuotaExceeded')
return;
}

this.ai_error = this.translate.instant('CDSCanvas.AiError')
}, () => {
this.logger.debug("[ACTION GPT-TASK] preview prompt *COMPLETE*: ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,18 @@ export class CdsActionGPTTaskComponent implements OnInit {
element.classList.add('preview-container-extended')
}, 200)
this.ai_response = ai_response;
}, (error) => {
}, (err) => {
this.searching = false;
this.logger.error("[ACTION GPT-TASK] previewPrompt error: ", error);
this.logger.error("[ACTION GPT-TASK] previewPrompt error: ", err);
setTimeout(() => {
let element = document.getElementById("preview-container");
element.classList.add('preview-container-extended')
}, 200)
this.showAiError = true;
if(err.error.error_code === 13001){
this.ai_error = this.translate.instant('CDSCanvas.AiQuotaExceeded')
return;
}
this.ai_error = this.translate.instant('CDSCanvas.AiError')
}, () => {
this.logger.debug("[ACTION GPT-TASK] preview prompt *COMPLETE*: ");
Expand Down
4 changes: 2 additions & 2 deletions src/app/chatbot-design-studio/utils-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ export const ACTIONS_LIST: {[key: string]: {name: string, category: TYPE_ACTION_
ASKGPT: { name: 'CDSActionList.NAME.AskTheKnowledgeBase', category: TYPE_ACTION_CATEGORY.AI, type: TYPE_ACTION.ASKGPT, src: "assets/images/actions/ask_to_kb.svg", status: "inactive", description: "CDSActionList.DESCRIPTION.AskTheKnowledgeBase" },
ASKGPTV2: { name: 'CDSActionList.NAME.AskTheKnowledgeBase', category: TYPE_ACTION_CATEGORY.AI, type: TYPE_ACTION.ASKGPTV2, src: "assets/images/actions/ask_to_kb.svg", status: "active", description: "CDSActionList.DESCRIPTION.AskTheKnowledgeBase" },
GPT_TASK: { name: 'CDSActionList.NAME.GPTTask', category: TYPE_ACTION_CATEGORY.AI, type: TYPE_ACTION.GPT_TASK, src: "assets/images/actions/openai-icon.svg", status: "active", description: "CDSActionList.DESCRIPTION.GPTTask" },
GPT_ASSISTANT: { name: 'CDSActionList.NAME.GPTAssistant', category: TYPE_ACTION_CATEGORY.AI, type: TYPE_ACTION.GPT_ASSISTANT, src: "assets/images/actions/openai-assistent.svg", status: "beta", description: "CDSActionList.DESCRIPTION.GPTAssistant", doc: "CDSActionList.DOCS.GPTAssistant" },
GPT_ASSISTANT: { name: 'CDSActionList.NAME.GPTAssistant', category: TYPE_ACTION_CATEGORY.AI, type: TYPE_ACTION.GPT_ASSISTANT, src: "assets/images/actions/openai-assistent.svg", status: "beta", plan: PLAN_NAME.F, description: "CDSActionList.DESCRIPTION.GPTAssistant", doc: "CDSActionList.DOCS.GPTAssistant" },
HIDE_MESSAGE: { name: 'CDSActionList.NAME.HiddenMessage', category: TYPE_ACTION_CATEGORY.SPECIAL, type: TYPE_ACTION.HIDE_MESSAGE, src: "assets/images/actions/hidden_message.svg", status: "active" },
CHANGE_DEPARTMENT: { name: 'CDSActionList.NAME.ChangeDept', category: TYPE_ACTION_CATEGORY.SPECIAL, type: TYPE_ACTION.CHANGE_DEPARTMENT, src: "assets/images/actions/change_department.svg", status: "active" },
CODE : { name: 'CDSActionList.NAME.Code', category: TYPE_ACTION_CATEGORY.SPECIAL, type: TYPE_ACTION.CODE, src:"assets/images/actions/code.svg", status: "active", plan: PLAN_NAME.F, description: '', disabled: false },
CODE : { name: 'CDSActionList.NAME.Code', category: TYPE_ACTION_CATEGORY.SPECIAL, type: TYPE_ACTION.CODE, src:"assets/images/actions/code.svg", status: "active", plan: PLAN_NAME.F, description: '', disabled: false },
// ASSIGN_FUNCTION: { name: 'CDSActionList.NAME.SetFunction', category: TYPE_ACTION_CATEGORY.NEW, type: TYPE_ACTION.ASSIGN_FUNCTION, src: "assets/images/actions/assign_var.svg" },
CAPTURE_USER_REPLY: { name: 'CDSActionList.NAME.CaptureUserReply', category: TYPE_ACTION_CATEGORY.FLOW, type: TYPE_ACTION.CAPTURE_USER_REPLY, src: "assets/images/actions/capture_user_reply.svg", status: "active", description: "CDSActionList.DESCRIPTION.CaptureUserReply" },
QAPLA: { name: 'CDSActionList.NAME.Qapla', category: TYPE_ACTION_CATEGORY.INTEGRATIONS, type: TYPE_ACTION.QAPLA, src: "assets/images/actions/qapla.svg", status: "active", plan: PLAN_NAME.E, description: "CDSActionList.DESCRIPTION.Qapla", disabled: false },
Expand Down

0 comments on commit e335859

Please sign in to comment.