chore: Update eslint and prettier configurations
This commit is contained in:
parent
c63c9b5c8a
commit
5b1aaee605
24 changed files with 826 additions and 38 deletions
14
.editorconfig
Normal file
14
.editorconfig
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
max_line_length = 120
|
||||||
|
quote_type = double
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
2
.eslintignore
Normal file
2
.eslintignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
11
.eslintrc.json
Normal file
11
.eslintrc.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
]
|
||||||
|
}
|
5
.prettierrc
Normal file
5
.prettierrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"endOfLine": "auto",
|
||||||
|
"trailingComma": "all",
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
}
|
|
@ -8,15 +8,17 @@
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"dev": "nodemon src/app.ts",
|
"dev": "nodemon src/app.ts",
|
||||||
"db:push": "drizzle-kit push sqlite",
|
"db:push": "drizzle-kit push sqlite",
|
||||||
"format": "prettier . --check",
|
"lint": "eslint ."
|
||||||
"format:write": "prettier . --write"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/better-sqlite3": "^7.6.10",
|
"@types/better-sqlite3": "^7.6.10",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/readable-stream": "^4.0.11",
|
"@types/readable-stream": "^4.0.11",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
||||||
|
"@typescript-eslint/parser": "^7.15.0",
|
||||||
"drizzle-kit": "^0.22.7",
|
"drizzle-kit": "^0.22.7",
|
||||||
|
"eslint": "^8",
|
||||||
"nodemon": "^3.1.0",
|
"nodemon": "^3.1.0",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
|
|
|
@ -66,7 +66,7 @@ const basicAcademicSearchResponsePrompt = `
|
||||||
const strParser = new StringOutputParser();
|
const strParser = new StringOutputParser();
|
||||||
|
|
||||||
const handleStream = async (
|
const handleStream = async (
|
||||||
stream: AsyncGenerator<StreamEvent, any, unknown>,
|
stream: AsyncGenerator<StreamEvent, unknown, unknown>,
|
||||||
emitter: eventEmitter,
|
emitter: eventEmitter,
|
||||||
) => {
|
) => {
|
||||||
for await (const event of stream) {
|
for await (const event of stream) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ const basicRedditSearchResponsePrompt = `
|
||||||
const strParser = new StringOutputParser();
|
const strParser = new StringOutputParser();
|
||||||
|
|
||||||
const handleStream = async (
|
const handleStream = async (
|
||||||
stream: AsyncGenerator<StreamEvent, any, unknown>,
|
stream: AsyncGenerator<StreamEvent, unknown, unknown>,
|
||||||
emitter: eventEmitter,
|
emitter: eventEmitter,
|
||||||
) => {
|
) => {
|
||||||
for await (const event of stream) {
|
for await (const event of stream) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ const basicWebSearchResponsePrompt = `
|
||||||
const strParser = new StringOutputParser();
|
const strParser = new StringOutputParser();
|
||||||
|
|
||||||
const handleStream = async (
|
const handleStream = async (
|
||||||
stream: AsyncGenerator<StreamEvent, any, unknown>,
|
stream: AsyncGenerator<StreamEvent, unknown, unknown>,
|
||||||
emitter: eventEmitter,
|
emitter: eventEmitter,
|
||||||
) => {
|
) => {
|
||||||
for await (const event of stream) {
|
for await (const event of stream) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ const basicWolframAlphaSearchResponsePrompt = `
|
||||||
const strParser = new StringOutputParser();
|
const strParser = new StringOutputParser();
|
||||||
|
|
||||||
const handleStream = async (
|
const handleStream = async (
|
||||||
stream: AsyncGenerator<StreamEvent, any, unknown>,
|
stream: AsyncGenerator<StreamEvent, unknown, unknown>,
|
||||||
emitter: eventEmitter,
|
emitter: eventEmitter,
|
||||||
) => {
|
) => {
|
||||||
for await (const event of stream) {
|
for await (const event of stream) {
|
||||||
|
@ -153,7 +153,7 @@ const createBasicWolframAlphaSearchAnsweringChain = (llm: BaseChatModel) => {
|
||||||
chat_history: formatChatHistoryAsString(input.chat_history),
|
chat_history: formatChatHistoryAsString(input.chat_history),
|
||||||
}),
|
}),
|
||||||
basicWolframAlphaSearchRetrieverChain
|
basicWolframAlphaSearchRetrieverChain
|
||||||
.pipe(({ query, docs }) => {
|
.pipe(({ docs }) => {
|
||||||
return docs;
|
return docs;
|
||||||
})
|
})
|
||||||
.withConfig({
|
.withConfig({
|
||||||
|
@ -210,7 +210,8 @@ const handleWolframAlphaSearch = (
|
||||||
message: string,
|
message: string,
|
||||||
history: BaseMessage[],
|
history: BaseMessage[],
|
||||||
llm: BaseChatModel,
|
llm: BaseChatModel,
|
||||||
embeddings: Embeddings,
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_embeddings: Embeddings,
|
||||||
) => {
|
) => {
|
||||||
const emitter = basicWolframAlphaSearch(message, history, llm);
|
const emitter = basicWolframAlphaSearch(message, history, llm);
|
||||||
return emitter;
|
return emitter;
|
||||||
|
|
|
@ -19,7 +19,7 @@ Since you are a writing assistant, you would not perform web searches. If you th
|
||||||
const strParser = new StringOutputParser();
|
const strParser = new StringOutputParser();
|
||||||
|
|
||||||
const handleStream = async (
|
const handleStream = async (
|
||||||
stream: AsyncGenerator<StreamEvent, any, unknown>,
|
stream: AsyncGenerator<StreamEvent, unknown, unknown>,
|
||||||
emitter: eventEmitter,
|
emitter: eventEmitter,
|
||||||
) => {
|
) => {
|
||||||
for await (const event of stream) {
|
for await (const event of stream) {
|
||||||
|
@ -59,7 +59,8 @@ const handleWritingAssistant = (
|
||||||
query: string,
|
query: string,
|
||||||
history: BaseMessage[],
|
history: BaseMessage[],
|
||||||
llm: BaseChatModel,
|
llm: BaseChatModel,
|
||||||
embeddings: Embeddings,
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_embeddings: Embeddings,
|
||||||
) => {
|
) => {
|
||||||
const emitter = new eventEmitter();
|
const emitter = new eventEmitter();
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ const basicYoutubeSearchResponsePrompt = `
|
||||||
const strParser = new StringOutputParser();
|
const strParser = new StringOutputParser();
|
||||||
|
|
||||||
const handleStream = async (
|
const handleStream = async (
|
||||||
stream: AsyncGenerator<StreamEvent, any, unknown>,
|
stream: AsyncGenerator<StreamEvent, unknown, unknown>,
|
||||||
emitter: eventEmitter,
|
emitter: eventEmitter,
|
||||||
) => {
|
) => {
|
||||||
for await (const event of stream) {
|
for await (const event of stream) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ type RecursivePartial<T> = {
|
||||||
const loadConfig = () =>
|
const loadConfig = () =>
|
||||||
toml.parse(
|
toml.parse(
|
||||||
fs.readFileSync(path.join(__dirname, `../${configFileName}`), 'utf-8'),
|
fs.readFileSync(path.join(__dirname, `../${configFileName}`), 'utf-8'),
|
||||||
) as any as Config;
|
) as unknown as Config;
|
||||||
|
|
||||||
export const getPort = () => loadConfig().GENERAL.PORT;
|
export const getPort = () => loadConfig().GENERAL.PORT;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ export class HuggingFaceTransformersEmbeddings
|
||||||
|
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
private pipelinePromise: Promise<any>;
|
private pipelinePromise: Promise<any>;
|
||||||
|
|
||||||
constructor(fields?: Partial<HuggingFaceTransformersEmbeddingsParams>) {
|
constructor(fields?: Partial<HuggingFaceTransformersEmbeddingsParams>) {
|
||||||
|
|
|
@ -102,6 +102,7 @@ export const getAvailableChatModelProviders = async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const { models: ollamaModels } = (await response.json()) as any;
|
const { models: ollamaModels } = (await response.json()) as any;
|
||||||
|
|
||||||
models['ollama'] = ollamaModels.reduce((acc, model) => {
|
models['ollama'] = ollamaModels.reduce((acc, model) => {
|
||||||
|
@ -153,6 +154,7 @@ export const getAvailableEmbeddingModelProviders = async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const { models: ollamaModels } = (await response.json()) as any;
|
const { models: ollamaModels } = (await response.json()) as any;
|
||||||
|
|
||||||
models['ollama'] = ollamaModels.reduce((acc, model) => {
|
models['ollama'] = ollamaModels.reduce((acc, model) => {
|
||||||
|
|
|
@ -9,9 +9,10 @@ const router = express.Router();
|
||||||
|
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
let { query, chat_history, chat_model_provider, chat_model } = req.body;
|
const { query, chat_history: raw_chat_history, chat_model_provider, chat_model } = req.body;
|
||||||
|
|
||||||
chat_history = chat_history.map((msg: any) => {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const chat_history = raw_chat_history.map((msg: any) => {
|
||||||
if (msg.role === 'user') {
|
if (msg.role === 'user') {
|
||||||
return new HumanMessage(msg.content);
|
return new HumanMessage(msg.content);
|
||||||
} else if (msg.role === 'assistant') {
|
} else if (msg.role === 'assistant') {
|
||||||
|
|
|
@ -9,9 +9,10 @@ const router = express.Router();
|
||||||
|
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
let { chat_history, chat_model, chat_model_provider } = req.body;
|
const { chat_history: raw_chat_history, chat_model, chat_model_provider } = req.body;
|
||||||
|
|
||||||
chat_history = chat_history.map((msg: any) => {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const chat_history = raw_chat_history.map((msg: any) => {
|
||||||
if (msg.role === 'user') {
|
if (msg.role === 'user') {
|
||||||
return new HumanMessage(msg.content);
|
return new HumanMessage(msg.content);
|
||||||
} else if (msg.role === 'assistant') {
|
} else if (msg.role === 'assistant') {
|
||||||
|
|
|
@ -9,9 +9,10 @@ const router = express.Router();
|
||||||
|
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
let { query, chat_history, chat_model_provider, chat_model } = req.body;
|
const { query, chat_history: raw_chat_history, chat_model_provider, chat_model } = req.body;
|
||||||
|
|
||||||
chat_history = chat_history.map((msg: any) => {
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const chat_history = raw_chat_history.map((msg: any) => {
|
||||||
if (msg.role === 'user') {
|
if (msg.role === 'user') {
|
||||||
return new HumanMessage(msg.content);
|
return new HumanMessage(msg.content);
|
||||||
} else if (msg.role === 'assistant') {
|
} else if (msg.role === 'assistant') {
|
||||||
|
|
2
ui/.eslintignore
Normal file
2
ui/.eslintignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"extends": "next/core-web-vitals"
|
"overrides": []
|
||||||
}
|
}
|
||||||
|
|
5
ui/.prettierrc
Normal file
5
ui/.prettierrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"endOfLine": "auto",
|
||||||
|
"trailingComma": "all",
|
||||||
|
"arrowParens": "avoid"
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
/** @type {import("prettier").Config} */
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
printWidth: 80,
|
|
||||||
trailingComma: 'all',
|
|
||||||
endOfLine: 'auto',
|
|
||||||
singleQuote: true,
|
|
||||||
tabWidth: 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = config;
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import DeleteChat from '@/components/DeleteChat';
|
import DeleteChat from '@/components/DeleteChat';
|
||||||
import { formatTimeDifference } from '@/lib/utils';
|
import { formatTimeDifference } from '@/lib/utils';
|
||||||
import { BookOpenText, ClockIcon, Delete, ScanEye } from 'lucide-react';
|
import { BookOpenText, ClockIcon } from 'lucide-react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
|
Loading…
Add table
Reference in a new issue