Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Directly Connecting Python to LLMs via Strongly-Typed Functions, Dataclasses, Interfaces & Generic Types
| Date | Stars |
|---|---|
| 2026-07-31 | 400 |
| 2026-08-03 | 400 |
| 2026-08-06 | 400 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# llm-strategy
[](https://img.shields.io/github/v/release/blackhc/llm-strategy)
[](https://github.com/blackhc/llm-strategy/actions/workflows/main.yml?query=branch%3Amain)
[](https://codecov.io/gh/blackhc/llm-strategy)
[](https://img.shields.io/github/commit-activity/m/blackhc/llm-strategy)
[](https://img.shields.io/github/license/blackhc/llm-strategy)
Implementing the Strategy Pattern using LLMs.
Also, please see https://blog.blackhc.net/2022/12/llm_software_engineering/ for a wider perspective on why this could be important in the future.
This package adds a decorator `llm_strategy` that connects to an LLM (such as OpenAI’s GPT-3) and uses the LLM to "implement" abstract methods in interface classes. It does this by forwarding requests to the LLM and converting the responses back to Python data using Python's `@dataclasses`.
It uses the doc strings, type annotations, and method/function names as prompts for the LLM, and can automatically convert the results back into Python types (currently only supporting `@dataclasses`). It can also extract a data schema to send to the LLM for interpretation. While the `llm-strategy` package still relies on some Python code, it has the potential to reduce the need for this code in the future by using additional, cheaper LLMs to automate the parsing of structured data.
- **Github repository**: <https://github.com/blackhc/llm-strategy/>
- **Documentation** <https://blackhc.github.io/llm-strategy/>
## Research Example
The latest version also includes a package for hyperparameter tracking and collecting traces from LLMs.
This for example allows for meta optimization. See examples/research for a simple implementation using Generics.
You can find an example WandB trace at: https://wandb.ai/blackhc/blackboard-pagi/reports/Meta-Optimization-Example-Trace--Vmlldzo3MDMxODEz?accessToken=p9hubfskmq1z5yj1uz7wx1idh304diiernp7pjlrjrybpaozlwv3dnitjt7vni1j
The prompts showing off the pattern using Generics are straightforward:
```python
T_TaskParameters = TypeVar("T_TaskParameters")
T_TaskResults = TypeVar("T_TaskResults")
T_Hyperparameters = TypeVar("T_Hyperparameters")
class TaskRun(BaseModel, Generic[T_TaskParameters, T_TaskResults, T_Hyperparameters]):
"""
The task run. This is the 'data' we use to optimize the hyperparameters.
"""
task_parameters: T_TaskParameters = Field(..., description="The task parameters.")
hyperparameters: T_Hyperparameters = Field(
...,
description="The hyperparameters used for the task. We optimize these.",
)
all_chat_chains: dict = Field(..., description="The chat chains from the task execution.")
return_value: T_TaskResults | None = Field(
..., description="The results of the task. (None for exceptions/failure.)"
)
exception: list[str] | str | None = Field(..., description="Exception that occurred during the task execution.")
class TaskReflection(BaseModel):
"""
The reflections on the task.
This contains the lessons we learn from each task run to come up with better
hyperparameters to try.
"""
feedback: str = Field(
...,
description=(
"Only look at the final results field. Does its content satisfy the "
"task description and task parameters? Does it contain all the relevant "
"information from the all_chains and all_prompts fields? What could be improved "
"in the results?"
),
)
evaluation: str = Field(
...,
description=(
"The evaluation of the outpuExcerpt of 12,665 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:418d51eca05c3fd3, topic:llm, topic:gpt