Add ability to "inject"options from the results of other `Evaluatable`s
- Lingua principale
- Python
- Stelle
- 17
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
There are times when you want to dynamically generate the value of an option using a dataset or other `Evaluatable` object. This is most often useful when using a `dataset` that someone else wrote.
Currently, a similar ability exists in the [`Map`](https://8451.github.io/labrea/usage.html#map) type, but only when iterating over the result of an `Evaluatable` that returns an interable.
The most natural way to do this would probably be to extend the `WithOptions` type (which powers the `Dataset.with_options` method) so that you can provide dynamic options as well as static ones. For example
```python
from labrea import dataset, Option
@dataset
def foo(bar: str = Option("BAR")) -> str:
return bar
@dataset
def bar(msg: str = Option("MSG")) -> str:
return msg
foo.with_options({"BAR": bar}).evaluate({"MSG": "Hello World!"})
# 'Hello World!'
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Look at the `WithOptions` type in the codebase, likely in a file like `with_options.py` or `evaluatable.py`. Understand how static options are currently handled. The goal is to allow an option's value to be the result of another `Evaluatable` (like a dataset). Check the `Map` type's implementation for iterable-based dynamic options as a reference. The change involves modifying the option resolution logic to evaluate provided `Evaluatable` objects and inject their results. Run existing tests for `WithOptions` and `Map` to ensure the new feature works and doesn't break existing functionality.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100