Skip to content

Commit

Permalink
responses from AI now render, communication with LLMs not yet solid
Browse files Browse the repository at this point in the history
  • Loading branch information
zdodson21 committed Jun 24, 2024
1 parent c3b4f38 commit d547fb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions elements/chat-agent/chat-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ChatAgent extends DDD {
this.chatLog = [];
this.engine = "alfred";
store.userData.userName !== undefined ? this.userName = store.userData.userName : this.userName = "guest";
store.userData.userPicture !== undefined ? this.userPicture = store.userData.userPicture : null;
store.userData.userPicture !== undefined ? this.userPicture = store.userData.userPicture : null; // TODO may not utilize, remove if not utilized

// button
this.buttonIcon = "hax:wizard-hat";
Expand Down Expand Up @@ -223,6 +223,8 @@ class ChatAgent extends DDD {
* @param {string} message - the written or suggested prompt
*/
handleMessage(author, message) {
this.developerModeEnabled ? console.info(`HAX-DEV-MODE: Writing message ${message} by ${author} to chatLog.`) : null;

let authorIndex;

this.messageIndex++;
Expand Down Expand Up @@ -278,11 +280,13 @@ class ChatAgent extends DDD {
MicroFrontendRegistry.call("@haxcms/aiChat", params)
.then((d) => {
if (d.status == 200) {
this.answers = [...d.data.answers];
this.answers = [d.data.answer];
console.log(this.answers);
this.question = d.data.question;
}
this.loading = false;

this.handleMessage("merlin", d.data.answer);
})
.catch((error) => {
this.loading = false;
Expand Down
8 changes: 6 additions & 2 deletions elements/chat-agent/src/chat-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ChatAgent extends DDD {
this.chatLog = [];
this.engine = "alfred";
store.userData.userName !== undefined ? this.userName = store.userData.userName : this.userName = "guest";
store.userData.userPicture !== undefined ? this.userPicture = store.userData.userPicture : null;
store.userData.userPicture !== undefined ? this.userPicture = store.userData.userPicture : null; // TODO may not utilize, remove if not utilized

// button
this.buttonIcon = "hax:wizard-hat";
Expand Down Expand Up @@ -223,6 +223,8 @@ class ChatAgent extends DDD {
* @param {string} message - the written or suggested prompt
*/
handleMessage(author, message) {
this.developerModeEnabled ? console.info(`HAX-DEV-MODE: Writing message ${message} by ${author} to chatLog.`) : null;

let authorIndex;

this.messageIndex++;
Expand Down Expand Up @@ -278,11 +280,13 @@ class ChatAgent extends DDD {
MicroFrontendRegistry.call("@haxcms/aiChat", params)
.then((d) => {
if (d.status == 200) {
this.answers = [...d.data.answers];
this.answers = [d.data.answer];
console.log(this.answers);
this.question = d.data.question;
}
this.loading = false;

this.handleMessage("merlin", d.data.answer);
})
.catch((error) => {
this.loading = false;
Expand Down

0 comments on commit d547fb9

Please sign in to comment.