gpt4 book ai didi

python - 如何修复 TypeError : load() missing 1 required positional argument: 'Loader' error in Colab?

转载 作者:行者123 更新时间:2023-12-02 22:46:16 29 4
gpt4 key购买 nike

我正在尝试运行 this notebook在 Colab 中。

from openai.embeddings_utils import get_embedding

# This will take just under 10 minutes
df['babbage_similarity'] = df.combined.apply(lambda x: get_embedding(x, engine='text-similarity-babbage-001'))
df['babbage_search'] = df.combined.apply(lambda x: get_embedding(x, engine='text-search-babbage-doc-001'))
df.to_csv('/content/documents.csv')

当我尝试运行此代码块时失败了——我收到此错误:

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-31-b04fdb9f95d8> in <module>()
5
6
----> 7 from openai.embeddings_utils import get_embedding
8
9 # This will take just under 10 minutes

10 frames
/usr/local/lib/python3.7/dist-packages/distributed/config.py in <module>()
18
19 with open(fn) as f:
---> 20 defaults = yaml.load(f)
21
22 dask.config.update_defaults(defaults)

TypeError: load() missing 1 required positional argument: 'Loader'

根据谷歌搜索,这似乎是 Colab 特有的版本问题。但我无法修复它。有什么想法吗?

最佳答案

config.py 中:

替换这个:

with open(fn) as f:
defaults = yaml.load(f)

用这个:

with open(fn) as f:
defaults = yaml.safe_load(f)

关于python - 如何修复 TypeError : load() missing 1 required positional argument: 'Loader' error in Colab?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70981856/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com