Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,48 @@
"**/node_modules/**"
],
"rewrites": [
{
"source": "/explainText",
"function": {
"functionId": "explainText",
"region": "us-central1"
}
},
{
"source": "/explainEnglishText",
"function": {
"functionId": "explainEnglishText",
"region": "us-central1"
}
},
{
"source": "/analyzeImage",
"function": {
"functionId": "analyzeImage",
"region": "us-central1"
}
},
{
"source": "/generateChineseSentences",
"function": {
"functionId": "generateChineseSentences",
"region": "us-central1"
}
},
{
"source": "/analyzeCollocation",
"function": {
"functionId": "analyzeCollocation",
"region": "us-central1"
}
},
{
"source": "/explainWordInContext",
"function": {
"functionId": "explainWordInContext",
"region": "us-central1"
}
},
{
"source": "/components/**",
"destination": "/components/index.html"
Expand Down Expand Up @@ -51,4 +93,4 @@
]
}
]
}
}
12 changes: 6 additions & 6 deletions public/js/modules/data-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ async function explainChineseSentence(text) {
if (localAi.isLocalAiEnabled()) {
return await localAi.explainChineseSentence(text);
}
const functions = getFunctions();
const functions = getFunctions(getApp(), window.location.origin);
// connectFunctionsEmulator(functions, "127.0.0.1", 5001);
const explainChinese = httpsCallable(functions, 'explainText');
const result = await explainChinese(text);
Expand All @@ -737,7 +737,7 @@ async function translateEnglish(text) {
if (localAi.isLocalAiEnabled()) {
result = await localAi.translateEnglish(text);
} else {
const functions = getFunctions();
const functions = getFunctions(getApp(), window.location.origin);
// connectFunctionsEmulator(functions, "127.0.0.1", 5001);
const explainEnglish = httpsCallable(functions, 'explainEnglishText');
result = await explainEnglish(text);
Expand All @@ -752,7 +752,7 @@ async function generateChineseSentences(word, definitions) {
if (localAi.isLocalAiEnabled()) {
aiData = await localAi.generateChineseSentences(word, definitions);
} else {
const functions = getFunctions();
const functions = getFunctions(getApp(), window.location.origin);
// connectFunctionsEmulator(functions, "127.0.0.1", 5001);
const generateChineseSentencesCall = httpsCallable(functions, 'generateChineseSentences');
aiData = await generateChineseSentencesCall({ word, definitions });
Expand All @@ -774,7 +774,7 @@ async function analyzeCollocation(collocation) {
if (localAi.isLocalAiEnabled()) {
aiData = await localAi.analyzeCollocation(collocation);
} else {
const functions = getFunctions();
const functions = getFunctions(getApp(), window.location.origin);
// connectFunctionsEmulator(functions, "127.0.0.1", 5001);
const analyzeCollocationCall = httpsCallable(functions, 'analyzeCollocation');
aiData = await analyzeCollocationCall(collocation);
Expand All @@ -797,7 +797,7 @@ async function analyzeImage(base64ImageContents) {
if (localAi.isLocalAiEnabled()) {
return await localAi.analyzeImage(base64ImageContents);
}
const functions = getFunctions();
const functions = getFunctions(getApp(), window.location.origin);
// connectFunctionsEmulator(functions, "127.0.0.1", 5001);
const analyzeImage = httpsCallable(functions, 'analyzeImage');
const result = await analyzeImage(base64ImageContents);
Expand All @@ -808,7 +808,7 @@ async function explainWordInContext(word, sentence) {
if (localAi.isLocalAiEnabled()) {
return await localAi.explainWordInContext(word, sentence);
}
const functions = getFunctions();
const functions = getFunctions(getApp(), window.location.origin);
// connectFunctionsEmulator(functions, "127.0.0.1", 5001);
const explainWordInContextCall = httpsCallable(functions, 'explainWordInContext');
const result = await explainWordInContextCall({ word, sentence });
Expand Down
Loading