Skip to main content

迁移指南 - LiteLLM v1.0.0+

当我们进行重大变更(例如从1.x.x升级到2.x.x)时,我们将在本指南中记录这些变更。

1.0.0

重大变更前的最后一次发布:0.14.0

变更内容

  • 需要 openai>=1.0.0
  • openai.InvalidRequestErroropenai.BadRequestError
  • openai.ServiceUnavailableErroropenai.APIStatusError
  • 新增 litellm 客户端,允许用户传递 api_key
    • litellm.Litellm(api_key="sk-123")
  • 响应对象现在继承自 BaseModel(之前是 OpenAIObject
  • 新增 默认异常 - APIConnectionError(之前是 APIError
  • litellm.get_max_tokens() 现在返回一个整数而不是字典
    max_tokens = litellm.get_max_tokens("gpt-3.5-turbo") # 返回一个整数而不是字典
    assert max_tokens==4097
  • 流式传输 - OpenAI 数据块现在对空流数据块返回 None。以下是如何处理包含内容的流数据块
    response = litellm.completion(model="gpt-3.5-turbo", messages=messages, stream=True)
    for part in response:
    print(part.choices[0].delta.content or "")

如何更好地传达变更? 告诉我们

优云智算