赞
踩
gpt4free很牛,用过的都知道!gpt4free已经升级到0.0.1.4版本,使用方法跟以前略有区别。首先新版本的gpt4free只支持python3.10以上的版本,所以重新安装了python3.10环境。
刚开始用源代码编译编译安装,但是走了弯路,最后用Miniconda包安装,才最终成功。以下就是安装和使用中碰到的问题记录。
pip install g4f
使用的时候报错:
from google.protobuf.internal import type_checkers
File "/home/skywalk/py10/lib/python3.10/site-packages/google/protobuf/internal/type_checkers.py", line 48, in <module>
import ctypes
File "/home/skywalk/py310/lib/python3.10/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
把protobuf版本降低到3.20 ,报错:
File "/home/skywalk/py10/lib/python3.10/site-packages/pandas/compat/compressors.py", line 7, in <module>
import bz2
File "/home/skywalk/py310/lib/python3.10/bz2.py", line 17, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
把pandas的版本升级到2.1.0rc0 ,结果又出现了ctypes报错;
File "/home/skywalk/py10/lib/python3.10/site-packages/pandas/errors/__init__.py", line 6, in <module>
import ctypes
File "/home/skywalk/py310/lib/python3.10/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
很明显很多库新版本用ctypes都有点问题啊!
最后实在搞不定,装3.10版本Miniconda环境,问题解决。
现在有了新的报错:
raise OSError(errno.ENOSPC, "inotify watch limit reached")
OSError: [Errno 28] inotify watch limit reached
这个报错是系统报错,暂时问题不大,先不管它。
安装gpt4free pip install g4f
安装相关库:进入gpt4free目录,pip install -r requirements.txt
安装streamlit库:pip install streamlit
安装js2py库:pip install js2py
写app_streamlit0.1.4.py 文件:
- mport os
- import sys
-
- sys.path.append(os.path.join(os.path.dirname(__file__), os.path.pardir))
- import g4f
- import streamlit as st
- from g4f.Provider import DeepAi
- def get_answer(question: str) -> str:
- # Set cloudflare clearance cookie and get answer from GPT-4 model
- try:
- tmp = ""
- response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=DeepAi, messages=[
- {"role": "user", "content": question }], stream=True)
- for message in response:
- #print(message)
- tmp += message
- status.text(tmp)
- return tmp
-
-
- except Exception as e:
- # Return error message if an exception occurs
- return (
- f'An error occurred: {e}. Please make sure you are using a valid cloudflare clearance token and user agent.'
- )
-
-
- # Set page configuration and add header
- st.set_page_config(
- page_title="gpt4freeGUI",
- initial_sidebar_state="expanded",
- page_icon="声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/237999推荐阅读
相关标签
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。