Skip to content

Commit

Permalink
Update: Add context referencing for chatbot (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed Jun 2, 2024
1 parent 634e4e6 commit 60c3100
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
1 change: 0 additions & 1 deletion MovieVerse-Frontend/js/chatbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ async function movieVerseResponse(message) {
animateLoadingDots();

let fullResponse = '';

try {
const genAI = new GoogleGenerativeAI(getAIResponse());
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,9 @@ async function movieVerseResponse(message) {
}
else {
showSpinner();
let fullResponse = '';
animateLoadingDots();

let fullResponse = '';
try {
const genAI = new GoogleGenerativeAI(getAIResponse());
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
Expand All @@ -636,7 +637,7 @@ async function movieVerseResponse(message) {
temperature: 1,
topP: 0.95,
topK: 64,
maxOutputTokens: 512,
maxOutputTokens: 8192,
responseMimeType: "text/plain"
},
safetySettings: [
Expand All @@ -662,6 +663,17 @@ async function movieVerseResponse(message) {
}
}

async function animateLoadingDots() {
const loadingTextElement = document.querySelector('#myModal p');
let dots = ".";

while (document.getElementById('myModal').classList.contains('modal-visible')) {
loadingTextElement.textContent = `Loading response${dots}`;
dots = (dots.length < 3) ? dots + "." : ".";
await new Promise(resolve => setTimeout(resolve, 500));
}
}

function removeMarkdown(text) {
const converter = new showdown.Converter();
const html = converter.makeHtml(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,9 @@ async function movieVerseResponse(message) {
}
else {
showSpinner();
let fullResponse = '';
animateLoadingDots();

let fullResponse = '';
try {
const genAI = new GoogleGenerativeAI(getAIResponse());
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
Expand All @@ -636,7 +637,7 @@ async function movieVerseResponse(message) {
temperature: 1,
topP: 0.95,
topK: 64,
maxOutputTokens: 512,
maxOutputTokens: 8192,
responseMimeType: "text/plain"
},
safetySettings: [
Expand All @@ -662,6 +663,17 @@ async function movieVerseResponse(message) {
}
}

async function animateLoadingDots() {
const loadingTextElement = document.querySelector('#myModal p');
let dots = ".";

while (document.getElementById('myModal').classList.contains('modal-visible')) {
loadingTextElement.textContent = `Loading response${dots}`;
dots = (dots.length < 3) ? dots + "." : ".";
await new Promise(resolve => setTimeout(resolve, 500));
}
}

function removeMarkdown(text) {
const converter = new showdown.Converter();
const html = converter.makeHtml(text);
Expand Down
16 changes: 14 additions & 2 deletions MovieVerse-Mobile/www/MovieVerse-Frontend/js/chatbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,9 @@ async function movieVerseResponse(message) {
}
else {
showSpinner();
let fullResponse = '';
animateLoadingDots();

let fullResponse = '';
try {
const genAI = new GoogleGenerativeAI(getAIResponse());
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
Expand All @@ -636,7 +637,7 @@ async function movieVerseResponse(message) {
temperature: 1,
topP: 0.95,
topK: 64,
maxOutputTokens: 512,
maxOutputTokens: 8192,
responseMimeType: "text/plain"
},
safetySettings: [
Expand All @@ -662,6 +663,17 @@ async function movieVerseResponse(message) {
}
}

async function animateLoadingDots() {
const loadingTextElement = document.querySelector('#myModal p');
let dots = ".";

while (document.getElementById('myModal').classList.contains('modal-visible')) {
loadingTextElement.textContent = `Loading response${dots}`;
dots = (dots.length < 3) ? dots + "." : ".";
await new Promise(resolve => setTimeout(resolve, 500));
}
}

function removeMarkdown(text) {
const converter = new showdown.Converter();
const html = converter.makeHtml(text);
Expand Down

0 comments on commit 60c3100

Please sign in to comment.