[JS] use shorthand notation (#711)
* [JS] use shorthand notation * add `"object-shorthand": ["error", "always"],` * fix "Expected method shorthand object-shorthand" * formatpull/717/head
parent
f35e104dbd
commit
d5559df521
|
@ -34,6 +34,7 @@ module.exports = {
|
|||
argsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
"object-shorthand": ["error", "always"],
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
|
|
|
@ -57,7 +57,7 @@ export function refreshSessionCookie(cookies: Cookies, sessionId: string) {
|
|||
}
|
||||
|
||||
export async function findUser(sessionId: string) {
|
||||
const session = await collections.sessions.findOne({ sessionId: sessionId });
|
||||
const session = await collections.sessions.findOne({ sessionId });
|
||||
|
||||
if (!session) {
|
||||
return null;
|
||||
|
|
|
@ -30,7 +30,7 @@ export async function endpointOai(
|
|||
|
||||
const openai = new OpenAI({
|
||||
apiKey: apiKey ?? "sk-",
|
||||
baseURL: baseURL,
|
||||
baseURL,
|
||||
});
|
||||
|
||||
if (completion === "completions") {
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function findSimilarSentences(
|
|||
(sentenceEmbedding: Embedding, index: number) => {
|
||||
return {
|
||||
distance: innerProduct(queryEmbedding, sentenceEmbedding),
|
||||
index: index,
|
||||
index,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ export async function runWebSearch(
|
|||
})() satisfies Message[];
|
||||
|
||||
const webSearch: WebSearch = {
|
||||
prompt: prompt,
|
||||
prompt,
|
||||
searchQuery: "",
|
||||
results: [],
|
||||
context: "",
|
||||
|
@ -35,7 +35,7 @@ export async function runWebSearch(
|
|||
};
|
||||
|
||||
function appendUpdate(message: string, args?: string[], type?: "error" | "update") {
|
||||
updatePad({ type: "webSearch", messageType: type ?? "update", message: message, args: args });
|
||||
updatePad({ type: "webSearch", messageType: type ?? "update", message, args });
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -42,7 +42,7 @@ export function loadClientCertificates(
|
|||
key: clientKey,
|
||||
ca: caCert,
|
||||
passphrase: clientKeyPassword,
|
||||
rejectUnauthorized: rejectUnauthorized,
|
||||
rejectUnauthorized,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ export const POST: RequestHandler = async ({ locals, request }) => {
|
|||
preprompt: preprompt === model?.preprompt ? model?.preprompt : preprompt,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
embeddingModel: embeddingModel,
|
||||
embeddingModel,
|
||||
...(locals.user ? { userId: locals.user._id } : { sessionId: locals.sessionId }),
|
||||
...(values.fromShare ? { meta: { fromShareId: values.fromShare } } : {}),
|
||||
});
|
||||
|
|
|
@ -260,7 +260,7 @@
|
|||
messages = messages.map((message) => {
|
||||
if (message.id === messageId) {
|
||||
oldScore = message.score;
|
||||
return { ...message, score: score };
|
||||
return { ...message, score };
|
||||
}
|
||||
return message;
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
|
|||
|
||||
// register the event for ratelimiting
|
||||
await collections.messageEvents.insertOne({
|
||||
userId: userId,
|
||||
userId,
|
||||
createdAt: new Date(),
|
||||
ip: getClientAddress(),
|
||||
});
|
||||
|
@ -265,7 +265,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
|
|||
from: "assistant",
|
||||
content: output.token.text.trimStart(),
|
||||
webSearch: webSearchResults,
|
||||
updates: updates,
|
||||
updates,
|
||||
id: crypto.randomUUID(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
|
@ -293,7 +293,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
|
|||
{
|
||||
...messages[messages.length - 1],
|
||||
content: output.generated_text,
|
||||
updates: updates,
|
||||
updates,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
];
|
||||
|
|
|
@ -40,7 +40,7 @@ export async function GET({ params, locals }) {
|
|||
preprompt: conv.preprompt,
|
||||
webSearch: messagesUpTo[messagesUpTo.length - 1].webSearch,
|
||||
messages: messagesUpTo,
|
||||
model: model,
|
||||
model,
|
||||
});
|
||||
|
||||
return new Response(
|
||||
|
|
|
@ -4,7 +4,7 @@ import { collections } from "$lib/server/database";
|
|||
import { redirect } from "@sveltejs/kit";
|
||||
|
||||
export const actions = {
|
||||
delete: async function ({ locals }) {
|
||||
async delete({ locals }) {
|
||||
// double check we have a user to delete conversations for
|
||||
if (locals.user?._id || locals.sessionId) {
|
||||
await collections.conversations.deleteMany({
|
||||
|
|
|
@ -3,7 +3,7 @@ import { getOIDCAuthorizationUrl } from "$lib/server/auth";
|
|||
import { base } from "$app/paths";
|
||||
|
||||
export const actions = {
|
||||
default: async function ({ url, locals, request }) {
|
||||
async default({ url, locals, request }) {
|
||||
// TODO: Handle errors if provider is not responding
|
||||
const referer = request.headers.get("referer");
|
||||
const authorizationUrl = await getOIDCAuthorizationUrl(
|
||||
|
|
|
@ -5,7 +5,7 @@ import { collections } from "$lib/server/database";
|
|||
import { redirect } from "@sveltejs/kit";
|
||||
|
||||
export const actions = {
|
||||
default: async function ({ cookies, locals }) {
|
||||
async default({ cookies, locals }) {
|
||||
await collections.sessions.deleteOne({ sessionId: locals.sessionId });
|
||||
|
||||
cookies.delete(COOKIE_NAME, {
|
||||
|
|
Loading…
Reference in New Issue