stores 0.1.7.dev6__py3-none-any.whl → 0.1.8.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stores/format.py +15 -9
- stores/indexes/base_index.py +12 -9
- stores/indexes/remote_index.py +7 -2
- {stores-0.1.7.dev6.dist-info → stores-0.1.8.dev1.dist-info}/METADATA +1 -1
- {stores-0.1.7.dev6.dist-info → stores-0.1.8.dev1.dist-info}/RECORD +7 -7
- {stores-0.1.7.dev6.dist-info → stores-0.1.8.dev1.dist-info}/WHEEL +0 -0
- {stores-0.1.7.dev6.dist-info → stores-0.1.8.dev1.dist-info}/licenses/LICENSE +0 -0
stores/format.py
CHANGED
@@ -61,7 +61,7 @@ def get_type_repr(typ: Type | GenericAlias) -> list[str]:
|
|
61
61
|
return [type_mappings[typ.__name__]]
|
62
62
|
|
63
63
|
|
64
|
-
def get_type_schema(typ: Type | GenericAlias):
|
64
|
+
def get_type_schema(typ: Type | GenericAlias, provider: ProviderFormat):
|
65
65
|
origin = get_origin(typ)
|
66
66
|
args = get_args(typ)
|
67
67
|
|
@@ -77,24 +77,27 @@ def get_type_schema(typ: Type | GenericAlias):
|
|
77
77
|
schema["enum"] = [v.value for v in typ]
|
78
78
|
elif isinstance(typ, type) and typ.__class__.__name__ == "_TypedDictMeta":
|
79
79
|
hints = get_type_hints(typ)
|
80
|
-
schema["properties"] = {
|
81
|
-
|
80
|
+
schema["properties"] = {
|
81
|
+
k: get_type_schema(v, provider) for k, v in hints.items()
|
82
|
+
}
|
83
|
+
if provider != ProviderFormat.GOOGLE_GEMINI:
|
84
|
+
schema["additionalProperties"] = False
|
82
85
|
schema["required"] = list(hints.keys())
|
83
86
|
elif origin in (list, List) or typ is dict:
|
84
87
|
if args:
|
85
|
-
schema["items"] = get_type_schema(args[0])
|
88
|
+
schema["items"] = get_type_schema(args[0], provider)
|
86
89
|
else:
|
87
90
|
raise TypeError("Insufficient argument type information")
|
88
91
|
elif origin in (dict, Dict) or typ is dict:
|
89
92
|
raise TypeError("Insufficient argument type information")
|
90
93
|
elif origin in (tuple, Tuple) or typ is tuple:
|
91
94
|
if args:
|
92
|
-
schema["items"] = get_type_schema(args[0])
|
95
|
+
schema["items"] = get_type_schema(args[0], provider)
|
93
96
|
else:
|
94
97
|
raise TypeError("Insufficient argument type information")
|
95
98
|
elif origin is Union or origin is T.UnionType:
|
96
99
|
for arg in args:
|
97
|
-
subschema = get_type_schema(arg)
|
100
|
+
subschema = get_type_schema(arg, provider)
|
98
101
|
del subschema["type"]
|
99
102
|
schema = {
|
100
103
|
**schema,
|
@@ -103,14 +106,17 @@ def get_type_schema(typ: Type | GenericAlias):
|
|
103
106
|
|
104
107
|
# Un-nest single member type lists since Gemini does not accept list of types
|
105
108
|
# Optional for OpenAI or Anthropic
|
106
|
-
if schema["type"]
|
107
|
-
schema["type"]
|
109
|
+
if schema["type"]:
|
110
|
+
if len(schema["type"]) == 1:
|
111
|
+
schema["type"] = schema["type"][0]
|
112
|
+
elif len(schema["type"]) > 1 and provider == ProviderFormat.GOOGLE_GEMINI:
|
113
|
+
schema["type"] = schema["type"][0]
|
108
114
|
|
109
115
|
return schema
|
110
116
|
|
111
117
|
|
112
118
|
def get_param_schema(param: inspect.Parameter, provider: ProviderFormat):
|
113
|
-
param_schema = get_type_schema(param.annotation)
|
119
|
+
param_schema = get_type_schema(param.annotation, provider)
|
114
120
|
|
115
121
|
if param_schema["type"] is None:
|
116
122
|
raise TypeError(f"Unsupported type: {param.annotation.__name__}")
|
stores/indexes/base_index.py
CHANGED
@@ -9,7 +9,6 @@ from typing import (
|
|
9
9
|
Callable,
|
10
10
|
List,
|
11
11
|
Literal,
|
12
|
-
Optional,
|
13
12
|
Tuple,
|
14
13
|
Union,
|
15
14
|
get_args,
|
@@ -98,7 +97,7 @@ def _handle_non_string_literal(annotation: type):
|
|
98
97
|
return list[new_annotation], {"item": literal_map}
|
99
98
|
if origin is Union or origin is UnionType:
|
100
99
|
union_literal_maps = {}
|
101
|
-
argtype_args = [a for a in get_args(annotation)
|
100
|
+
argtype_args = [a for a in get_args(annotation)]
|
102
101
|
new_union, literal_map = _handle_non_string_literal(argtype_args[0])
|
103
102
|
union_literal_maps[new_union.__name__] = literal_map
|
104
103
|
for child_argtype in argtype_args[1:]:
|
@@ -198,12 +197,12 @@ def wrap_tool(tool: Callable):
|
|
198
197
|
# Process args with default values: make sure type includes None
|
199
198
|
new_annotation = argtype
|
200
199
|
if new_annotation is Parameter.empty:
|
201
|
-
new_annotation =
|
200
|
+
new_annotation = type(new_arg.default) | None
|
202
201
|
origin = get_origin(new_annotation)
|
203
202
|
if origin not in [Union, UnionType] or NoneType not in get_args(
|
204
203
|
new_annotation
|
205
204
|
):
|
206
|
-
new_annotation =
|
205
|
+
new_annotation = new_annotation | None
|
207
206
|
new_arg = new_arg.replace(
|
208
207
|
default=None,
|
209
208
|
kind=Parameter.POSITIONAL_OR_KEYWORD,
|
@@ -402,13 +401,17 @@ class BaseIndex:
|
|
402
401
|
# Handle sync
|
403
402
|
yield tool_fn(**kwargs)
|
404
403
|
|
405
|
-
def parse_and_execute(self, msg: str):
|
404
|
+
def parse_and_execute(self, msg: str, collect_results=False):
|
406
405
|
toolcall = llm_parse_json(msg, keys=["toolname", "kwargs"])
|
407
|
-
return self.execute(
|
406
|
+
return self.execute(
|
407
|
+
toolcall.get("toolname"), toolcall.get("kwargs"), collect_results
|
408
|
+
)
|
408
409
|
|
409
|
-
async def
|
410
|
+
async def aparse_and_execute(self, msg: str, collect_results=False):
|
410
411
|
toolcall = llm_parse_json(msg, keys=["toolname", "kwargs"])
|
411
|
-
return await self.aexecute(
|
412
|
+
return await self.aexecute(
|
413
|
+
toolcall.get("toolname"), toolcall.get("kwargs"), collect_results
|
414
|
+
)
|
412
415
|
|
413
416
|
def stream_parse_and_execute(self, msg: str):
|
414
417
|
toolcall = llm_parse_json(msg, keys=["toolname", "kwargs"])
|
@@ -416,7 +419,7 @@ class BaseIndex:
|
|
416
419
|
|
417
420
|
async def astream_parse_and_execute(self, msg: str):
|
418
421
|
toolcall = llm_parse_json(msg, keys=["toolname", "kwargs"])
|
419
|
-
async for value in self.
|
422
|
+
async for value in self.astream_execute(
|
420
423
|
toolcall.get("toolname"), toolcall.get("kwargs")
|
421
424
|
):
|
422
425
|
yield value
|
stores/indexes/remote_index.py
CHANGED
@@ -8,7 +8,7 @@ from pathlib import Path
|
|
8
8
|
from typing import Optional
|
9
9
|
|
10
10
|
import requests
|
11
|
-
from git import Repo
|
11
|
+
from git import GitCommandError, Repo
|
12
12
|
|
13
13
|
from stores.constants import VENV_NAME
|
14
14
|
from stores.indexes.base_index import BaseIndex
|
@@ -44,6 +44,8 @@ def lookup_index(index_id: str, index_version: str | None = None):
|
|
44
44
|
)
|
45
45
|
if response.ok:
|
46
46
|
return response.json()
|
47
|
+
else:
|
48
|
+
raise ValueError(f"Index {index_id} not found in database")
|
47
49
|
|
48
50
|
|
49
51
|
class RemoteIndex(BaseIndex):
|
@@ -88,7 +90,10 @@ class RemoteIndex(BaseIndex):
|
|
88
90
|
if not repo_url:
|
89
91
|
# Otherwise, assume index references a GitHub repo
|
90
92
|
repo_url = f"https://github.com/{index_id}.git"
|
91
|
-
|
93
|
+
try:
|
94
|
+
repo = Repo.clone_from(repo_url, self.index_folder)
|
95
|
+
except GitCommandError as e:
|
96
|
+
raise ValueError(f"Index {index_id} not found") from e
|
92
97
|
if commit_like:
|
93
98
|
repo.git.checkout(commit_like)
|
94
99
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
stores/__init__.py,sha256=KYpKkNrMLx6ssVUbxHnn9wFBq5F5KnaFchcimIfDf9g,186
|
2
2
|
stores/constants.py,sha256=7WqFmoGCtmUKHA5WHxOJvvK7g-yYu_KGoqnuVFADNao,57
|
3
|
-
stores/format.py,sha256=
|
3
|
+
stores/format.py,sha256=L6DaRklE0CpUzMoVTckliaP-M5UrF6gW8nEG_m4y21M,8089
|
4
4
|
stores/parse.py,sha256=HYPNPzQod2vpu1Cln7yQ8aVkZT1Mw2IN0sZ2A1DIaqE,4967
|
5
5
|
stores/utils.py,sha256=GPWT6lCoGobwP3PlEOHyJfKyd0dobamjyErcR7lgm7M,242
|
6
6
|
stores/indexes/__init__.py,sha256=s-RNqml8uGREQhxwSdDoxcbcxeD8soB9BcL5dBKsQfI,215
|
7
|
-
stores/indexes/base_index.py,sha256=
|
7
|
+
stores/indexes/base_index.py,sha256=oaLN_Tk6PdoTSlRdGsd2wTvBVQ4S3ylV8rbIVSSNkEQ,15608
|
8
8
|
stores/indexes/index.py,sha256=Cub5mtnYGipHfPR8BexJYRSKfuJmcGPp0B3ou2bGNqs,2901
|
9
9
|
stores/indexes/local_index.py,sha256=Gg9LkEo1L0_NZZYPItsF_-1y6nFP369C3QlPvPyvPx8,3708
|
10
|
-
stores/indexes/remote_index.py,sha256
|
10
|
+
stores/indexes/remote_index.py,sha256=kbyfjqeOgH5IgC0gYfoq79loFM1AeOCCYcsKimudZAg,3666
|
11
11
|
stores/indexes/venv_utils.py,sha256=k664ptVhPfs4AHCpB6CiE-pWHGcqi982YjsZDDt64Ys,18577
|
12
|
-
stores-0.1.
|
13
|
-
stores-0.1.
|
14
|
-
stores-0.1.
|
15
|
-
stores-0.1.
|
12
|
+
stores-0.1.8.dev1.dist-info/METADATA,sha256=tByMf-oftedetQH71kTs_UrtHdpAqxtppYNe2sYtp5Q,3081
|
13
|
+
stores-0.1.8.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
+
stores-0.1.8.dev1.dist-info/licenses/LICENSE,sha256=VTidYE7_Dam0Dwyq095EhhDIqi47g03oVpLAHQgKws0,1066
|
15
|
+
stores-0.1.8.dev1.dist-info/RECORD,,
|
File without changes
|
File without changes
|