Skip to content

Conversation

@jacanchaplais
Copy link
Collaborator

Relevant issue or PR

Closes #22.

Description of changes

Add a --pretty-headings/--no-pretty-headings flag to the CLI, such that formatting on the parameter names in the Web UI can be toggled on and off.

This is useful in instances where Tesseracts have parameter names which differ only in case.

In the process, _parse_tesseract_oas() was refactored, so the formatting logic for input fields is easier to separate from the recursive logic of traversing the OAS tree. This was done by extracted formatting logic in a function called _format_field().

Testing done

Manual testing.

Example:

tesseract_api.py:

from pydantic import BaseModel, Field


class InputSchema(BaseModel):
    dummy_input: str = Field(description="Meaningless input", default="Dummy")
    this_is_a_long_one: str = Field(description="Pretty long", default="Oh my")
    THIS_IS_A_LONG_ONE: str = Field(description="Also long", default="Oh gosh")
    This_Is_A_Long_One: str = Field(description="Long, too", default="Oh darn")


class OutputSchema(BaseModel):
    dummy_output: str = Field(description="Meaningless output")
    wizard: str = Field(description="Magic", default="kadabra")
    Wizard: str = Field(description="Runes and stuff", default="presto!")


def apply(inputs: InputSchema) -> OutputSchema:
    """Run for 4 seconds before returning dummy output."""
    return OutputSchema(
        dummy_output="This is meaningless"
    )

Pretty headings on (default)

tesseract-streamlit --pretty-headings "http://localhost:50262" app.py  # this is default
streamlit run app.py
image

Pretty headings off

tesseract-streamlit --no-pretty-headings "http://localhost:50262" app.py
streamlit run app.py
image

Extract the input field formatting into a function that gets called by
_simplify_schema. Add use_title parameter to enable switching between
using the OAS key for an input field vs the formatted title.
@codecov
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.95%. Comparing base (1af8e67) to head (6929201).

Files with missing lines Patch % Lines
tesseract_streamlit/parse.py 96.15% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
+ Coverage   94.83%   94.95%   +0.11%     
==========================================
  Files           4        4              
  Lines         213      218       +5     
  Branches       24       25       +1     
==========================================
+ Hits          202      207       +5     
  Misses          8        8              
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jacanchaplais jacanchaplais marked this pull request as ready for review July 23, 2025 09:53
@jacanchaplais jacanchaplais enabled auto-merge (squash) July 23, 2025 11:02
Copy link
Contributor

@dionhaefner dionhaefner left a comment

Choose a reason for hiding this comment

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

Not sure how useful this feature is (I'd just go with "not pretty headings" by default), but shouldn't harm either. Thanks @jacanchaplais!

@jacanchaplais jacanchaplais merged commit 03613a0 into main Jul 23, 2025
9 checks passed
@jacanchaplais jacanchaplais deleted the jacan/pretty-headings branch July 23, 2025 13:37
@pasteurlabs pasteurlabs locked and limited conversation to collaborators Jul 23, 2025
@jacanchaplais
Copy link
Collaborator Author

jacanchaplais commented Jul 23, 2025

@dionhaefner I like a bit of pointless prettiness 🤭 But also it's about consistency, because the OAS titles are formatted in title case, but also the array and composite types are not very useful / break conventions. So it's to make the rough edges smooth using keys where the title fails, or make everything consistent with using keys exclusively. But can always flip the default later, as per click's recommendation to provide --flag/--no-flag options. ♻️

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a --pretty-headings flag to the CLI

3 participants