vsakkas / sydney.py

Python Client for Copilot (formerly named Bing Chat), also known as Sydney.
MIT License
239 stars 31 forks source link

How to ask without streaming ? #145

Closed TheLime1 closed 5 months ago

TheLime1 commented 5 months ago

id appreciate and example without streaming!


import asyncio

from sydney import SydneyClient

async def main() -> None:
    async with SydneyClient() as sydney:
        while True:
            prompt = input("You: ")

            if prompt == "!reset":
                await sydney.reset_conversation()
                continue
            elif prompt == "!exit":
                break

            print("Sydney: ", end="", flush=True)
            async for response in sydney.ask_stream(prompt):
                print(response, end="", flush=True)
            print("\n")

if __name__ == "__main__":
    asyncio.run(main())
vsakkas commented 5 months ago

Hi @TheLime1

Something like this could work:

import asyncio

from sydney import SydneyClient

async def main() -> None:
    async with SydneyClient() as sydney:
        while True:
            prompt = input("You: ")

            if prompt == "!reset":
                await sydney.reset_conversation()
                continue
            elif prompt == "!exit":
                break

            response = await sydney.ask(prompt)
            print(f"Sydney: {response}")

if __name__ == "__main__":
    asyncio.run(main())

You can also find more examples on the README

TheLime1 commented 5 months ago

thanks very much