From f4618fd15d293f665719ebecf2751e9c7e7b0140 Mon Sep 17 00:00:00 2001 From: "Aivin V. Solatorio" Date: Mon, 19 Jun 2023 16:17:43 -0400 Subject: [PATCH] Improve db prompt with proper dialect and release v0.0.4 (#18) * Include the db dialect in the prompt to improve syntax Signed-off-by: Aivin V. Solatorio * Bump version for release v0.0.4 Signed-off-by: Aivin V. Solatorio --------- Signed-off-by: Aivin V. Solatorio --- llm4data/__init__.py | 2 +- llm4data/prompts/indicators/wdi.py | 7 +++++-- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/llm4data/__init__.py b/llm4data/__init__.py index 505b95a..7f8faed 100644 --- a/llm4data/__init__.py +++ b/llm4data/__init__.py @@ -7,7 +7,7 @@ # Do this before importing any other modules. dotenv.load_dotenv() -__version__ = "0.0.3" +__version__ = "0.0.4" indicator2name = dict( wdi=json.load((Path(__file__).parent / "wdi2name.json").open("r")) diff --git a/llm4data/prompts/indicators/wdi.py b/llm4data/prompts/indicators/wdi.py index 99a932b..e86e2ca 100644 --- a/llm4data/prompts/indicators/wdi.py +++ b/llm4data/prompts/indicators/wdi.py @@ -5,6 +5,7 @@ from urllib.parse import urlparse from openai_tools.parser import parse_misparsed from llm4data.prompts.base import DatedPrompt, APIPrompt +from llm4data import configs class WDISQLPrompt(DatedPrompt): @@ -18,8 +19,10 @@ def __init__(self, input_variables=None, template=None): "I have a database containing data from the WDI indicators." " Write an SQL query for the prompt: ```{{{{user_content}}}}```\n\n" "table: {table}\n" - "fields: {fields}\n\n" - "Only the indicator can parameterized and you must fill the rest." + "fields: {fields}\n" + f"dialect: {configs.WDIDBConfig.engine}\n\n" + "Pay attention to the dialect when writing the query.\n\n" + "Only the indicator can be parameterized and you must fill the rest." " Use the convention `:indicator` and not `?`." " Use country_iso3 when querying, use country in the result.\n\n" "Use the last 10 years if no year is specified." diff --git a/pyproject.toml b/pyproject.toml index 0c17c6e..67516d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "llm4data" -version = "0.0.3" +version = "0.0.4" description = "LLM4Data is a Python library designed to facilitate the application of large language models (LLMs) and artificial intelligence for development data and knowledge discovery." authors = ["Aivin V. Solatorio "] readme = "README.md"