cbrkit 0.28.0__tar.gz → 0.28.2__tar.gz

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.
Files changed (71) hide show
  1. {cbrkit-0.28.0 → cbrkit-0.28.2}/PKG-INFO +1 -1
  2. {cbrkit-0.28.0 → cbrkit-0.28.2}/pyproject.toml +1 -1
  3. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/embed.py +19 -14
  4. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/system.py +11 -16
  5. {cbrkit-0.28.0 → cbrkit-0.28.2}/README.md +0 -0
  6. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/__init__.py +0 -0
  7. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/__main__.py +0 -0
  8. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/adapt/__init__.py +0 -0
  9. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/adapt/attribute_value.py +0 -0
  10. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/adapt/generic.py +0 -0
  11. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/adapt/numbers.py +0 -0
  12. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/adapt/strings.py +0 -0
  13. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/api.py +0 -0
  14. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/cli.py +0 -0
  15. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/constants.py +0 -0
  16. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/cycle.py +0 -0
  17. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/dumpers.py +0 -0
  18. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/eval/__init__.py +0 -0
  19. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/eval/common.py +0 -0
  20. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/eval/retrieval.py +0 -0
  21. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/helpers.py +0 -0
  22. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/loaders.py +0 -0
  23. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/model/__init__.py +0 -0
  24. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/model/graph.py +0 -0
  25. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/model/result.py +0 -0
  26. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/py.typed +0 -0
  27. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/retrieval/__init__.py +0 -0
  28. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/retrieval/apply.py +0 -0
  29. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/retrieval/build.py +0 -0
  30. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/retrieval/rerank.py +0 -0
  31. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/reuse/__init__.py +0 -0
  32. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/reuse/apply.py +0 -0
  33. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/reuse/build.py +0 -0
  34. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/__init__.py +0 -0
  35. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/aggregator.py +0 -0
  36. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/attribute_value.py +0 -0
  37. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/collections.py +0 -0
  38. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/generic.py +0 -0
  39. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/__init__.py +0 -0
  40. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/alignment.py +0 -0
  41. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/astar.py +0 -0
  42. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/brute_force.py +0 -0
  43. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/common.py +0 -0
  44. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/dfs.py +0 -0
  45. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/greedy.py +0 -0
  46. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/lap.py +0 -0
  47. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/precompute.py +0 -0
  48. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/qap.py +0 -0
  49. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/graphs/vf2.py +0 -0
  50. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/numbers.py +0 -0
  51. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/pooling.py +0 -0
  52. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/strings.py +0 -0
  53. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/taxonomy.py +0 -0
  54. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/sim/wrappers.py +0 -0
  55. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/__init__.py +0 -0
  56. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/apply.py +0 -0
  57. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/build.py +0 -0
  58. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/model.py +0 -0
  59. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/prompts.py +0 -0
  60. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/__init__.py +0 -0
  61. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/anthropic.py +0 -0
  62. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/cohere.py +0 -0
  63. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/google.py +0 -0
  64. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/instructor.py +0 -0
  65. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/model.py +0 -0
  66. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/ollama.py +0 -0
  67. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/openai.py +0 -0
  68. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/openai_agents.py +0 -0
  69. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/pydantic_ai.py +0 -0
  70. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/synthesis/providers/wrappers.py +0 -0
  71. {cbrkit-0.28.0 → cbrkit-0.28.2}/src/cbrkit/typing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cbrkit
3
- Version: 0.28.0
3
+ Version: 0.28.2
4
4
  Summary: Customizable Case-Based Reasoning (CBR) toolkit for Python with a built-in API and CLI
5
5
  Keywords: cbr,case-based reasoning,api,similarity,nlp,retrieval,cli,tool,library
6
6
  Author: Mirko Lenz
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cbrkit"
3
- version = "0.28.0"
3
+ version = "0.28.2"
4
4
  description = "Customizable Case-Based Reasoning (CBR) toolkit for Python with a built-in API and CLI"
5
5
  authors = [{ name = "Mirko Lenz", email = "mirko@mirkolenz.com" }]
6
6
  readme = "README.md"
@@ -191,18 +191,19 @@ class cache(BatchConversionFunc[str, NumpyArray]):
191
191
 
192
192
  self.path.parent.mkdir(parents=True, exist_ok=True)
193
193
 
194
- with self.connect() as connection:
195
- connection.execute(f"""
194
+ with self.connect() as con:
195
+ con.execute(f"""
196
196
  CREATE TABLE IF NOT EXISTS "{self.table}" (
197
197
  id INTEGER PRIMARY KEY AUTOINCREMENT,
198
198
  text TEXT NOT NULL UNIQUE,
199
199
  vector BLOB NOT NULL
200
200
  )
201
201
  """)
202
+ con.commit()
202
203
 
203
- cursor = connection.execute(f'SELECT text, vector FROM "{self.table}"')
204
+ cur = con.execute(f'SELECT text, vector FROM "{self.table}"')
204
205
 
205
- for text, vector_blob in cursor:
206
+ for text, vector_blob in cur:
206
207
  self.store[text] = np.frombuffer(vector_blob, dtype=np.float64)
207
208
 
208
209
  @contextmanager
@@ -210,12 +211,12 @@ class cache(BatchConversionFunc[str, NumpyArray]):
210
211
  if self.path is None:
211
212
  raise ValueError("Path must be set to use the cache")
212
213
 
213
- connection = sqlite3.connect(self.path)
214
+ con = sqlite3.connect(self.path, autocommit=False)
214
215
 
215
216
  try:
216
- yield connection
217
+ yield con
217
218
  finally:
218
- connection.close()
219
+ con.close()
219
220
 
220
221
  @override
221
222
  def __call__(self, texts: Sequence[str]) -> Sequence[NumpyArray]:
@@ -230,13 +231,17 @@ class cache(BatchConversionFunc[str, NumpyArray]):
230
231
  self.store[text] = vector
231
232
 
232
233
  if self.path is not None:
233
- with self.connect() as connection:
234
- for text, vector in zip(new_texts, new_vectors, strict=True):
235
- vector_blob = vector.astype(np.float64).tobytes()
236
- connection.execute(
237
- f'INSERT OR IGNORE INTO "{self.table}" (text, vector) VALUES (?, ?)',
238
- (text, vector_blob),
239
- )
234
+ with self.connect() as con:
235
+ con.executemany(
236
+ f'INSERT OR IGNORE INTO "{self.table}" (text, vector) VALUES(?, ?)',
237
+ [
238
+ (text, vector.astype(np.float64).tobytes())
239
+ for text, vector in zip(
240
+ new_texts, new_vectors, strict=True
241
+ )
242
+ ],
243
+ )
244
+ con.commit()
240
245
 
241
246
  return [self.store[text] for text in texts]
242
247
 
@@ -17,18 +17,17 @@ __all__ = [
17
17
 
18
18
 
19
19
  @dataclass(slots=True, frozen=True)
20
- class System[K: str | int, V: BaseModel, S: Float]:
20
+ class System[K: str | int, V: BaseModel, S: Float, P: str]:
21
21
  casebase: cbrkit.typing.Casebase[K, V]
22
- model: type[V]
23
22
  retriever_pipelines: Mapping[
24
- str, MaybeSequence[cbrkit.typing.RetrieverFunc[K, V, S]]
23
+ P, MaybeSequence[cbrkit.typing.RetrieverFunc[K, V, S]]
25
24
  ] = field(default_factory=dict)
26
- reuser_pipelines: Mapping[str, MaybeSequence[cbrkit.typing.ReuserFunc[K, V, S]]] = (
25
+ reuser_pipelines: Mapping[P, MaybeSequence[cbrkit.typing.ReuserFunc[K, V, S]]] = (
27
26
  field(default_factory=dict)
28
27
  )
29
28
 
30
29
  def get_retriever_pipeline(
31
- self, name: str, limit: int | None
30
+ self, name: P, limit: int | None
32
31
  ) -> Sequence[cbrkit.typing.RetrieverFunc[K, V, S]]:
33
32
  retrievers = produce_sequence(self.retriever_pipelines[name])
34
33
 
@@ -43,7 +42,7 @@ class System[K: str | int, V: BaseModel, S: Float]:
43
42
  def retrieve(
44
43
  self,
45
44
  query: V,
46
- retriever_pipeline: str,
45
+ retriever_pipeline: P,
47
46
  limit: int | None = None,
48
47
  ) -> cbrkit.retrieval.QueryResultStep[K, V, S]:
49
48
  return cbrkit.retrieval.apply_query(
@@ -55,7 +54,7 @@ class System[K: str | int, V: BaseModel, S: Float]:
55
54
  def reuse(
56
55
  self,
57
56
  query: V,
58
- reuser_pipeline: str,
57
+ reuser_pipeline: P,
59
58
  ) -> cbrkit.retrieval.QueryResultStep[K, V, S]:
60
59
  return cbrkit.reuse.apply_query(
61
60
  self.casebase,
@@ -66,8 +65,8 @@ class System[K: str | int, V: BaseModel, S: Float]:
66
65
  def cycle(
67
66
  self,
68
67
  query: V,
69
- retriever_pipeline: str,
70
- reuser_pipeline: str,
68
+ retriever_pipeline: P,
69
+ reuser_pipeline: P,
71
70
  limit: int | None = None,
72
71
  ) -> cbrkit.retrieval.QueryResultStep[K, V, S]:
73
72
  return cbrkit.cycle.apply_query(
@@ -117,9 +116,7 @@ class System[K: str | int, V: BaseModel, S: Float]:
117
116
  with cbrkit.helpers.optional_dependencies():
118
117
  from fastapi import FastAPI
119
118
 
120
- def to_fastapi(system: System) -> FastAPI:
121
- app = FastAPI()
122
-
119
+ def to_fastapi(system: System, app: FastAPI) -> FastAPI:
123
120
  for value in system.tools:
124
121
  app.post(f"/tool/{value.__name__}")(value)
125
122
 
@@ -135,9 +132,7 @@ with cbrkit.helpers.optional_dependencies():
135
132
  with cbrkit.helpers.optional_dependencies():
136
133
  from fastmcp import FastMCP
137
134
 
138
- def to_fastmcp(system: System) -> FastMCP[Any]:
139
- app = FastMCP()
140
-
135
+ def to_fastmcp[T](system: System, app: FastMCP[T]) -> FastMCP[T]:
141
136
  for value in system.tools:
142
137
  app.tool(value)
143
138
 
@@ -153,5 +148,5 @@ with cbrkit.helpers.optional_dependencies():
153
148
  with cbrkit.helpers.optional_dependencies():
154
149
  from pydantic_ai.toolsets import FunctionToolset
155
150
 
156
- def to_pydantic_ai(system: System) -> FunctionToolset[Any]:
151
+ def to_pydantic_ai(system: System) -> FunctionToolset[None]:
157
152
  return FunctionToolset(system.tools)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes