bind_kwargs
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| BoundFunction schemez.bind_kwargs A function with pre-bound parameters. |
🛈 DocStrings¶
BoundFunction
¶
A function with pre-bound parameters.
This class wraps a function and binds some parameters to fixed values, while updating the signature and docstring to reflect only the remaining parameters that can still be provided when calling.
Source code in src/schemez/bind_kwargs.py
__call__
¶
Call the function with the bound parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments for the function |
()
|
**kwargs
|
Any
|
Keyword arguments for the function |
{}
|
Returns:
| Type | Description |
|---|---|
T
|
The return value from the wrapped function |
Source code in src/schemez/bind_kwargs.py
__init__
¶
Initialize with a function and parameters to bind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., T]
|
The function to wrap |
required |
**bound_kwargs
|
Any
|
Parameters to bind to fixed values |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If any parameter name is not in the function signature |
Source code in src/schemez/bind_kwargs.py
remove_kwargs_from_docstring
¶
Update docstring to remove bound parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docstring
|
str | None
|
Original function docstring |
required |
kwargs
|
dict[str, Any]
|
kwargs to remove from docstring |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Updated docstring with bound parameters removed |
Source code in src/schemez/bind_kwargs.py
search_db
async
¶
search_db(
query: str, k: int = 5, filters: dict[str, list[str]] | None = None, min_score: float = 0.7
) -> list[dict[str, Any]]
Search the database for relevant information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query text |
required |
k
|
int
|
Number of results to return |
5
|
filters
|
dict[str, list[str]] | None
|
Filters to apply to search 2nd line |
None
|
min_score
|
float
|
Minimum relevance score |
0.7
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of search results |
Example
await search_db("quantum computing", k=3)