mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-29 02:04:48 +08:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { first } from "lodash-es";
|
|
import { Id, User } from "@/types";
|
|
|
|
// Assistant is a special user.
|
|
export const assistantList: User[] = [
|
|
{
|
|
id: "sql-assistant",
|
|
name: "SQL Chat",
|
|
description: "🤖️ I'm an expert in SQL. I can answer your questions about databases and SQL.",
|
|
avatar: "",
|
|
},
|
|
];
|
|
|
|
export const getAssistantById = (id: Id) => {
|
|
const user = assistantList.find((user) => user.id === id);
|
|
return user || (first(assistantList) as User);
|
|
};
|
|
|
|
// getPromptOfAssistant define the special prompt for each assistant.
|
|
export const getPromptGeneratorOfAssistant = (assistant: User) => {
|
|
const basicPrompt = `Please follow the instructions to answer the questions.
|
|
1. Set the language to the markdown code block for each code block. For example, \`SELECT * FROM table\` is SQL.
|
|
`;
|
|
if (assistant.id === "sql-assistant") {
|
|
return (schema: string) =>
|
|
`This is my database schema"${schema}". You will see the tables and columns in the database. And please answer the following questions about the database.\n${basicPrompt}`;
|
|
}
|
|
return () => `\n${basicPrompt}`;
|
|
};
|