FIX: avoid semicolons at the end of queries for SQL Helper (#268)
This makes it easier to cut and paste snippets it is producing Also fine tune the prompt in an attempt to hone gpt 3.5 which is very finicky
This commit is contained in:
parent
6add06af8f
commit
b06380d9fa
|
@ -48,7 +48,7 @@ module DiscourseAi::AiBot::Commands
|
||||||
schema_info =
|
schema_info =
|
||||||
table_info.map { |table_name, columns| "#{table_name}(#{columns.join(",")})" }.join("\n")
|
table_info.map { |table_name, columns| "#{table_name}(#{columns.join(",")})" }.join("\n")
|
||||||
|
|
||||||
{ tables: @tables, schema_info: schema_info }
|
{ schema_info: schema_info, tables: tables }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,9 +38,18 @@ module DiscourseAi
|
||||||
def system_prompt
|
def system_prompt
|
||||||
<<~PROMPT
|
<<~PROMPT
|
||||||
You are a PostgreSQL expert.
|
You are a PostgreSQL expert.
|
||||||
You understand and generate Discourse Markdown but specialize in creating queries.
|
- You understand and generate Discourse Markdown but specialize in creating queries.
|
||||||
You live in a Discourse Forum Message.
|
- You live in a Discourse Forum Message.
|
||||||
The schema in your training set MAY be out of date.
|
- The schema in your training set MAY be out of date.
|
||||||
|
- When generating SQL NEVER end SQL samples with a semicolon (;).
|
||||||
|
- When generating SQL always use ```sql markdown code blocks.
|
||||||
|
- Always format SQL in a highly readable format.
|
||||||
|
|
||||||
|
Eg:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
select 1 from table
|
||||||
|
```
|
||||||
|
|
||||||
The user_actions tables stores likes (action_type 1).
|
The user_actions tables stores likes (action_type 1).
|
||||||
the topics table stores private/personal messages it uses archetype private_message for them.
|
the topics table stores private/personal messages it uses archetype private_message for them.
|
||||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe DiscourseAi::AiBot::Commands::DbSchemaCommand do
|
||||||
expect(result[:schema_info]).to include("posts")
|
expect(result[:schema_info]).to include("posts")
|
||||||
expect(result[:schema_info]).to include("topics")
|
expect(result[:schema_info]).to include("topics")
|
||||||
|
|
||||||
expect(result[:tables]).to eq(%w[posts topics])
|
expect(result[:tables]).to eq("posts,topics")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue