This commit is contained in:
Mckay Wrigley
2023-04-04 10:06:59 -06:00
parent d570c8b1ed
commit 4fd5210df6
3 changed files with 42 additions and 8 deletions
+16 -1
View File
@@ -118,6 +118,21 @@ const Home: React.FC<HomeProps> = ({
};
const endpoint = getEndpoint(plugin);
let body;
if (!plugin) {
body = JSON.stringify(chatBody);
} else {
body = JSON.stringify({
...chatBody,
googleAPIKey: pluginKeys
.find((key) => key.pluginId === 'google-search')
?.requiredKeys.find((key) => key.key === 'GOOGLE_API_KEY')?.value,
googleCSEId: pluginKeys
.find((key) => key.pluginId === 'google-search')
?.requiredKeys.find((key) => key.key === 'GOOGLE_CSE_ID')?.value,
});
}
const controller = new AbortController();
const response = await fetch(endpoint, {
@@ -126,7 +141,7 @@ const Home: React.FC<HomeProps> = ({
'Content-Type': 'application/json',
},
signal: controller.signal,
body: JSON.stringify(chatBody),
body,
});
if (!response.ok) {