chore: format

This commit is contained in:
Timothy Jaeryang Baek
2024-11-30 23:36:30 -08:00
parent 370f97b44e
commit 2fac9b45cd
55 changed files with 777 additions and 383 deletions
+13 -18
View File
@@ -397,14 +397,12 @@ export const generateQueries = async (
}
};
export const generateAutoCompletion = async (
token: string = '',
model: string,
prompt: string,
messages?: object[],
type: string = 'search query',
type: string = 'search query'
) => {
const controller = new AbortController();
let error = null;
@@ -425,17 +423,17 @@ export const generateAutoCompletion = async (
stream: false
})
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
if ('detail' in err) {
error = err.detail;
}
return null;
});
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
if ('detail' in err) {
error = err.detail;
}
return null;
});
if (error) {
throw error;
@@ -443,7 +441,6 @@ export const generateAutoCompletion = async (
const response = res?.choices[0]?.message?.content ?? '';
try {
const jsonStartIndex = response.indexOf('{');
const jsonEndIndex = response.lastIndexOf('}');
@@ -458,7 +455,7 @@ export const generateAutoCompletion = async (
if (parsed && parsed.text) {
return parsed.text;
} else {
return "";
return '';
}
}
@@ -469,10 +466,8 @@ export const generateAutoCompletion = async (
console.error('Failed to parse response: ', e);
return response;
}
};
export const generateMoACompletion = async (
token: string = '',
model: string,