feat(app): lint & beautify

This commit is contained in:
ItzCrazyKns
2025-09-25 18:57:21 +05:30
parent 5f18fc1d22
commit 984163bbbc
6 changed files with 36 additions and 22 deletions

View File

@@ -6,14 +6,18 @@ export const messages = sqliteTable('messages', {
id: integer('id').primaryKey(), id: integer('id').primaryKey(),
role: text('type', { enum: ['assistant', 'user', 'source'] }).notNull(), role: text('type', { enum: ['assistant', 'user', 'source'] }).notNull(),
chatId: text('chatId').notNull(), chatId: text('chatId').notNull(),
createdAt: text('createdAt').notNull().default(sql`CURRENT_TIMESTAMP`), createdAt: text('createdAt')
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
messageId: text('messageId').notNull(), messageId: text('messageId').notNull(),
content: text('content'), content: text('content'),
sources: text('sources', { sources: text('sources', {
mode: 'json', mode: 'json',
}).$type<Document[]>().default(sql`'[]'`), })
.$type<Document[]>()
.default(sql`'[]'`),
}); });
interface File { interface File {

View File

@@ -694,7 +694,11 @@ export const ChatProvider = ({
(msg, i) => i > userMessageIndex && msg.role === 'suggestion', (msg, i) => i > userMessageIndex && msg.role === 'suggestion',
); );
if (sourceMessage && sourceMessage.sources.length > 0 && suggestionMessageIndex == -1) { if (
sourceMessage &&
sourceMessage.sources.length > 0 &&
suggestionMessageIndex == -1
) {
const suggestions = await getSuggestions(messagesRef.current); const suggestions = await getSuggestions(messagesRef.current);
setMessages((prev) => { setMessages((prev) => {
return [ return [

View File

@@ -1,7 +1,10 @@
import { webSearchResponsePrompt, webSearchRetrieverFewShots, webSearchRetrieverPrompt } from './webSearch'; import {
webSearchResponsePrompt,
webSearchRetrieverFewShots,
webSearchRetrieverPrompt,
} from './webSearch';
import { writingAssistantPrompt } from './writingAssistant'; import { writingAssistantPrompt } from './writingAssistant';
export default { export default {
webSearchResponsePrompt, webSearchResponsePrompt,
webSearchRetrieverPrompt, webSearchRetrieverPrompt,

View File

@@ -1,4 +1,4 @@
import { BaseMessageLike } from "@langchain/core/messages"; import { BaseMessageLike } from '@langchain/core/messages';
export const webSearchRetrieverPrompt = ` export const webSearchRetrieverPrompt = `
You are an AI question rephraser. You will be given a conversation and a follow-up question, you will have to rephrase the follow up question so it is a standalone question and can be used by another LLM to search the web for information to answer it. You are an AI question rephraser. You will be given a conversation and a follow-up question, you will have to rephrase the follow up question so it is a standalone question and can be used by another LLM to search the web for information to answer it.
@@ -16,13 +16,13 @@ export const webSearchRetrieverFewShots: BaseMessageLike[] = [
</conversation> </conversation>
<query> <query>
What is the capital of France What is the capital of France
</query>` </query>`,
], ],
[ [
'assistant', 'assistant',
`<question> `<question>
Capital of france Capital of france
</question>` </question>`,
], ],
[ [
'user', 'user',
@@ -30,13 +30,13 @@ Capital of france
</conversation> </conversation>
<query> <query>
Hi, how are you? Hi, how are you?
</query>` </query>`,
], ],
[ [
'assistant', 'assistant',
`<question> `<question>
not_needed not_needed
</question>` </question>`,
], ],
[ [
'user', 'user',
@@ -44,13 +44,13 @@ not_needed
</conversation> </conversation>
<query> <query>
What is Docker? What is Docker?
</query>` </query>`,
], ],
[ [
'assistant', 'assistant',
`<question> `<question>
What is Docker What is Docker
</question>` </question>`,
], ],
[ [
'user', 'user',
@@ -58,7 +58,7 @@ What is Docker
</conversation> </conversation>
<query> <query>
Can you tell me what is X from https://example.com Can you tell me what is X from https://example.com
</query>` </query>`,
], ],
[ [
'assistant', 'assistant',
@@ -67,7 +67,7 @@ What is X?
</question> </question>
<links> <links>
https://example.com https://example.com
</links>` </links>`,
], ],
[ [
'user', 'user',
@@ -75,7 +75,7 @@ https://example.com
</conversation> </conversation>
<query> <query>
Summarize the content from https://example.com Summarize the content from https://example.com
</query>` </query>`,
], ],
[ [
'assistant', 'assistant',
@@ -84,8 +84,8 @@ summarize
</question> </question>
<links> <links>
https://example.com https://example.com
</links>` </links>`,
] ],
]; ];
export const webSearchResponsePrompt = ` export const webSearchResponsePrompt = `

View File

@@ -67,7 +67,9 @@ class MetaSearchAgent implements MetaSearchAgentType {
ChatPromptTemplate.fromMessages([ ChatPromptTemplate.fromMessages([
['system', this.config.queryGeneratorPrompt], ['system', this.config.queryGeneratorPrompt],
...this.config.queryGeneratorFewShots, ...this.config.queryGeneratorFewShots,
['user', ` [
'user',
`
<conversation> <conversation>
{chat_history} {chat_history}
</conversation> </conversation>
@@ -75,7 +77,8 @@ class MetaSearchAgent implements MetaSearchAgentType {
<query> <query>
{query} {query}
</query> </query>
`] `,
],
]), ]),
llm, llm,
this.strParser, this.strParser,
@@ -89,7 +92,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
}); });
const links = await linksOutputParser.parse(input); const links = await linksOutputParser.parse(input);
let question = await questionOutputParser.parse(input) ?? input; let question = (await questionOutputParser.parse(input)) ?? input;
if (question === 'not_needed') { if (question === 'not_needed') {
return { query: '', docs: [] }; return { query: '', docs: [] };