Skip to content

feat: re-export serve types from public mellea.* namespace#1243

Open
markstur wants to merge 2 commits into
generative-computing:mainfrom
markstur:issue_873
Open

feat: re-export serve types from public mellea.* namespace#1243
markstur wants to merge 2 commits into
generative-computing:mainfrom
markstur:issue_873

Conversation

@markstur

@markstur markstur commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Issue

Fixes #873

Description

Creates a stable public API for m serve types by moving user-facing types from cli/serve/models to mellea/serve/models. Users can now import ChatMessage and related types via:

from mellea.serve import ChatMessage

Changes:

  • Add mellea/serve/ module with ChatMessage, TextContent, ImageUrlContent, and MessageContent
  • Update cli/serve/models.py to re-export from mellea.serve
  • Update m serve examples to use new import path
  • Update m-serve.md documentation
  • Maintain backward compatibility (cli.serve.models still works)

The new public API provides clear separation
between user-facing types (mellea.serve) and internal CLI implementation (cli/serve).

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

Adding a new component, requirement, sampling strategy, or tool?

If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.

Creates a stable public API for m serve types by moving user-facing
types from cli/serve/models to mellea/serve/models. Users can now
import ChatMessage and related types via:

  from mellea.serve import ChatMessage

Changes:
- Add mellea/serve/ module with ChatMessage, TextContent,
  ImageUrlContent, and MessageContent
- Update cli/serve/models.py to re-export from mellea.serve
- Update m serve examples to use new import path
- Update m-serve.md documentation
- Maintain backward compatibility (cli.serve.models still works)

The new public API provides clear separation
between user-facing types (mellea.serve) and internal CLI
implementation (cli/serve).

Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Assisted-by: IBM Bob
@markstur markstur requested a review from a team as a code owner June 9, 2026 23:28
@github-actions github-actions Bot added the enhancement New feature or request label Jun 9, 2026
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
@markstur markstur enabled auto-merge June 10, 2026 15:06

@ajbozarth ajbozarth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One action item and a few inline nits:

  • The tests in test/cli/test_serve_models_multimodal.py should move to test/serve/test_models_multimodal.py and import from mellea.serve directly. The types they cover now live there, and the file isn't touched in this PR so I can't comment inline.

try:
from cpex.framework.hooks.policies import (
HookPayloadPolicy, # type: ignore[import-not-found]
from cpex.framework.hooks.policies import ( # type: ignore[import-not-found]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to #873 — worth either pulling out or mentioning in the description.

Also worth noting: neither placement actually works. # type: ignore on a multi-line import has to sit on the closing ) to apply. And mypy passes clean without it anyway, so the cleanest fix is to just delete the comment rather than move it.

Comment thread mellea/serve/models.py
Comment on lines +1 to +5
"""User-facing types for m serve.

This module contains the types that users need when writing serve() functions
for use with the `m serve` command.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this docstring duplicates mellea/serve/__init__.py's nearly verbatim. Consider trimming to one line.

Suggested change
"""User-facing types for m serve.
This module contains the types that users need when writing serve() functions
for use with the `m serve` command.
"""
"""User-facing types for `m serve`."""

@psschwei psschwei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of minor questions:

  • Should we update docs/examples/notebooks/m_serve_example.ipynb too?
  • Should we test the new path?

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: re-export serve types from public mellea.* namespace

3 participants