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

chat history #9

Merged
merged 5 commits into from
Nov 13, 2024
Merged

chat history #9

merged 5 commits into from
Nov 13, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Nov 13, 2024

needs OpenVoiceOS/ovos-plugin-manager#286

Summary by CodeRabbit

  • New Features

    • Enhanced interaction capabilities of the persona system.
    • Added methods for handling user and AI utterances.
    • Introduced a new chat completion method for improved chat-based interactions.
    • Dynamic loading of chat-related plugins for enhanced functionality.
  • Bug Fixes

    • Improved error handling and logging for message processing and intent matching.
  • Refactor

    • Simplified intent loading logic and updated method signatures for better clarity.

Copy link

coderabbitai bot commented Nov 13, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in the ovos_persona module enhance the functionality of the PersonaService and Persona classes, including updates to the chat method and the introduction of new methods for handling utterances and message history. The QuestionSolversService class in solvers.py is also improved with a new chat_completion method for better chat interaction. These modifications streamline intent processing and improve event handling capabilities.

Changes

File Change Summary
ovos_persona/init.py - Updated chat method in Persona class.
- Added _build_msg_history method in PersonaService class.
- Modified chatbox_ask to accept a message parameter.
- Added handle_utterance and handle_speak methods.
- Updated load_intent_files to an instance method.
ovos_persona/solvers.py - Added chat_completion method in QuestionSolversService class.
- Expanded typing imports to include List and Dict.
- Wrapped ChatMessageSolver import in try-except.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PersonaService
    participant QuestionSolversService
    participant ChatMessageSolver

    User->>PersonaService: send chat message
    PersonaService->>QuestionSolversService: call chat_completion
    QuestionSolversService->>ChatMessageSolver: get_chat_completion
    ChatMessageSolver-->>QuestionSolversService: return response
    QuestionSolversService-->>PersonaService: return response
    PersonaService-->>User: send response
Loading

🐰 "In the meadow where ideas bloom,
New methods dance, dispelling gloom.
With chat and speak, we share our tale,
In the world of personas, we shall prevail!
So hop along, let's celebrate,
For changes here will elevate!" 🎉

Warning

Rate limit exceeded

@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 50 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4ba49c8 and f137184.


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 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.

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: 4

🧹 Outside diff range and nitpick comments (2)
ovos_persona/solvers.py (1)

56-56: Fix grammatical error in log message

The log message on line 56~ has a grammatical error. It should read "does not support chat history!" instead of "does not supported chat history!".

Apply this diff to correct the error:

-LOG.debug(f"{module} does not supported chat history!")
+LOG.debug(f"{module} does not support chat history!")
ovos_persona/__init__.py (1)

167-170: Simplify conditional assignment with a ternary operator

The if-else block can be simplified using a ternary operator for better readability.

Apply this diff to refactor the code:

-        if ans is None:
-            ans = m[1]  # track answer
-        else:  # merge multi speak answers
-            ans = f"{ans}. {m[1]}"
+        ans = m[1] if ans is None else f"{ans}. {m[1]}"
🧰 Tools
🪛 Ruff

167-170: Use ternary operator ans = m[1] if ans is None else f"{ans}. {m[1]}" instead of if-else-block

(SIM108)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6b29c2e and 4ba49c8.

📒 Files selected for processing (2)
  • ovos_persona/__init__.py (9 hunks)
  • ovos_persona/solvers.py (2 hunks)
🧰 Additional context used
🪛 Ruff
ovos_persona/__init__.py

167-170: Use ternary operator ans = m[1] if ans is None else f"{ans}. {m[1]}" instead of if-else-block

(SIM108)

🔇 Additional comments (2)
ovos_persona/__init__.py (2)

132-135: Ensure all calls to 'chatbox_ask' accommodate the new 'message' parameter

The chatbox_ask method signature now includes a message: Message = None parameter. Verify that existing calls to this method are updated to include this parameter if necessary, or handle it appropriately to avoid potential errors.

Run the following script to identify all calls to chatbox_ask:

#!/bin/bash
# Description: Identify all usages of 'chatbox_ask' to ensure compatibility with the new signature.

# Test: Search for 'chatbox_ask(' in the codebase.
# Expect: Calls should match the new method signature.

rg 'chatbox_ask\(' -A 3

84-85: Verify the impact of changing 'load_intent_files' from class method to instance method

The method load_intent_files has been changed from a class method to an instance method. Ensure that all references and calls to this method are updated accordingly to prevent any runtime errors.

Run the following script to locate any class method references to load_intent_files:

✅ Verification successful

Let me try a different search strategy to verify the impact of this change.


Let me search for any usage of this method within the codebase to ensure we have a complete picture.


Method change from @classmethod to instance method is safe

The git history shows that load_intent_files was previously decorated with @classmethod, but there are no direct class method calls (PersonaService.load_intent_files()) found in the codebase. The method is only used internally within instance methods, making this change safe.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find references to 'load_intent_files' being called as a class method.

# Test: Search for 'PersonaService.load_intent_files(' in the codebase.
# Expect: No calls should reference it as a class method.

rg 'PersonaService\.load_intent_files\('

Length of output: 1451


Script:

#!/bin/bash
# Search for any references to load_intent_files in the codebase
rg "load_intent_files" -A 2

# Also search for any class method decorators (@classmethod) near load_intent_files
# to verify if it was previously a class method
rg -B 2 "def load_intent_files"

Length of output: 406


Script:

#!/bin/bash
# Search for any calls to load_intent_files
rg -B 3 -A 3 "\.(load_intent_files)"

# Also check the git history to see if it was previously decorated as a classmethod
git log -p | rg -B 3 -A 3 "load_intent_files"

Length of output: 589

ovos_persona/solvers.py Show resolved Hide resolved
ovos_persona/solvers.py Show resolved Hide resolved
ovos_persona/__init__.py Outdated Show resolved Hide resolved
ovos_persona/__init__.py Outdated Show resolved Hide resolved
@JarbasAl JarbasAl merged commit 089bcaf into dev Nov 13, 2024
2 checks passed
@JarbasAl JarbasAl deleted the history branch December 29, 2024 01:07
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