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

Tool use added #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

CivilEngineerUK
Copy link

Changelog

New Features

  • Added tools/functions support to the SimpleRealtime client
    • New tool registration system with add_tool() and add_tools() methods
    • Automatic schema generation from Python functions
    • Support for both synchronous and asynchronous tool handlers
    • Tool definitions are sent to OpenAI on connection
    • Added function call handling in the message handler

Code Organization

  • Split audio-related code into separate audio.py module
    • Moved StreamingAudioRecorder class to its own file
    • Cleaned up imports in main app.py

SimpleRealtime Client Improvements

  • Added tool/function management
    • New tools dictionary to store registered functions
    • Added _function_to_schema() helper method for automatic OpenAI schema generation
    • Enhanced connect() to configure session with registered tools
  • Made receive() method asynchronous
  • Added proper typing hints and docstrings
  • Improved error handling for function calls
  • Enhanced websocket connection management

App Changes

  • Added sample time function tool (get_current_time())
  • Updated client initialization to support tools
  • Improved session state management
  • Enhanced error handling and user feedback

Technical Improvements

  • Added proper type hints throughout the codebase
  • Improved asyncio integration and error handling
  • Enhanced websocket connection management
  • Better separation of concerns between modules

Bug Fixes

  • Fixed websocket connection handling
  • Improved error handling in message handler
  • Fixed tool registration validation
  • Enhanced session state management

The refactoring mainly focused on adding tool support while improving code organization and robustness. The core audio functionality remains largely unchanged, but is now better organized in its own module.

@mdagost
Copy link
Owner

mdagost commented Dec 4, 2024

Wow! Thanks for this, and sorry for my slow reply! I was take a deeper look at the PR in the next day or two. Thanks again!

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.

2 participants