Skip to content

Feat: add supports for stream mode#79

Open
RockChinQ wants to merge 3 commits intoKoushikNavuluri:mainfrom
RockChinQ:main
Open

Feat: add supports for stream mode#79
RockChinQ wants to merge 3 commits intoKoushikNavuluri:mainfrom
RockChinQ:main

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.

1 participant