Skip to content

Commit efe212f

Browse files
Merge branch 'main' (which includes a large refactor by Michal) into jc/issue-54-request-context
2 parents d523bf7 + 6510bd8 commit efe212f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1482
-882
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ omit =
1212
exclude_lines =
1313
pragma: no cover
1414
if __name__ == .__main__.
15+
\.\.\.
1516
show_missing = True

.github/ISSUE_TEMPLATE/01_feature_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 🚀 Feature Request
22
description: Submit a proposal/request for a new db-ally feature.
33
title: "feat: "
4-
labels: ["enhancement"]
4+
labels: ["feature"]
55
body:
66
- type: markdown
77
attributes:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# <h1 align="center">db-ally</h1>
1+
# <h1 align="center">🦮 db-ally</h1>
22

33
<p align="center">
44
<em>Efficient, consistent and secure library for querying structured data with natural language</em>

benchmark/dbally_benchmark/e2e_benchmark.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import dbally
2424
from dbally.collection import Collection
2525
from dbally.collection.exceptions import NoViewFoundError
26-
from dbally.iql_generator.iql_prompt_template import UnsupportedQueryError, default_iql_template
26+
from dbally.iql_generator.prompt import IQL_GENERATION_TEMPLATE, UnsupportedQueryError
2727
from dbally.llms.litellm import LiteLLM
28-
from dbally.view_selection.view_selector_prompt_template import default_view_selector_template
28+
from dbally.view_selection.prompt import VIEW_SELECTION_TEMPLATE
2929

3030

3131
async def _run_dbally_for_single_example(example: BIRDExample, collection: Collection) -> Text2SQLResult:
@@ -126,9 +126,9 @@ async def evaluate(cfg: DictConfig) -> Any:
126126
logger.info(f"db-ally predictions saved under directory: {output_dir}")
127127

128128
if run:
129-
run["config/iql_prompt_template"] = stringify_unsupported(default_iql_template.chat)
130-
run["config/view_selection_prompt_template"] = stringify_unsupported(default_view_selector_template.chat)
131-
run["config/iql_prompt_template"] = stringify_unsupported(default_iql_template)
129+
run["config/iql_prompt_template"] = stringify_unsupported(IQL_GENERATION_TEMPLATE.chat)
130+
run["config/view_selection_prompt_template"] = stringify_unsupported(VIEW_SELECTION_TEMPLATE.chat)
131+
run["config/iql_prompt_template"] = stringify_unsupported(IQL_GENERATION_TEMPLATE)
132132
run[f"evaluation/{metrics_file_name}"].upload((output_dir / metrics_file_name).as_posix())
133133
run[f"evaluation/{results_file_name}"].upload((output_dir / results_file_name).as_posix())
134134
run["evaluation/metrics"] = stringify_unsupported(metrics)

benchmark/dbally_benchmark/iql_benchmark.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from dbally.audit.event_tracker import EventTracker
2323
from dbally.iql_generator.iql_generator import IQLGenerator
24-
from dbally.iql_generator.iql_prompt_template import UnsupportedQueryError, default_iql_template
24+
from dbally.iql_generator.prompt import IQL_GENERATION_TEMPLATE, UnsupportedQueryError
2525
from dbally.llms.litellm import LiteLLM
2626
from dbally.views.structured import BaseStructuredView
2727

@@ -33,13 +33,15 @@ async def _run_iql_for_single_example(
3333
event_tracker = EventTracker()
3434

3535
try:
36-
iql_filters, _ = await iql_generator.generate_iql(
37-
question=example.question, filters=filter_list, event_tracker=event_tracker
36+
iql_filters = await iql_generator.generate_iql(
37+
question=example.question,
38+
filters=filter_list,
39+
event_tracker=event_tracker,
3840
)
3941
except UnsupportedQueryError:
4042
return IQLResult(question=example.question, iql_filters="UNSUPPORTED_QUERY", exception_raised=True)
4143

42-
return IQLResult(question=example.question, iql_filters=iql_filters, exception_raised=False)
44+
return IQLResult(question=example.question, iql_filters=str(iql_filters), exception_raised=False)
4345

4446

4547
async def run_iql_for_dataset(
@@ -139,7 +141,7 @@ async def evaluate(cfg: DictConfig) -> Any:
139141
logger.info(f"IQL predictions saved under directory: {output_dir}")
140142

141143
if run:
142-
run["config/iql_prompt_template"] = stringify_unsupported(default_iql_template.chat)
144+
run["config/iql_prompt_template"] = stringify_unsupported(IQL_GENERATION_TEMPLATE.chat)
143145
run[f"evaluation/{metrics_file_name}"].upload((output_dir / metrics_file_name).as_posix())
144146
run[f"evaluation/{results_file_name}"].upload((output_dir / results_file_name).as_posix())
145147
run["evaluation/metrics"] = stringify_unsupported(metrics)

benchmark/dbally_benchmark/text2sql/prompt_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dbally.prompts import PromptTemplate
1+
from dbally.prompt import PromptTemplate
22

33
TEXT2SQL_PROMPT_TEMPLATE = PromptTemplate(
44
(

docs/about/roadmap.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ Below you can find a list of planned features and integrations.
1010
## Planned Features
1111

1212
- [ ] **Support analytical queries**: support for exposing operations beyond filtering.
13-
- [ ] **Few-shot prompting configuration**: allow users to configure the few-shot prompting in View definition to
13+
- [x] **Few-shot prompting configuration**: allow users to configure the few-shot prompting in View definition to
1414
improve IQL generation accuracy.
1515
- [ ] **Request contextualization**: allow to provide extra context for db-ally runs, such as user asking the question.
1616
- [X] **OpenAI Assistants API adapter**: allow to embed db-ally into OpenAI's Assistants API to easily extend the
1717
capabilities of the assistant.
1818
- [ ] **Langchain adapter**: allow to embed db-ally into Langchain applications.
1919

20-
2120
## Integrations
2221

2322
Being agnostic to the underlying technology is one of the main goals of db-ally.

docs/assets/guide_dog_lg.png

15.2 KB
Loading

docs/assets/guide_dog_sm.png

2.47 KB
Loading

docs/how-to/create_custom_event_handler.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ In this guide we will implement a simple [Event Handler](../reference/event_hand
1010
First, we need to create a new class that inherits from `EventHandler` and implements the all abstract methods.
1111

1212
```python
13-
from dbally.audit import EventHandler
14-
from dbally.data_models.audit import RequestStart, RequestEnd
13+
from dbally.audit import EventHandler, RequestStart, RequestEnd
1514

1615
class FileEventHandler(EventHandler):
1716

0 commit comments

Comments
 (0)