8000 Update System Prompt & Improve As-Readable Logic by ohdearquant · Pull Request #547 · khive-ai/lionagi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update System Prompt & Improve As-Readable Logic #547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jan 24, 2025

Conversation

ohdearquant
Copy link
Collaborator
@ohdearquant ohdearquant commented Jan 24, 2025

PR Description: Update System Prompt & Improve As-Readable Logic

Overview
This pull request updates our system prompt across LionAGI, integrates a more robust as_readable approach for displaying nested data, and addresses miscellaneous fixes in the ReAct flow, interpret actions, and error handling in APICalling.


Key Changes

  1. System Prompt Enhancement

    • Introduces LION_SYSTEM_MESSAGE in lionagi/session/prompts.py, describing the LionAGI vocabulary and design principles.
    • Adds an optional use_lion_system_message flag in Branch.__init__(), allowing the developer to prepend the Lion system message automatically.
  2. as_readable & as_readable_json Improvements

    • Refactors logic in lionagi/libs/schema/as_readable.py to handle:
      • More robust recursion for nested dicts/lists/Pydantic models.
      • Optional YAML-like (format_dict) vs. JSON output.
      • Markdown code blocks for notebook display.
    • Adds better multi-line string handling, ensuring the block scalar style (|) for YAML-like output.
  3. ReAct Flow Enhancements

    • ReAct.py now prints intermediate analyses using as_readable, with optional markdown, curly-based or JSON-based formatting.
    • Adds a verbose_length parameter to truncate overly lengthy chain-of-thought logs, avoiding huge console prints.
  4. Interpret & Parse Adjustments

    • interpret() can specify interpret_model for an alternative chat model.
    • Minor changes in parse.py to handle InterruptedError and stricter use of partial results if an LLM conversation is canceled mid-parse.
  5. APICalling Cancellation Handling

    • _inner() and _stream() methods more cleanly raise asyncio.CancelledError when user or environment cancels.
    • Ensures partial results are handled properly, and the event’s status is set to FAILED if canceled.
  6. Miscellaneous

    • Bumps version from 0.8.8 to 0.9.0.
    • Adds a new system config “developer prompt” for certain iModel calls if a specific “o1” model name is used in OpenAI completions logic.

Files Changed

  • lionagi/libs/schema/as_readable.py
    • Main refactor for the YAML-like vs. JSON rendering.
  • lionagi/operations/ReAct/ReAct.py
    • Enhanced logging with as_readable.
  • lionagi/operations/_act/act.py
    • Minor verbose debug improvements.
  • lionagi/operations/interpret/interpret.py
    • Supports interpret_model usage.
  • lionagi/service/endpoints/base.py
    • Improved _inner with explicit CancelledError re-raising.
  • lionagi/session/branch.py
    • use_lion_system_message flag, updated handling of system prompts.
  • lionagi/session/prompts.py (new)
    • Contains the large “LION_SYSTEM_MESSAGE” text block.
  • lionagi/version.py & pyproject.toml
    • Version bumped to 0 10000 .9.0.

Testing & Validation

  • Unit tests updated or added in tests/libs/utils/test_as_readable.py, ensuring correct multiline string formatting and custom kwargs handling.
  • Verified ReAct steps output truncated chain-of-thought logs when verbose_length is provided.
  • Confirmed interpret steps accept optional model overrides without breaking defaults.
  • Ran local integration tests on standard flows (branch.communicate, branch.operate, branch.ReAct) to confirm no regressions.

We appreciate your review and feedback!
This PR should provide better system-level clarity via the new system prompt, improved debug/tracing with refined as_readable, and more robust cancellation handling in the event loop.

@ohdearquant ohdearquant merged commit 98cab3c into main Jan 24, 2025
5 checks passed
@ohdearquant ohdearquant changed the title Update system prompt Update System Prompt & Improve As-Readable Logic Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0