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

Streaming Is Not Supported #103

Open
dashi6174 opened this issue Nov 29, 2024 · 1 comment · May be fixed by #105
Open

Streaming Is Not Supported #103

dashi6174 opened this issue Nov 29, 2024 · 1 comment · May be fixed by #105
Labels
in-roadmap Item is planned for a future release as part of roadmap

Comments

@dashi6174
Copy link

import os

import aisuite as ai
client = ai.Client()

models = ["anthropic:claude-3-5-sonnet-20240620"]

os.environ['ANTHROPIC_BASE_URL'] = 'http://api.sundray.work'
os.environ['ANTHROPIC_API_KEY'] = 'sk-'

messages = [
    {"role": "system", "content": "Respond in Pirate English."},
    {"role": "user", "content": "Tell me a joke."},
]

for model in models:
    response = client.chat.completions.create(
        model=model,
        messages=messages,
        temperature=0.75,
        stream=True
    )
    print(response.choices[0].message.content)

The following error occurs
image

@1345822
Copy link

1345822 commented Nov 29, 2024

Here, a module named aisuite is imported and renamed ai. Errors may occur here. If the aisuite module is not installed correctly, Python will throw a ModuleNotFoundError. You need to make sure that the module and its dependencies have been installed through PIPIPInstall or other suitable installation methods.

yusefes added a commit to yusefes/aisuite that referenced this issue Nov 29, 2024
Fixes andrewyng#103

Add support for streaming responses in the Anthropic provider.

* Handle the `stream` parameter in the `chat_completions_create` method in `aisuite/providers/anthropic_provider.py`.
* Use `handle_streaming_response` method to process streaming responses.
* Add a test case for the `stream` parameter in `tests/client/test_client.py`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/andrewyng/aisuite/issues/103?shareId=XXXX-XXXX-XXXX-XXXX).
@yusefes yusefes linked a pull request Nov 29, 2024 that will close this issue
@ksolo ksolo added the in-roadmap Item is planned for a future release as part of roadmap label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-roadmap Item is planned for a future release as part of roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants