Skip to content

Commit c97ba15

Browse files
renamed Context() -> AskerContext(); added more detailed detailed examples to the prompt
1 parent 0d8cd1e commit c97ba15

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

src/dbally/context/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from inspect import isclass
2-
from typing import Any, Optional, Sequence, List, Tuple, Type, Union
2+
from typing import Any, List, Optional, Sequence, Tuple, Type, Union
33

44
import typing_extensions as type_ext
55

src/dbally/context/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BaseCallerContext(ABC):
1717
a class implementing this interface, selected based on the filter method signature (type hints).
1818
"""
1919

20-
_alias: str = "Context"
20+
_alias: str = "AskerContext"
2121

2222
@classmethod
2323
def select_context(cls, contexts: Iterable[CustomContext]) -> Self:

src/dbally/iql_generator/prompt.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ def __init__(
7474
"You MUST use only these methods:\n"
7575
"\n{filters}\n"
7676
"It is VERY IMPORTANT not to use methods other than those listed above."
77-
"Finally, if a called function argument value is not directly specified in the query but instead requires knowledge of some additional context, than substitute that argument value by: Context()."
78-
'The typical input phrase referencing some additional context contains the word "my" or similar phrasing, e.g. "my position name", "my company valuation".'
77+
"Finally, if a called function argument value is not directly specified in the query but instead requires some additional execution context, than substitute that argument value by: AskerContext()."
78+
'The typical input phrase suggesting that the additional execution context need to be referenced contains words like: "I", "my", "mine", "current", "the" etc..'
79+
'For example: "my position name", "my company valuation", "current day", "the ongoing project".'
7980
"In that case, the part of the output will look like this:"
80-
"filter4(Context())"
81+
"filter4(AskerContext())"
8182
"""If you DON'T KNOW HOW TO ANSWER DON'T SAY \"\", SAY: `UNSUPPORTED QUERY` INSTEAD! """
8283
"This is CRUCIAL, otherwise the system will crash. "
8384
),

tests/unit/iql/test_iql_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def test_iql_parser():
2626
custom_context2 = AnotherTestCustomContext(some_field="aaa")
2727

2828
parsed = await IQLQuery.parse(
29-
"not (filter_by_name(['John', 'Anne']) and filter_by_city(Context()) and filter_by_company('deepsense.ai'))",
29+
"not (filter_by_name(['John', 'Anne']) and filter_by_city(AskerContext()) and filter_by_company('deepsense.ai'))",
3030
allowed_functions=[
3131
ExposedFunction(
3232
name="filter_by_name", description="", parameters=[MethodParamWithTyping(name="name", type=List[str])]

tests/unit/test_iql_format.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ async def test_iql_prompt_format_default() -> None:
2323
"You MUST use only these methods:\n"
2424
"\n\n"
2525
"It is VERY IMPORTANT not to use methods other than those listed above."
26-
"Finally, if a called function argument value is not directly specified in the query but instead requires knowledge of some additional context, than substitute that argument value by: Context()."
27-
'The typical input phrase referencing some additional context contains the word "my" or similar phrasing, e.g. "my position name", "my company valuation".'
26+
"Finally, if a called function argument value is not directly specified in the query but instead requires some additional execution context, than substitute that argument value by: AskerContext()."
27+
'The typical input phrase suggesting that the additional execution context need to be referenced contains words like: "I", "my", "mine", "current", "the" etc..'
28+
'For example: "my position name", "my company valuation", "current day", "the ongoing project".'
2829
"In that case, the part of the output will look like this:"
29-
"filter4(Context())"
30+
"filter4(AskerContext())"
3031
"""If you DON'T KNOW HOW TO ANSWER DON'T SAY \"\", SAY: `UNSUPPORTED QUERY` INSTEAD! """
3132
"This is CRUCIAL, otherwise the system will crash. ",
3233
"is_example": False,
@@ -57,10 +58,11 @@ async def test_iql_prompt_format_few_shots_injected() -> None:
5758
"You MUST use only these methods:\n"
5859
"\n\n"
5960
"It is VERY IMPORTANT not to use methods other than those listed above."
60-
"Finally, if a called function argument value is not directly specified in the query but instead requires knowledge of some additional context, than substitute that argument value by: Context()."
61-
'The typical input phrase referencing some additional context contains the word "my" or similar phrasing, e.g. "my position name", "my company valuation".'
61+
"Finally, if a called function argument value is not directly specified in the query but instead requires some additional execution context, than substitute that argument value by: AskerContext()."
62+
'The typical input phrase suggesting that the additional execution context need to be referenced contains words like: "I", "my", "mine", "current", "the" etc..'
63+
'For example: "my position name", "my company valuation", "current day", "the ongoing project".'
6264
"In that case, the part of the output will look like this:"
63-
"filter4(Context())"
65+
"filter4(AskerContext())"
6466
"""If you DON'T KNOW HOW TO ANSWER DON'T SAY \"\", SAY: `UNSUPPORTED QUERY` INSTEAD! """
6567
"This is CRUCIAL, otherwise the system will crash. ",
6668
"is_example": False,

tests/unit/views/test_sqlalchemy_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def test_filter_sql_generation() -> None:
6060
mock_connection = sqlalchemy.create_mock_engine("postgresql://", executor=None)
6161
mock_view = MockSqlAlchemyView(mock_connection.engine)
6262
query = await IQLQuery.parse(
63-
'method_foo(1) and method_bar("London", 2020) and method_baz(BaseCallerContext())',
63+
'method_foo(1) and method_bar("London", 2020) and method_baz(AskerContext())',
6464
allowed_functions=mock_view.list_filters(),
6565
contexts=[SomeTestContext(age=69)],
6666
)

0 commit comments

Comments
 (0)