Skip to main content

Python bindings for zeta_prompt

Project description

zed-zeta-bindings

Python bindings for Zed's Zeta prompt formatting and model output parsing code.

Installation

pip install zed-zeta-bindings

Usage

import zeta_bindings as zeta

prompt_format = "V0318SeedMultiRegions" # Zeta2.1 prompt format
prompt_input = zeta.ZetaPromptInput.from_dict(request_body)
prompt = zeta.format_prompt(prompt_input, prompt_format)
stop_tokens = zeta.stop_tokens(prompt_format) or None

raw_output = await engine.predict({"prompt": prompt, "stop": stop_tokens})
parsed_output = zeta.parse_output(raw_output, prompt_format, prompt_input)

response = {
    "output": parsed_output.new_editable_region,
    "editable_range": {
        "start": parsed_output.range_in_excerpt[0],
        "end": parsed_output.range_in_excerpt[1],
    },
}

For more detailed type information, see crates/zeta_prompt in the Zed repository: https://github.com/zed-industries/zed/tree/main/crates/zeta_prompt.

License

zed-zeta-bindings is licensed under GPL-3.0-or-later.

API

Functions that accept a format_str parameter are parameterized on the prompt format. Refer to the following table for the prompt format to use:

Zeta Version Prompt Format String
Zeta2 V0211SeedCoder
Zeta2.1 V0318SeedMultiRegions

ZetaPromptInput.from_dict(data)

Builds the typed prompt input from a request dictionary. The required fields are:

  • cursor_path
  • cursor_excerpt
  • cursor_offset_in_excerpt
  • excerpt_ranges

Optional fields include excerpt_start_row, events, related_files, active_buffer_diagnostics, and syntax_ranges.

format_prompt(prompt_input, format_str)

Formats a ZetaPromptInput into the prompt string sent to the model.

Returns None if the input does not fit within the selected format's token budget.

stop_tokens(format_str)

Returns the stop tokens for the selected prompt format.

parse_output(model_output, format_str, prompt_input)

Parses a raw model completion into a ParsedOutput.

ParsedOutput contains:

  • new_editable_region: the replacement text for the editable region.
  • range_in_excerpt: the [start, end] byte range of the editable region in cursor_excerpt.
  • cursor_offset_in_new_editable_region: the cursor offset in the replacement text, when present.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zed_zeta_bindings-1.6.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (804.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

File details

Details for the file zed_zeta_bindings-1.6.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: zed_zeta_bindings-1.6.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 804.5 kB
  • Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for zed_zeta_bindings-1.6.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4aa69b406a4dd5a401736fb1157abb7bd876237a4b00331c904fa1b7c4405699
MD5 69b5c7943ec86c38ba52b5540214f4b0
BLAKE2b-256 2dba5ea5035e49acc5ca2196260f9712d29b4e80601cf87facd7a78a987df6c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page