Spaces:
Build error
Build error
Mishig
commited on
Commit
•
d5559df
1
Parent(s):
f35e104
[JS] use shorthand notation (#711)
Browse files* [JS] use shorthand notation
* add `"object-shorthand": ["error", "always"],`
* fix "Expected method shorthand object-shorthand"
* format
- .eslintrc.cjs +1 -0
- src/lib/server/auth.ts +1 -1
- src/lib/server/endpoints/openai/endpointOai.ts +1 -1
- src/lib/server/sentenceSimilarity.ts +1 -1
- src/lib/server/websearch/runWebSearch.ts +2 -2
- src/lib/utils/loadClientCerts.ts +1 -1
- src/routes/conversation/+server.ts +1 -1
- src/routes/conversation/[id]/+page.svelte +1 -1
- src/routes/conversation/[id]/+server.ts +3 -3
- src/routes/conversation/[id]/message/[messageId]/prompt/+server.ts +1 -1
- src/routes/conversations/+page.server.ts +1 -1
- src/routes/login/+page.server.ts +1 -1
- src/routes/logout/+page.server.ts +1 -1
.eslintrc.cjs
CHANGED
@@ -34,6 +34,7 @@ module.exports = {
|
|
34 |
argsIgnorePattern: "^_",
|
35 |
},
|
36 |
],
|
|
|
37 |
},
|
38 |
env: {
|
39 |
browser: true,
|
|
|
34 |
argsIgnorePattern: "^_",
|
35 |
},
|
36 |
],
|
37 |
+
"object-shorthand": ["error", "always"],
|
38 |
},
|
39 |
env: {
|
40 |
browser: true,
|
src/lib/server/auth.ts
CHANGED
@@ -57,7 +57,7 @@ export function refreshSessionCookie(cookies: Cookies, sessionId: string) {
|
|
57 |
}
|
58 |
|
59 |
export async function findUser(sessionId: string) {
|
60 |
-
const session = await collections.sessions.findOne({ sessionId
|
61 |
|
62 |
if (!session) {
|
63 |
return null;
|
|
|
57 |
}
|
58 |
|
59 |
export async function findUser(sessionId: string) {
|
60 |
+
const session = await collections.sessions.findOne({ sessionId });
|
61 |
|
62 |
if (!session) {
|
63 |
return null;
|
src/lib/server/endpoints/openai/endpointOai.ts
CHANGED
@@ -30,7 +30,7 @@ export async function endpointOai(
|
|
30 |
|
31 |
const openai = new OpenAI({
|
32 |
apiKey: apiKey ?? "sk-",
|
33 |
-
baseURL
|
34 |
});
|
35 |
|
36 |
if (completion === "completions") {
|
|
|
30 |
|
31 |
const openai = new OpenAI({
|
32 |
apiKey: apiKey ?? "sk-",
|
33 |
+
baseURL,
|
34 |
});
|
35 |
|
36 |
if (completion === "completions") {
|
src/lib/server/sentenceSimilarity.ts
CHANGED
@@ -28,7 +28,7 @@ export async function findSimilarSentences(
|
|
28 |
(sentenceEmbedding: Embedding, index: number) => {
|
29 |
return {
|
30 |
distance: innerProduct(queryEmbedding, sentenceEmbedding),
|
31 |
-
index
|
32 |
};
|
33 |
}
|
34 |
);
|
|
|
28 |
(sentenceEmbedding: Embedding, index: number) => {
|
29 |
return {
|
30 |
distance: innerProduct(queryEmbedding, sentenceEmbedding),
|
31 |
+
index,
|
32 |
};
|
33 |
}
|
34 |
);
|
src/lib/server/websearch/runWebSearch.ts
CHANGED
@@ -25,7 +25,7 @@ export async function runWebSearch(
|
|
25 |
})() satisfies Message[];
|
26 |
|
27 |
const webSearch: WebSearch = {
|
28 |
-
prompt
|
29 |
searchQuery: "",
|
30 |
results: [],
|
31 |
context: "",
|
@@ -35,7 +35,7 @@ export async function runWebSearch(
|
|
35 |
};
|
36 |
|
37 |
function appendUpdate(message: string, args?: string[], type?: "error" | "update") {
|
38 |
-
updatePad({ type: "webSearch", messageType: type ?? "update", message
|
39 |
}
|
40 |
|
41 |
try {
|
|
|
25 |
})() satisfies Message[];
|
26 |
|
27 |
const webSearch: WebSearch = {
|
28 |
+
prompt,
|
29 |
searchQuery: "",
|
30 |
results: [],
|
31 |
context: "",
|
|
|
35 |
};
|
36 |
|
37 |
function appendUpdate(message: string, args?: string[], type?: "error" | "update") {
|
38 |
+
updatePad({ type: "webSearch", messageType: type ?? "update", message, args });
|
39 |
}
|
40 |
|
41 |
try {
|
src/lib/utils/loadClientCerts.ts
CHANGED
@@ -42,7 +42,7 @@ export function loadClientCertificates(
|
|
42 |
key: clientKey,
|
43 |
ca: caCert,
|
44 |
passphrase: clientKeyPassword,
|
45 |
-
rejectUnauthorized
|
46 |
},
|
47 |
});
|
48 |
|
|
|
42 |
key: clientKey,
|
43 |
ca: caCert,
|
44 |
passphrase: clientKeyPassword,
|
45 |
+
rejectUnauthorized,
|
46 |
},
|
47 |
});
|
48 |
|
src/routes/conversation/+server.ts
CHANGED
@@ -64,7 +64,7 @@ export const POST: RequestHandler = async ({ locals, request }) => {
|
|
64 |
preprompt: preprompt === model?.preprompt ? model?.preprompt : preprompt,
|
65 |
createdAt: new Date(),
|
66 |
updatedAt: new Date(),
|
67 |
-
embeddingModel
|
68 |
...(locals.user ? { userId: locals.user._id } : { sessionId: locals.sessionId }),
|
69 |
...(values.fromShare ? { meta: { fromShareId: values.fromShare } } : {}),
|
70 |
});
|
|
|
64 |
preprompt: preprompt === model?.preprompt ? model?.preprompt : preprompt,
|
65 |
createdAt: new Date(),
|
66 |
updatedAt: new Date(),
|
67 |
+
embeddingModel,
|
68 |
...(locals.user ? { userId: locals.user._id } : { sessionId: locals.sessionId }),
|
69 |
...(values.fromShare ? { meta: { fromShareId: values.fromShare } } : {}),
|
70 |
});
|
src/routes/conversation/[id]/+page.svelte
CHANGED
@@ -260,7 +260,7 @@
|
|
260 |
messages = messages.map((message) => {
|
261 |
if (message.id === messageId) {
|
262 |
oldScore = message.score;
|
263 |
-
return { ...message, score
|
264 |
}
|
265 |
return message;
|
266 |
});
|
|
|
260 |
messages = messages.map((message) => {
|
261 |
if (message.id === messageId) {
|
262 |
oldScore = message.score;
|
263 |
+
return { ...message, score };
|
264 |
}
|
265 |
return message;
|
266 |
});
|
src/routes/conversation/[id]/+server.ts
CHANGED
@@ -39,7 +39,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
|
|
39 |
|
40 |
// register the event for ratelimiting
|
41 |
await collections.messageEvents.insertOne({
|
42 |
-
userId
|
43 |
createdAt: new Date(),
|
44 |
ip: getClientAddress(),
|
45 |
});
|
@@ -265,7 +265,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
|
|
265 |
from: "assistant",
|
266 |
content: output.token.text.trimStart(),
|
267 |
webSearch: webSearchResults,
|
268 |
-
updates
|
269 |
id: crypto.randomUUID(),
|
270 |
createdAt: new Date(),
|
271 |
updatedAt: new Date(),
|
@@ -293,7 +293,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
|
|
293 |
{
|
294 |
...messages[messages.length - 1],
|
295 |
content: output.generated_text,
|
296 |
-
updates
|
297 |
updatedAt: new Date(),
|
298 |
},
|
299 |
];
|
|
|
39 |
|
40 |
// register the event for ratelimiting
|
41 |
await collections.messageEvents.insertOne({
|
42 |
+
userId,
|
43 |
createdAt: new Date(),
|
44 |
ip: getClientAddress(),
|
45 |
});
|
|
|
265 |
from: "assistant",
|
266 |
content: output.token.text.trimStart(),
|
267 |
webSearch: webSearchResults,
|
268 |
+
updates,
|
269 |
id: crypto.randomUUID(),
|
270 |
createdAt: new Date(),
|
271 |
updatedAt: new Date(),
|
|
|
293 |
{
|
294 |
...messages[messages.length - 1],
|
295 |
content: output.generated_text,
|
296 |
+
updates,
|
297 |
updatedAt: new Date(),
|
298 |
},
|
299 |
];
|
src/routes/conversation/[id]/message/[messageId]/prompt/+server.ts
CHANGED
@@ -40,7 +40,7 @@ export async function GET({ params, locals }) {
|
|
40 |
preprompt: conv.preprompt,
|
41 |
webSearch: messagesUpTo[messagesUpTo.length - 1].webSearch,
|
42 |
messages: messagesUpTo,
|
43 |
-
model
|
44 |
});
|
45 |
|
46 |
return new Response(
|
|
|
40 |
preprompt: conv.preprompt,
|
41 |
webSearch: messagesUpTo[messagesUpTo.length - 1].webSearch,
|
42 |
messages: messagesUpTo,
|
43 |
+
model,
|
44 |
});
|
45 |
|
46 |
return new Response(
|
src/routes/conversations/+page.server.ts
CHANGED
@@ -4,7 +4,7 @@ import { collections } from "$lib/server/database";
|
|
4 |
import { redirect } from "@sveltejs/kit";
|
5 |
|
6 |
export const actions = {
|
7 |
-
|
8 |
// double check we have a user to delete conversations for
|
9 |
if (locals.user?._id || locals.sessionId) {
|
10 |
await collections.conversations.deleteMany({
|
|
|
4 |
import { redirect } from "@sveltejs/kit";
|
5 |
|
6 |
export const actions = {
|
7 |
+
async delete({ locals }) {
|
8 |
// double check we have a user to delete conversations for
|
9 |
if (locals.user?._id || locals.sessionId) {
|
10 |
await collections.conversations.deleteMany({
|
src/routes/login/+page.server.ts
CHANGED
@@ -3,7 +3,7 @@ import { getOIDCAuthorizationUrl } from "$lib/server/auth";
|
|
3 |
import { base } from "$app/paths";
|
4 |
|
5 |
export const actions = {
|
6 |
-
|
7 |
// TODO: Handle errors if provider is not responding
|
8 |
const referer = request.headers.get("referer");
|
9 |
const authorizationUrl = await getOIDCAuthorizationUrl(
|
|
|
3 |
import { base } from "$app/paths";
|
4 |
|
5 |
export const actions = {
|
6 |
+
async default({ url, locals, request }) {
|
7 |
// TODO: Handle errors if provider is not responding
|
8 |
const referer = request.headers.get("referer");
|
9 |
const authorizationUrl = await getOIDCAuthorizationUrl(
|
src/routes/logout/+page.server.ts
CHANGED
@@ -5,7 +5,7 @@ import { collections } from "$lib/server/database";
|
|
5 |
import { redirect } from "@sveltejs/kit";
|
6 |
|
7 |
export const actions = {
|
8 |
-
|
9 |
await collections.sessions.deleteOne({ sessionId: locals.sessionId });
|
10 |
|
11 |
cookies.delete(COOKIE_NAME, {
|
|
|
5 |
import { redirect } from "@sveltejs/kit";
|
6 |
|
7 |
export const actions = {
|
8 |
+
async default({ cookies, locals }) {
|
9 |
await collections.sessions.deleteOne({ sessionId: locals.sessionId });
|
10 |
|
11 |
cookies.delete(COOKIE_NAME, {
|