迁移指南
迁移到0.2版本
openai v1 是对库的完全重写,包含了许多重大变更。例如,推理过程需要实例化一个客户端,而不是使用全局类方法。
因此,pyautogen<0.2 的用户需要进行一些更改。
api_base->base_url,request_timeout->timeout在llm_config和config_list中。max_retry_period和retry_wait_time已被弃用。可以为每个客户端设置max_retries。- MathChat 在未来版本中测试之前将不被支持。
autogen.Completion和autogen.ChatCompletion已弃用。主要功能已移至autogen.OpenAIWrapper:
from autogen import OpenAIWrapper
client = OpenAIWrapper(config_list=config_list)
response = client.create(messages=[{"role": "user", "content": "2+2="}])
print(client.extract_text_or_completion_object(response))
- 推理参数调优和推理日志记录功能已更新:
import autogen.runtime_logging
# Start logging
autogen.runtime_logging.start()
# Stop logging
autogen.runtime_logging.stop()
查看Logging文档和Logging示例笔记本以了解更多。
推理参数调优可以通过flaml.tune来完成。
seedin autogen is renamed intocache_seedto accommodate the newly addedseedparam in openai chat completion api.use_cacheis removed as a kwarg inOpenAIWrapper.create()for being automatically decided bycache_seed: int | None. The difference between autogen'scache_seedand openai'sseedis that:- autogen 使用本地磁盘缓存来确保相同的输入产生完全相同的输出,并且当命中缓存时,不会进行 openai api 调用。
- openai的
seed是一种尽力而为的确定性采样,并不保证完全的确定性。当使用openai的seed且将cache_seed设置为None时,即使对于相同的输入,也会调用openai api,并且无法保证获得完全相同的输出。