Skip to content

Add publish() to PromptClient #23

Open

Description

@sujal-maheshwari2004

Summary

PromptClient has no publish() method. PublishPrompt is available from the priompt CLI (priompt publish), promptctl and priompt/js-sdk (client.publish), and the generated Python stub already includes it, but Python users have to drop down to client._stub.PublishPrompt and build the request (including the slot list) by hand.

Impact

Python pipelines (evaluation jobs, notebooks, LangChain/LangGraph tooling) that want to publish a prompt version must use a private attribute and repeat promptctl's slot-derivation logic. Getting slots wrong fails server-side validation with template uses undeclared slots: ....

Steps to reproduce

  1. pip install priompt-sdk
  2. Run:
    from priompt_sdk import PromptClient
    c = PromptClient(host="localhost:8443")
    c.publish("priompt://acme/onboarding/welcome", "Hi {name}, welcome to {org}!")

Actual: AttributeError: 'PromptClient' object has no attribute 'publish'

Expected behavior

resp = c.publish("priompt://acme/onboarding/welcome", "Hi {name}, welcome to {org}!",
                 message="friendlier greeting")          # slots derived: ["name", "org"]
print(resp.version_hash)

publish() sends PublishPromptRequest (uri, template, slots, message, branch), derives slots from {placeholders} when not given, and invalidates the client cache entry for that URI.

Where to look

Suggested approach

  • Add publish(self, uri, template, slots=None, message="", branch="").
  • When slots is None, derive them with re.findall(r"\{(\w+)\}", template) de-duplicated in order, matching promptctl.
  • Call self._stub.PublishPrompt(...) with the client's metadata (and timeout, if one exists by then), then self._cache.pop(uri, None) and drop any cached list() entries whose prefix matches the URI.
  • Document it in the README API list and the priompt-dot-com Python SDK page (which currently lists Publish as "No").

Acceptance criteria

  • PromptClient.publish() exists with slots, message and branch parameters and returns the PublishPromptResponse.
  • Slots are derived from the template when not passed; tests cover duplicates and no placeholders.
  • A cached get() for the URI is invalidated after publish (test with the fake stub in tests/test_client.py).
  • README lists publish().

Activity

  1. techkayacodes commented on Nov 15, 2026

    @techkayacodes

    Hi @sujal-maheshwari2004! Following up on your note on priompt/js-sdk#31, I'd love to take this help wanted issue on and implement publish() on PromptClient (along with unit tests in ests/). Could you assign this to me?

  2. sujal-maheshwari2004 commented on Nov 16, 2026

    @sujal-maheshwari2004
    MemberAuthor

    Hey @techkayacodes sure you can have it, can you please share your approach to solve the issue on a high level?

  3. techkayacodes commented on Nov 19, 2026

    @techkayacodes

    Thanks @sujal-maheshwari2004! Here's the high-level approach I have in mind for PromptClient.publish():

    1. Method & gRPC wiring (priompt_sdk/client.py)

      • Add publish(self, uri, template, slots=None, message="", branch="") returning PublishPromptResponse.
      • Build prompt_pb2.PublishPromptRequest(uri=uri, template=template, slots=..., message=message, branch=branch) and call self._stub.PublishPrompt(req, metadata=self._md).
    2. Slot derivation (slots is None)

      • Only derive slots when slots is None (if an explicit list like slots=[] is passed, forward it as-is).
      • Extract slot names in first-seen, deduplicated order while skipping escaped literal braces ({{ / }}) to match validate.Slots in priompt/proto (so {{name}} isn't treated as a slot).
    3. Cache invalidation

      • Pop uri from self._cache and drop any cached ("list", prefix) entries where uri.startswith(prefix).
      • Quick check: since unpinned get() and list() serve main, would you prefer invalidating only when branch in ("", "main"), or unconditionally on every publish()?
    4. Tests & Docs

      • Extend FakeStub in tests/test_client.py with PublishPrompt and add tests covering slot derivation (normal, duplicates, no placeholders, escaped {{...}}, explicit slots), request/metadata forwarding, and cache invalidation for both get() and list().
      • Document publish() in README.md.

    Let me know if this looks good (and your preference on branch cache invalidation) and I'll get the PR ready once assigned!

  4. sujal-maheshwari2004 commented on Nov 19, 2026

    @sujal-maheshwari2004
    MemberAuthor

    @techkayacodes the issue is yours, The former would be much better suited for the service! (invalidating only when branch in ("", "main"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions