Skip to content

Commit e488635

Browse files
committed
Don't ignore baml_client
1 parent ac2cdcb commit e488635

File tree

14 files changed

+1022
-1
lines changed

14 files changed

+1022
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ wheels/
1010
.venv
1111

1212
# Local stuff
13-
/src/taskgist/baml_client
13+
#/src/taskgist/baml_client
1414
/knowledge-base
1515
/task.md
1616
.*_repo_snapshot.md
17+
*.code-workspace

src/taskgist/baml_client/__init__.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
###############################################################################
2+
#
3+
# Welcome to Baml! To use this generated code, please run the following:
4+
#
5+
# $ pip install baml-py
6+
#
7+
###############################################################################
8+
9+
# This file was generated by BAML: please do not edit it. Instead, edit the
10+
# BAML files and re-generate this code.
11+
#
12+
# ruff: noqa: E501,F401
13+
# flake8: noqa: E501,F401
14+
# pylint: disable=unused-import,line-too-long
15+
# fmt: off
16+
__version__ = "0.89.0"
17+
18+
try:
19+
from baml_py.safe_import import EnsureBamlPyImport
20+
except ImportError:
21+
raise ImportError(f"""Update to baml-py required.
22+
Version of baml_client generator (see generators.baml): {__version__}
23+
24+
Please upgrade baml-py to version "{__version__}".
25+
26+
$ pip install baml-py=={__version__}
27+
$ uv add baml-py=={__version__}
28+
29+
If nothing else works, please ask for help:
30+
31+
https://github.com/boundaryml/baml/issues
32+
https://boundaryml.com/discord
33+
""") from None
34+
35+
with EnsureBamlPyImport(__version__) as e:
36+
e.raise_if_incompatible_version(__version__)
37+
38+
from . import types
39+
from . import tracing
40+
from . import partial_types
41+
from . import config
42+
from .config import reset_baml_env_vars
43+
44+
from .async_client import b
45+
46+
47+
__all__ = [
48+
"b",
49+
"partial_types",
50+
"tracing",
51+
"types",
52+
"reset_baml_env_vars",
53+
"config",
54+
]
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
###############################################################################
2+
#
3+
# Welcome to Baml! To use this generated code, please run the following:
4+
#
5+
# $ pip install baml-py
6+
#
7+
###############################################################################
8+
9+
# This file was generated by BAML: please do not edit it. Instead, edit the
10+
# BAML files and re-generate this code.
11+
#
12+
# ruff: noqa: E501,F401
13+
# flake8: noqa: E501,F401
14+
# pylint: disable=unused-import,line-too-long
15+
# fmt: off
16+
from typing import Any, Dict, List, Optional, TypeVar, Union, TypedDict, Type, cast
17+
from typing_extensions import NotRequired, Literal
18+
import pprint
19+
20+
import baml_py
21+
from pydantic import BaseModel, ValidationError, create_model
22+
23+
from . import partial_types, types
24+
from .types import Checked, Check
25+
from .type_builder import TypeBuilder
26+
from .parser import LlmResponseParser, LlmStreamParser
27+
from .async_request import AsyncHttpRequest, AsyncHttpStreamRequest
28+
from .globals import DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME
29+
30+
OutputType = TypeVar('OutputType')
31+
32+
33+
# Define the TypedDict with optional parameters having default values
34+
class BamlCallOptions(TypedDict, total=False):
35+
tb: NotRequired[TypeBuilder]
36+
client_registry: NotRequired[baml_py.baml_py.ClientRegistry]
37+
collector: NotRequired[Union[baml_py.baml_py.Collector, List[baml_py.baml_py.Collector]]]
38+
39+
40+
class BamlAsyncClient:
41+
__runtime: baml_py.BamlRuntime
42+
__ctx_manager: baml_py.BamlCtxManager
43+
__stream_client: "BamlStreamClient"
44+
__http_request: "AsyncHttpRequest"
45+
__http_stream_request: "AsyncHttpStreamRequest"
46+
__llm_response_parser: LlmResponseParser
47+
__llm_stream_parser: LlmStreamParser
48+
__baml_options: BamlCallOptions
49+
50+
def __init__(self, runtime: baml_py.BamlRuntime, ctx_manager: baml_py.BamlCtxManager, baml_options: Optional[BamlCallOptions] = None):
51+
self.__runtime = runtime
52+
self.__ctx_manager = ctx_manager
53+
self.__stream_client = BamlStreamClient(self.__runtime, self.__ctx_manager, baml_options)
54+
self.__http_request = AsyncHttpRequest(self.__runtime, self.__ctx_manager)
55+
self.__http_stream_request = AsyncHttpStreamRequest(self.__runtime, self.__ctx_manager)
56+
self.__llm_response_parser = LlmResponseParser(self.__runtime, self.__ctx_manager)
57+
self.__llm_stream_parser = LlmStreamParser(self.__runtime, self.__ctx_manager)
58+
self.__baml_options = baml_options or {}
59+
60+
def with_options(
61+
self,
62+
tb: Optional[TypeBuilder] = None,
63+
client_registry: Optional[baml_py.baml_py.ClientRegistry] = None,
64+
collector: Optional[Union[baml_py.baml_py.Collector, List[baml_py.baml_py.Collector]]] = None,
65+
) -> "BamlAsyncClient":
66+
"""
67+
Returns a new instance of BamlAsyncClient with explicitly typed baml options
68+
for Python 3.8 compatibility.
69+
"""
70+
new_options = self.__baml_options.copy()
71+
72+
# Override if any keyword arguments were provided.
73+
if tb is not None:
74+
new_options["tb"] = tb
75+
if client_registry is not None:
76+
new_options["client_registry"] = client_registry
77+
if collector is not None:
78+
new_options["collector"] = collector
79+
80+
return BamlAsyncClient(self.__runtime, self.__ctx_manager, new_options)
81+
82+
@property
83+
def stream(self):
84+
return self.__stream_client
85+
86+
@property
87+
def request(self):
88+
return self.__http_request
89+
90+
@property
91+
def stream_request(self):
92+
return self.__http_stream_request
93+
94+
@property
95+
def parse(self):
96+
return self.__llm_response_parser
97+
98+
@property
99+
def parse_stream(self):
100+
return self.__llm_stream_parser
101+
102+
103+
async def ExtractKeywords(
104+
self,
105+
taskDescription: str,
106+
baml_options: BamlCallOptions = {},
107+
) -> types.KeywordPhrase:
108+
options: BamlCallOptions = {**self.__baml_options, **(baml_options or {})}
109+
110+
__tb__ = options.get("tb", None)
111+
if __tb__ is not None:
112+
tb = __tb__._tb # type: ignore (we know how to use this private attribute)
113+
else:
114+
tb = None
115+
__cr__ = options.get("client_registry", None)
116+
collector = options.get("collector", None)
117+
collectors = collector if isinstance(collector, list) else [collector] if collector is not None else []
118+
raw = await self.__runtime.call_function(
119+
"ExtractKeywords",
120+
{
121+
"taskDescription": taskDescription,
122+
},
123+
self.__ctx_manager.get(),
124+
tb,
125+
__cr__,
126+
collectors,
127+
)
128+
return cast(types.KeywordPhrase, raw.cast_to(types, types, partial_types, False))
129+
130+
131+
132+
class BamlStreamClient:
133+
__runtime: baml_py.BamlRuntime
134+
__ctx_manager: baml_py.BamlCtxManager
135+
__baml_options: BamlCallOptions
136+
def __init__(self, runtime: baml_py.BamlRuntime, ctx_manager: baml_py.BamlCtxManager, baml_options: Optional[BamlCallOptions] = None):
137+
self.__runtime = runtime
138+
self.__ctx_manager = ctx_manager
139+
self.__baml_options = baml_options or {}
140+
141+
142+
def ExtractKeywords(
143+
self,
144+
taskDescription: str,
145+
baml_options: BamlCallOptions = {},
146+
) -> baml_py.BamlStream[partial_types.KeywordPhrase, types.KeywordPhrase]:
147+
options: BamlCallOptions = {**self.__baml_options, **(baml_options or {})}
148+
__tb__ = options.get("tb", None)
149+
if __tb__ is not None:
150+
tb = __tb__._tb # type: ignore (we know how to use this private attribute)
151+
else:
152+
tb = None
153+
__cr__ = options.get("client_registry", None)
154+
collector = options.get("collector", None)
155+
collectors = collector if isinstance(collector, list) else [collector] if collector is not None else []
156+
raw = self.__runtime.stream_function(
157+
"ExtractKeywords",
158+
{
159+
"taskDescription": taskDescription,
160+
},
161+
None,
162+
self.__ctx_manager.get(),
163+
tb,
164+
__cr__,
165+
collectors,
166+
)
167+
168+
return baml_py.BamlStream[partial_types.KeywordPhrase, types.KeywordPhrase](
169+
raw,
170+
lambda x: cast(partial_types.KeywordPhrase, x.cast_to(types, types, partial_types, True)),
171+
lambda x: cast(types.KeywordPhrase, x.cast_to(types, types, partial_types, False)),
172+
self.__ctx_manager.get(),
173+
)
174+
175+
176+
177+
b = BamlAsyncClient(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX)
178+
179+
__all__ = ["b"]
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
###############################################################################
2+
#
3+
# Welcome to Baml! To use this generated code, please run the following:
4+
#
5+
# $ pip install baml-py
6+
#
7+
###############################################################################
8+
9+
# This file was generated by BAML: please do not edit it. Instead, edit the
10+
# BAML files and re-generate this code.
11+
#
12+
# ruff: noqa: E501,F401
13+
# flake8: noqa: E501,F401
14+
# pylint: disable=unused-import,line-too-long
15+
# fmt: off
16+
from typing import Any, Dict, List, Optional, Union, TypedDict, Type
17+
from typing_extensions import NotRequired, Literal
18+
19+
import baml_py
20+
21+
from . import types
22+
from .types import Checked, Check
23+
from .type_builder import TypeBuilder
24+
25+
26+
class BamlCallOptions(TypedDict, total=False):
27+
tb: NotRequired[TypeBuilder]
28+
client_registry: NotRequired[baml_py.baml_py.ClientRegistry]
29+
30+
31+
class AsyncHttpRequest:
32+
__runtime: baml_py.BamlRuntime
33+
__ctx_manager: baml_py.BamlCtxManager
34+
35+
def __init__(self, runtime: baml_py.BamlRuntime, ctx_manager: baml_py.BamlCtxManager):
36+
self.__runtime = runtime
37+
self.__ctx_manager = ctx_manager
38+
39+
40+
async def ExtractKeywords(
41+
self,
42+
taskDescription: str,
43+
baml_options: BamlCallOptions = {},
44+
) -> baml_py.HTTPRequest:
45+
__tb__ = baml_options.get("tb", None)
46+
if __tb__ is not None:
47+
tb = __tb__._tb # type: ignore (we know how to use this private attribute)
48+
else:
49+
tb = None
50+
__cr__ = baml_options.get("client_registry", None)
51+
52+
return await self.__runtime.build_request(
53+
"ExtractKeywords",
54+
{
55+
"taskDescription": taskDescription,
56+
},
57+
self.__ctx_manager.get(),
58+
tb,
59+
__cr__,
60+
False,
61+
)
62+
63+
64+
65+
class AsyncHttpStreamRequest:
66+
__runtime: baml_py.BamlRuntime
67+
__ctx_manager: baml_py.BamlCtxManager
68+
69+
def __init__(self, runtime: baml_py.BamlRuntime, ctx_manager: baml_py.BamlCtxManager):
70+
self.__runtime = runtime
71+
self.__ctx_manager = ctx_manager
72+
73+
74+
async def ExtractKeywords(
75+
self,
76+
taskDescription: str,
77+
baml_options: BamlCallOptions = {},
78+
) -> baml_py.HTTPRequest:
79+
__tb__ = baml_options.get("tb", None)
80+
if __tb__ is not None:
81+
tb = __tb__._tb # type: ignore (we know how to use this private attribute)
82+
else:
83+
tb = None
84+
__cr__ = baml_options.get("client_registry", None)
85+
86+
return await self.__runtime.build_request(
87+
"ExtractKeywords",
88+
{
89+
"taskDescription": taskDescription,
90+
},
91+
self.__ctx_manager.get(),
92+
tb,
93+
__cr__,
94+
True,
95+
)
96+
97+
98+
99+
__all__ = ["AsyncHttpRequest", "AsyncHttpStreamRequest"]

src/taskgist/baml_client/config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###############################################################################
2+
#
3+
# Welcome to Baml! To use this generated code, please run the following:
4+
#
5+
# $ pip install baml-py
6+
#
7+
###############################################################################
8+
9+
# This file was generated by BAML: please do not edit it. Instead, edit the
10+
# BAML files and re-generate this code.
11+
#
12+
# ruff: noqa: E501,F401
13+
# flake8: noqa: E501,F401
14+
# pylint: disable=unused-import,line-too-long
15+
# fmt: off
16+
from baml_py.logging import set_log_level, get_log_level, set_log_json_mode, set_log_max_chunk_length
17+
from .globals import reset_baml_env_vars
18+
19+
__all__ = ["set_log_level", "get_log_level", "set_log_json_mode", "reset_baml_env_vars", "set_log_max_chunk_length"]

0 commit comments

Comments
 (0)