diff --git a/components/ChatView/MessageView.tsx b/components/ChatView/MessageView.tsx
index 574dc8b..888a38f 100644
--- a/components/ChatView/MessageView.tsx
+++ b/components/ChatView/MessageView.tsx
@@ -54,6 +54,9 @@ const MessageView = (props: Props) => {
);
},
+ code({ children }) {
+ return `{children}`
;
+ },
}}
>
{message.content}
diff --git a/lib/connectors/postgres/index.ts b/lib/connectors/postgres/index.ts
index 2712438..03c845d 100644
--- a/lib/connectors/postgres/index.ts
+++ b/lib/connectors/postgres/index.ts
@@ -31,6 +31,7 @@ const getDatabases = async (connection: Connection): Promise => {
const client = newPostgresClient(connection);
await client.connect();
await client.end();
+ // Because PostgreSQL needs to specify a database to connect to, we use the default database.
return [connection.database!];
};
@@ -55,17 +56,19 @@ const getTableStructure = async (connection: Connection, _: string, tableName: s
const client = newPostgresClient(connection);
await client.connect();
const { rows } = await client.query(
- `SELECT column_name, data_type, is_nullable, column_default FROM information_schema.columns WHERE table_schema='public' AND table_name=$1;`,
+ `SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_schema='public' AND table_name=$1;`,
[tableName]
);
await client.end();
const columnList = [];
// TODO(steven): transform it to standard schema string.
for (const row of rows) {
- columnList.push(`\`${row["column_name"]}\` ${row["data_type"]} ${String(row["is_nullable"]).toUpperCase()} ${row["column_default"]},`);
+ columnList.push(
+ `${row["column_name"]} ${row["data_type"].toUpperCase()} ${String(row["is_nullable"]).toUpperCase() === "NO" ? "NOT NULL" : ""}`
+ );
}
return `CREATE TABLE \`${tableName}\` (
- ${columnList.join("\n")}
+ ${columnList.join(",\n")}
);`;
};
diff --git a/store/assistant.ts b/store/assistant.ts
index fca4752..cd3043c 100644
--- a/store/assistant.ts
+++ b/store/assistant.ts
@@ -20,7 +20,7 @@ export const getAssistantById = (id: Id) => {
export const getPromptGeneratorOfAssistant = (assistant: User) => {
if (assistant.id === "sql-assistant") {
return (schema: string) =>
- `Remember that you are an expert in SQL. And you know everything about databases. You will answer some questions about databases with a database schema like "${schema}".`;
+ `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.`;
}
return () => "";
};