不会代码,使用ChatGPT转化的
转化的sh文件
#!/bin/bash
设置虚拟环境变量
VENV_NAME=venv
如果虚拟环境不存在,则创建一个虚拟环境
if [ ! -d "$VENV_NAME" ]; then
echo "Creating virtual environment $VENV_NAME..."
python3 -m venv $VENV_NAME
fi
显示虚拟环境已准备就绪
echo "Virtual environment $VENV_NAME is ready."
激活虚拟环境
echo "Activating Virtual environment!"
source ./venv/bin/activate
检查库更新
REQUIREMENTS="requirements.txt"
LAST_MODIFIED="requirements.temp"
检查 requirements.txt 文件是否存在
if [ ! -f "$REQUIREMENTS" ]; then
echo "Error: requirements.txt not found"
exit 1
fi
检查 last_modified.txt 文件是否存在
if [ ! -f "$LAST_MODIFIED" ]; then
echo "0" > "$LAST_MODIFIED"
fi
检查 requirements.txt 文件是否被修改
mod_date=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M:%S" "$REQUIREMENTS")
last_mod_date=$(cat "$LAST_MODIFIED")
if [ "$mod_date" != "$last_mod_date" ]; then
pip3 install -r $REQUIREMENTS
echo "$mod_date" > "$LAST_MODIFIED"
clear
echo "Requirements file has been modified. Updated complete!"
else
echo "Requirements file has not been modified. Skipping update."
fi
运行 SumGPT.py 程序
streamlit run src/SumGPT.py
报错内容
2023-04-13 22:47:24.330 Uncaught app exception
Traceback (most recent call last):
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/SumGPT.py", line 2, in
import Components
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/Components/init.py", line 1, in
from Components import sidebar
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/Components/sidebar.py", line 2, in
import GPT
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/GPT/init.py", line 1, in
from GPT import misc
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/GPT/misc.py", line 48, in
def predict_token_single(chunk: Dict[str, Union[str, float]] | str, max_tokens: int = None) -> int:
TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'type'
2023-04-13 22:47:28.079 Uncaught app exception
Traceback (most recent call last):
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/SumGPT.py", line 2, in
import Components
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/Components/init.py", line 1, in
from Components import sidebar
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/Components/sidebar.py", line 2, in
import GPT
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/GPT/init.py", line 1, in
from GPT import misc
File "/Users/sing/Downloads/333333/SumGPT-1.0.5/src/GPT/misc.py", line 48, in
def predict_token_single(chunk: Dict[str, Union[str, float]] | str, max_tokens: int = None) -> int:
TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'type'