迁移指南 - LiteLLM v1.0.0+
当出现破坏性变更时(例如从 1.x.x 升级到 2.x.x),我们将在此处记录这些更改。
1.0.0
破坏性变更前的最后一个版本: 0.14.0
有哪些变更?
- 需要
openai>=1.0.0 openai.InvalidRequestError→openai.BadRequestErroropenai.ServiceUnavailableError→openai.APIStatusError- 新增 litellm 客户端,允许用户传入 api_key
litellm.Litellm(api_key="sk-123")
- 响应对象现在继承自
BaseModel(之前为OpenAIObject) - 新增 默认异常 -
APIConnectionError(之前为APIError) - litellm.get_max_tokens() 现在返回 int 类型,不再返回 dict
max_tokens = litellm.get_max_tokens("gpt-3.5-turbo") # returns an int not a dict
assert max_tokens==4097 - 流式传输 - OpenAI Chunks 现在为空流块返回
None。这是处理带内容流块的方法response = litellm.completion(model="gpt-3.5-turbo", messages=messages, stream=True)
for part in response:
print(part.choices[0].delta.content or "")
我们如何能更好地沟通变更? 请告诉我们
- Discord
- 电子邮件 (support@berri.ai)