Repository navigation
Composable prompting protocol names: base[:version](+feature[:version])*. - #789
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
…n])*`.
Precursor for protocol features such as `python+verbatim`, which is the next
change. This one registers no feature, so existing names (`python`,
`python:1.0`, `python:2.0`, `json`, `markdown`, ...) prompt, parse and are
recorded exactly as before.
WHAT
* One parser, `ProtocolName.parse` (schema/base.py), reads the grammar and
normalizes a name: a feature without a version takes its only registered
version, implied features are added, and features are put in registration
order. Once the base version is filled in, a protocol has exactly one name.
* Names are checked where they are used: a malformed name, an unknown or
repeated feature, an unknown feature version, or a feature that does not
support the base protocol or its version raises `ValueError`.
* `lf.query` records the normalized name (`python` -> `python:2.0`, as before)
and now also passes it to the `LfQuery` instance, which used to keep its
class default `'python'`, so prompt and parse see the same name as the
record. The autofix gate checks the parsed base
(`PromptingProtocol.SUPPORTS_AUTOFIX`, True for `python`) instead of
`protocol.startswith('python:')`; the result is the same for every existing
protocol.
* `LfQuery.from_protocol` parses the name, then looks up its base and version
as before. `_DEFAULT_PROTOCOL_VERSIONS` is unchanged, so a protocol that
registers its default version there (e.g. `markdown`) keeps working.
* `PromptingProtocol.from_name` accepts versions and features (it rejected
`python:2.0`), so every `schema_repr`, `value_repr` and `parse_value` call
takes a recorded name. Instances carry their `version`, `features` and full
`name`.
* `lf.parse` dispatches on the base and also accepts names such as
`python:2.0` (it accepted exactly `python` or `json`); `lf.score` accepts
them on both of its paths; `lf.query_reward` takes the protocol of the
response.
* Features are private for now (`_ProtocolFeature`): a feature declares its
name, its version, the base protocols and versions it supports, and the
features it implies.
PiperOrigin-RevId: 1008606157
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Composable prompting protocol names:
base[:version](+feature[:version])*.Precursor for protocol features such as
python+verbatim, which is the nextchange. This one registers no feature, so existing names (
python,python:1.0,python:2.0,json,markdown, ...) prompt, parse and arerecorded exactly as before.
WHAT
ProtocolName.parse(schema/base.py), reads the grammar andnormalizes a name: a feature without a version takes its only registered
version, implied features are added, and features are put in registration
order. Once the base version is filled in, a protocol has exactly one name.
repeated feature, an unknown feature version, or a feature that does not
support the base protocol or its version raises
ValueError.lf.queryrecords the normalized name (python->python:2.0, as before)and now also passes it to the
LfQueryinstance, which used to keep itsclass default
'python', so prompt and parse see the same name as therecord. The autofix gate checks the parsed base
(
PromptingProtocol.SUPPORTS_AUTOFIX, True forpython) instead ofprotocol.startswith('python:'); the result is the same for every existingprotocol.
LfQuery.from_protocolparses the name, then looks up its base and versionas before.
_DEFAULT_PROTOCOL_VERSIONSis unchanged, so a protocol thatregisters its default version there (e.g.
markdown) keeps working.PromptingProtocol.from_nameaccepts versions and features (it rejectedpython:2.0), so everyschema_repr,value_reprandparse_valuecalltakes a recorded name. Instances carry their
version,featuresand fullname.lf.parsedispatches on the base and also accepts names such aspython:2.0(it accepted exactlypythonorjson);lf.scoreacceptsthem on both of its paths;
lf.query_rewardtakes the protocol of theresponse.
_ProtocolFeature): a feature declares itsname, its version, the base protocols and versions it supports, and the
features it implies.