Skip to content

Commit

Permalink
new(all): Auto import for logo, colors and website content.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Rodriguez committed May 21, 2024
1 parent 7fe50d9 commit e91c3a4
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 65 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ yarn-error.log
package-lock.json
yarn-lock.json
packages/saas.gbapp.zip
logo.svg
screenshot.png
48 changes: 47 additions & 1 deletion packages/core.gbapp/services/GBCoreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ import { GBHubSpotPackage } from '../../hubspot.gblib/index.js';
import open from 'open';
import ngrok from 'ngrok';
import Path from 'path';
import { file } from 'googleapis/build/src/apis/file/index.js';
import { GBUtil } from '../../../src/util.js';
import { GBLogEx } from './GBLogEx.js';
import { GBDeployer } from './GBDeployer.js';
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords.js';
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';

/**
* GBCoreService contains main logic for handling storage services related
Expand Down Expand Up @@ -665,6 +667,50 @@ ENDPOINT_UPDATE=true
await installationDeployer.openStorageFirewall(group, serverName);
}

public async setConfig(min, name: string, value: any): Promise<any> {

// Handles calls for BASIC persistence on sheet files.

GBLog.info( `Defining Config.xlsx variable ${name}= '${value}'...`);

let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);

const maxLines = 512;
const file = "Config.xlsx";
const path = DialogKeywords.getGBAIPath(min.botId, `gbot`);;

let document = await (new SystemKeywords()).internalGetDocument(client, baseUrl, path, file);

// Creates workbook session that will be discarded.

let sheets = await client
.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`)
.get();

let results = await client
.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name}')/range(address='A1:A${maxLines}')`)
.get();

const rows = results.text;
let address = '';

// Fills the row variable.

for (let i = 1; i <= rows.length; i++) {
let result = rows[i - 1][0];
if (result && result.toLowerCase() === name.toLowerCase()) {
address = `B${i}:B${i}`;
break;
}
}

let body = { values: [[]] };
body.values[0][0] = value;

await client
.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name}')/range(address='${address}')`)
.patch(body);
}



Expand Down
8 changes: 7 additions & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,13 @@ export class GBMinService {
paramLogoImageAlt: this.core.getParam(instance, 'Logo Image Alt', null),
paramLogoImageWidth: this.core.getParam(instance, 'Logo Image Width', null),
paramLogoImageHeight: this.core.getParam(instance, 'Logo Image Height', null),
paramLogoImageType: this.core.getParam(instance, 'Logo Image Type', null)
paramLogoImageType: this.core.getParam(instance, 'Logo Image Type', null),
logo: this.core.getParam(instance, 'Logo', null),
color1: this.core.getParam(instance, 'Color1', null),
color2: this.core.getParam(instance, 'Color2', null),



})
);
} else {
Expand Down
53 changes: 31 additions & 22 deletions packages/default.gbui/src/GBUIApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import GBBulletPlayer from './players/GBBulletPlayer.js';
import SidebarMenu from './components/SidebarMenu.js';
import SEO from './components/SEO.js';
import GBCss from './components/GBCss.js';
import { DirectLine} from 'botframework-directlinejs';
import { DirectLine } from 'botframework-directlinejs';
import { ConnectionStatus } from 'botframework-directlinejs';
import ReactWebChat from 'botframework-webchat';
import { UserAgentApplication } from 'msal';
Expand Down Expand Up @@ -257,16 +257,16 @@ class GBUIApp extends React.Component {
);
break;
case 'multiurl':
playerComponent = (
<GBMultiUrlPlayer
app={this}
ref={player => {
this.player = player;
}}
/>
);
break;
case 'image':
playerComponent = (
<GBMultiUrlPlayer
app={this}
ref={player => {
this.player = player;
}}
/>
);
break;
case 'image':
playerComponent = (
<GBImagePlayer
app={this}
Expand Down Expand Up @@ -305,18 +305,17 @@ class GBUIApp extends React.Component {
let chat = <div />;
let gbCss = <div />;
let seo = <div />;

let sideBar = (
<div className="sidebar">
<SidebarMenu chat={this.chat} instance={this.state.instanceClient} />
</div>
);
let sideBar = <div />;

if (this.state.line) {
if (this.state.instanceClient) {
let color1 = this.state.instanceClient.color1;
gbCss = <GBCss instance={this.state.instanceClient} />;
seo = <SEO instance={this.state.instanceClient} />;
const token = this.state.instanceClient.speechToken;

document.body.style.setProperty('background-color', this.state.instanceClient.color2, 'important');

chat = (
<ReactWebChat
ref={chat => {
Expand All @@ -329,15 +328,25 @@ class GBUIApp extends React.Component {
})}
/>
);
}
}

if (!this.state.instanceClient) {
sideBar = '';
sideBar = (
<div
className="sidebar"
ref={node => {
if (node) {
node.style.setProperty('background-color', this.state.instanceClient.color1, 'important');
}
}}
>
<SidebarMenu chat={this.chat} instance={this.state.instanceClient} />
</div>
);

}
}

return (
<StaticContent>

{seo}
<div>
{gbCss}
Expand Down
2 changes: 1 addition & 1 deletion packages/default.gbui/src/components/SidebarMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SideBarMenu extends React.Component {
<div className="tittleSideBarMenu">
<img
className="pragmatismoLogo"
src={"/themes/" + this.props.instance.theme + "/images/logo.png"}
src={this.props.instance.botId + "/cache/" + this.props.instance.logo}
alt="General Bots Logo" />

</div>
Expand Down
27 changes: 13 additions & 14 deletions packages/gpt.gblib/services/ChatServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,29 +254,28 @@ export class ChatServices {
public static async answerByGPT(
min: GBMinInstance,
user,
pid,
question: string,
searchScore: number,
subjects: GuaribasSubject[]
question: string, mode=null
) {
if (!process.env.OPENAI_API_KEY) {
return { answer: undefined, questionId: 0 };
}

const LLMMode = min.core.getParam(min.instance, 'Answer Mode', 'direct');
const LLMMode = mode??min.core.getParam(min.instance, 'Answer Mode', 'direct');

const docsContext = min['vectorStore'];

if (!this.memoryMap[user.userSystemId]) {
this.memoryMap[user.userSystemId] = new BufferWindowMemory({
returnMessages: true,
memoryKey: 'chat_history',
inputKey: 'input',
k: 2
});
const memory = new BufferWindowMemory({
returnMessages: true,
memoryKey: 'chat_history',
inputKey: 'input',
k: 2
});

if (user && !this.memoryMap[user.userSystemId]) {
this.memoryMap[user.userSystemId] = memory;
}
const memory = this.memoryMap[user.userSystemId];
const systemPrompt = this.userSystemPrompt[user.userSystemId];

const systemPrompt = user?this.userSystemPrompt[user.userSystemId]:'';

const model = new ChatOpenAI({
openAIApiKey: process.env.OPENAI_API_KEY,
Expand Down
Loading

0 comments on commit e91c3a4

Please sign in to comment.