[JS] use shorthand notation (#711)

* [JS] use shorthand notation

* add `"object-shorthand": ["error", "always"],`

* fix "Expected method shorthand  object-shorthand"

* format
pull/717/head
Mishig 2024-01-22 09:49:36 +01:00 committed by GitHub
parent f35e104dbd
commit d5559df521
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 16 additions and 15 deletions

View File

@ -34,6 +34,7 @@ module.exports = {
argsIgnorePattern: "^_",
},
],
"object-shorthand": ["error", "always"],
},
env: {
browser: true,

View File

@ -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;

View File

@ -30,7 +30,7 @@ export async function endpointOai(
const openai = new OpenAI({
apiKey: apiKey ?? "sk-",
baseURL: baseURL,
baseURL,
});
if (completion === "completions") {

View File

@ -28,7 +28,7 @@ export async function findSimilarSentences(
(sentenceEmbedding: Embedding, index: number) => {
return {
distance: innerProduct(queryEmbedding, sentenceEmbedding),
index: index,
index,
};
}
);

View File

@ -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 {

View File

@ -42,7 +42,7 @@ export function loadClientCertificates(
key: clientKey,
ca: caCert,
passphrase: clientKeyPassword,
rejectUnauthorized: rejectUnauthorized,
rejectUnauthorized,
},
});

View File

@ -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 } } : {}),
});

View File

@ -260,7 +260,7 @@
messages = messages.map((message) => {
if (message.id === messageId) {
oldScore = message.score;
return { ...message, score: score };
return { ...message, score };
}
return message;
});

View File

@ -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(),
},
];

View File

@ -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(

View File

@ -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({

View File

@ -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(

View File

@ -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, {