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

Feat: add supports for stream mode #79

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

Conversation

RockChinQ
Copy link

Changes

  • Add query method to wrap both stream and non-stream requests
  • Make send_message a wrapper of non-stream mode request method
  • Modified README

Related Issues

Test Case

from claude_api import Client

cookie_str = "fill cookie here"

claude = Client(cookie_str)

conversation_id = claude.create_new_chat()['uuid']

stream = False

gen = claude.query(
    prompt="What is the meaning of life?",
    conversation_id=conversation_id,
    stream=stream,
)

import time

if stream:
    for msg in gen:
        print(time.time(), msg)
        
else:
    print(gen)

@RockChinQ RockChinQ marked this pull request as ready for review October 7, 2023 04:06
@RockChinQ
Copy link
Author

Method query() returns a generator of str type when stream=True, it generates plain text of each tokens.
Returns plain text of response once when stream=False or by default.

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.

None yet

1 participant