andrewyng / aisuite

Simple, unified interface to multiple Generative AI providers
MIT License
5.31k stars 449 forks source link

Streaming Is Not Supported #103

Open dashi6174 opened 22 hours ago

dashi6174 commented 22 hours ago
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 commented 19 hours ago

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.