Skip to content
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

Use system_prompt in solver configuration (breaking change) #19

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

Delfshkrimm
Copy link

@Delfshkrimm Delfshkrimm commented Feb 3, 2025

Summary by CodeRabbit

  • Documentation
    • Updated configuration examples to use a unified "system_prompt" parameter, replacing the previous "persona" and "initial_prompt" terminology.
  • Refactor
    • Streamlined the chat response process by removing legacy persona management, ensuring a simpler configuration.
  • Chore
    • Revised integration settings for the assistant to align with the updated configuration approach.

Cleaned system_prompt saving in init method
Changed references to initial_prompt to system_prompt to unify
Bumped major version to signify breaking change
Copy link

coderabbitai bot commented Feb 3, 2025

Walkthrough

This pull request updates the configuration parameters and internal class structure. It replaces the parameters "persona" and "initial_prompt" with "system_prompt" in configuration examples and code, and removes the OpenAIPersonaSolver class altogether. The plugin entry point is updated to use the OpenAIChatCompletionsSolver directly. These changes simplify the solver implementation by eliminating the persona management layer and standardizing prompt terminology.

Changes

Files Change Summary
README.md
ovos_solver_openai_persona/dialog_transformers.py
Renamed parameters: replaced "persona"/"initial_prompt" with "system_prompt" in configuration examples and prompt initialization.
ovos_solver_openai_persona/init.py Removed the OpenAIPersonaSolver class and its methods (__init__, get_chat_history, etc.), transitioning to direct instantiation of OpenAIChatCompletionsSolver.
setup.py Updated PLUGIN_ENTRY_POINT to point to ovos_solver_openai_persona.engines:OpenAIChatCompletionsSolver instead of the removed OpenAIPersonaSolver.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant U as User
    participant OCS as OpenAIChatCompletionsSolver
    participant API as OpenAI Completions API
    U->>OCS: Call get_spoken_answer(query)
    OCS->>API: Send query with system_prompt
    API-->>OCS: Return spoken answer
    OCS-->>U: Deliver answer

Possibly related PRs

Poem

I'm a rabbit hopping through the code,
With system prompts lighting my humble abode.
The old persona has hopped away,
Leaving a sleeker path in its display.
I wiggle my nose at changes so neat—
A rabbit's joy in every beat!
🐇

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0176017 and b61365b.

📒 Files selected for processing (1)
  • ovos_solver_openai_persona/engines.py (4 hunks)
🔥 Files not summarized due to errors (1)
  • ovos_solver_openai_persona/engines.py: Error: Disallowed special token found: <|im_end|>
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sorry, something went wrong.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ovos_solver_openai_persona/__init__.py (1)

37-42: Consider adding docstring for the new method.

The new stream_chat_utterances method implementation looks good, but it's missing documentation.

Add a docstring to improve code maintainability:

 def stream_chat_utterances(self, messages: List[Dict[str, str]],
                            lang: Optional[str] = None,
                            units: Optional[str] = None) -> Iterable[str]:
+    """Stream chat utterances with system prompt prepended.
+
+    Args:
+        messages (List[Dict[str, str]]): List of message dictionaries with 'role' and 'content'.
+        lang (Optional[str], optional): Language code. Defaults to None.
+        units (Optional[str], optional): Units for the query. Defaults to None.
+
+    Yields:
+        str: Generated utterances from the chat model.
+    """
     messages = [{"role": "system", "content": self.system_prompt }] + messages
     answer = super().stream_chat_utterances(messages, lang, units)
     yield from answer
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b9ccf8 and badaf9c.

📒 Files selected for processing (4)
  • README.md (2 hunks)
  • ovos_solver_openai_persona/__init__.py (3 hunks)
  • ovos_solver_openai_persona/engines.py (2 hunks)
  • ovos_solver_openai_persona/version.py (1 hunks)
🔥 Files not summarized due to errors (1)
  • ovos_solver_openai_persona/engines.py: Error: Disallowed special token found: <|im_end|>
✅ Files skipped from review due to trivial changes (1)
  • ovos_solver_openai_persona/version.py
🔇 Additional comments (4)
ovos_solver_openai_persona/__init__.py (2)

12-12: LGTM! Good default system prompt.

The default system prompt is well-crafted, providing clear personality traits that align with a helpful assistant.


15-15: LGTM! Clean persona parameter handling.

The method correctly forwards the system prompt to the parent class, maintaining backward compatibility by keeping the unused persona parameter.

README.md (2)

16-16: LGTM! Clear example of system prompt usage.

The example demonstrates the new parameter name with a clear and descriptive prompt value.


36-36: LGTM! Configuration example updated correctly.

The configuration example has been updated to use the new parameter name with a simple, clear default value.

Removed specific OpenAIPersonaSolver class to use OpenAIChatCompletionsSolver
Moved specifics for system_prompt to OpenAIChatCompletionsSolver
Updated docs to reflect changes
@Delfshkrimm Delfshkrimm changed the title Use system_prompt in solver configuration Use system_prompt in solver configuration (breaking change) Feb 3, 2025
…rent class

Prepend message system prompt to continue_chat method when not streaming utterances from OpenAI API
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ovos_solver_openai_persona/__init__.py (1)

26-26: Consider updating example comments to reflect new class.

The bot instantiation correctly uses OpenAIChatCompletionsSolver. However, the example output comments below might benefit from being regenerated using the new class to ensure they accurately reflect current behavior.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9ca8f2 and 0176017.

📒 Files selected for processing (2)
  • ovos_solver_openai_persona/__init__.py (2 hunks)
  • ovos_solver_openai_persona/engines.py (5 hunks)
🔥 Files not summarized due to errors (1)
  • ovos_solver_openai_persona/engines.py: Error: Disallowed special token found: <|im_end|>
🔇 Additional comments (2)
ovos_solver_openai_persona/__init__.py (2)

1-1: LGTM!

The warnings import is correctly added to support the deprecation warning.


5-11: Implementation matches requested changes.

The deprecation warning has been implemented exactly as requested by JarbasAl, with proper warning message, deprecation type, and stack level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants