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

Refactor SydneyClient (Added GPT-4o for Creative Mode, Long Conversation Handling, Additional Functionalities and Minor Bug Fixes) #177

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Luneye
Copy link

@Luneye Luneye commented Jul 6, 2024

This pull request refactors the SydneyClient class in the sydney.py file to include new features and enhance functionality.
The main changes include:

  • New Features:
    • Introduced force_conv_deletion_on_exit_signal flag for auto-deletion of conversations on exit.
    • Added create_conversation_context method for creating a history of messages, from a list of messages following OpenAI syntax: [{"content": "...", "role": "system"}, {"content": "...", "role": "user"}, {"content": "...", "role": "assistant"}, ...].
    • Added ability to have a long conversation (more than the intended limit) as follows:
import asyncio
import os

from sydney import SydneyClient

os.environ["BING_COOKIES"] = f"insert_your_cookies_here"

async def main() -> None:
    history = []
    while True:
        async with SydneyClient(style="creative", force_conv_deletion_on_exit_signal=True) as sydney:
            prompt = input("You: ")
            history.append({"role": "user", "content": prompt})

            if prompt == "!reset":
                history = []
                await sydney.quit_current_and_start_new_conversation()
            elif prompt == "!exit":
                break
            else:
                print("Sydney: ", end="", flush=True)
                ai_response = ""
                async for response in sydney.ask_stream(prompt=prompt, context=sydney.create_conversation_context(history)):
                    print(response, end="", flush=True)
                    ai_response += response
                history.append({"role": "assistant", "content": ai_response})
                print("\n")


if __name__ == "__main__":
    asyncio.run(main())
  • Enhanced Functionality:
    • Changed some methods, exceptions and functions names for better comprehension and future use.
    • Fixed use_proxy typing in __init__ method of SydneyClient
    • Added delete_current_conversation method to delete individual conversations.

Testing:

  • Tested the new force_conv_deletion_on_exit_signal functionality.
  • Verified that the create_conversation_context method creates the correct context.
  • Confirmed that all the new functions, methods and exceptions names work correctly.
  • Validated the delete_current_conversation method functionality.
  • Ran all existing tests to ensure no regressions.

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.

@Luneye Luneye changed the title Refactor SydneyClient with New Conversation Handling and Additional Functionalities Refactor SydneyClient (Added GPT4-o for Creative Mode, Long Conversation Handling, Additional Functionalities and Minor Bug Fixes) Jul 6, 2024
@Luneye Luneye changed the title Refactor SydneyClient (Added GPT4-o for Creative Mode, Long Conversation Handling, Additional Functionalities and Minor Bug Fixes) Refactor SydneyClient (Added GPT-4o for Creative Mode, Long Conversation Handling, Additional Functionalities and Minor Bug Fixes) Jul 6, 2024
@vsakkas vsakkas self-requested a review July 9, 2024 08:04
Luneye and others added 9 commits September 8, 2024 21:09
…unctionalities

- Introduced orce_conv_deletion_on_exit_signal flag for auto-deletion of conversations on exit.
- Added create_conversation_context method for context creation from a list of messages.
- Modified start_new_conversation method to reflect new endpoint handling.
- Enhanced _ask method to handle new WebSocket responses.
- Implemented quit_current_and_start_new_conversation and quit_current_conversation methods for better session management.
- Added delete_current_conversation method to delete individual conversations.
- Improved type annotations and attribute initializations.
- Minor bug fixes and optimizations.
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