教程链接
准备
- Qwen key
- Deepseek key
- Python 3.10.11
tedczj@czj-MBP auto-coder % sudo vi /etc/zshenv
export MODEL_DEEPSEEK_TOKEN = sk-mockkey
export MODEL_QIANWEN_TOKEN = sk-mockkey
tedczj@czj-MBP auto-coder % source /etc/zshenv
安装auto-coder
- 注意: auto-coder使用的虚拟环境不要初始化在相关项目的目录下 ,因为后面auto-coder运行的时候默认会对工程目录下的文件使用Deepseek api进行index ,效果就是你要等很久并且Deepseek会扣很多钱。我的经历是等了一晚上,index了2000多个文件, Deepseek里充的10块钱被扣没了。
- 解决方案:按照下面在项目根目录外的目录,手动初始化虚拟环境,创建项目后手动设置关联即可
tedczj@czj-MBP auto-coder-venv % python3.10 -m venv auto-coder
tedczj@czj-MBP auto-coder-venv % source ./auto-coder/bin/activate
(auto-coder) tedczj@czj-MBP auto-coder-venv % pip install -U auto-coder
#pycharm setting -> Python Interpreter -> Add Interpreter -> Add Local Interpreter -> Virtualenv Environment -> Existing -> Interpreter 那里选择 /Users/tedczj/WorkPlace/auto-coder-venv/bin/python3.10
(auto-coder) tedczj@czj-MBP auto-coder-venv % ray start --head
Enable usage stats collection? This prompt will auto-proceed in 10 seconds to avoid blocking cluster startup. Confirm [Y/n]:
Usage stats collection is enabled. To disable this, add `--disable-usage-stats` to the command that starts the cluster, or run the following command: `ray disable-usage-stats` before starting the cluster. See https://docs.ray.io/en/master/cluster/usage-stats.html for more details.
Local node IP: 127.0.0.1
--------------------
Ray runtime started.
--------------------
Next steps
To connect to this Ray cluster:
import ray
ray.init()
To submit a Ray job using the Ray Jobs CLI:
RAY_ADDRESS='http://127.0.0.1:8265' ray job submit --working-dir . -- python my_script.py
See https://docs.ray.io/en/latest/cluster/running-applications/job-submission/index.html
for more information on submitting Ray jobs to the Ray cluster.
To terminate the Ray runtime, run
ray stop
To view the status of the cluster, use
ray status
To monitor and debug Ray, view the dashboard at
127.0.0.1:8265
If connection to the dashboard fails, check your firewall settings and network configuration.
启动推荐的模型代理
大语言模型
easy-byzerllm deploy deepseek-chat --token $MODEL_DEEPSEEK_TOKEN --alias deepseek_chat
Command Line Arguments:
--------------------------------------------------
command : deploy
ray_address : auto
num_workers : 1
worker_concurrency : 10
gpus_per_worker : 0.0
cpus_per_worker : 0.001
model_path :
pretrained_model_type: saas/openai
model : deepseek_chat
infer_backend :
infer_params : {'saas.base_url': 'https://api.deepseek.com/v1', 'saas.api_key': '******', 'saas.model': 'deepseek-chat'}
file : None
--------------------------------------------------
✓ Ray is already running
2024-08-04 00:23:58,711 INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...
2024-08-04 00:23:58,719 INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
Model deepseek_chat already deployed
easy-byzerllm chat deepseek_chat "你好" ✔ 14s auto-coder
Command Line Arguments:
--------------------------------------------------
command : query
ray_address : auto
model : deepseek_chat
query : 你好
template : auto
file : None
output_file :
--------------------------------------------------
✓ Ray is already running
2024-08-04 01:04:17,788 INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...
2024-08-04 01:04:17,797 INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
你好!欢迎使用语言模型进行交流。有什么我可以帮助你的吗?
向量模型
(auto-coder) tedczj@czj-MBP auto-coder % byzerllm deploy --pretrained_model_type saas/qianwen \
--cpus_per_worker 0.001 \
--gpus_per_worker 0 \
--num_workers 2 \
--infer_params saas.api_key=${MODEL_QIANWEN_TOKEN} saas.model=text-embedding-v2 \
--model qianwen_emb
Command Line Arguments:
--------------------------------------------------
command : deploy
ray_address : auto
num_workers : 2
worker_concurrency : 1
gpus_per_worker : 0.0
cpus_per_worker : 0.001
model_path :
pretrained_model_type: saas/qianwen
model : qianwen_emb
infer_backend :
infer_params : {'saas.api_key': '******', 'saas.model': 'text-embedding-v2'}
file : None
--------------------------------------------------
2024-05-30 00:12:45,114 INFO worker.py:1564 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...
2024-05-30 00:12:45,121 INFO worker.py:1740 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
Failed to look up actor with name 'qianwen_emb'. This could because 1. You are trying to look up a named actor you didn't create. 2. The named actor died. 3. You did not use a namespace matching the namespace of the actor.
(UDFWorker pid=85936) MODEL[qianwen_emb] Init Model,It may take a while.
(UDFWorker pid=85936) MODEL[qianwen_emb] Successful to init model, time taken:0.0016932487487792969s
Model qianwen_emb deployed successfully
(UDFWorker pid=85935) MODEL[qianwen_emb] Init Model,It may take a while.
(UDFWorker pid=85935) MODEL[qianwen_emb] Successful to init model, time taken:0.001352071762084961s
(auto-coder) tedczj@czj-MBP auto-coder %
初始化已有项目
(auto-coder) tedczj@czj-MBP auto-coder % auto-coder init --source_dir .
Command Line Arguments:
--------------------------------------------------
source_dir : .
git_url : None
target_file : None
query : None
template : common
project_type : py
execute : False
package_name :
script_path :
model :
model_max_length : 2000
model_max_input_length: 6000
vl_model :
sd_model :
emb_model :
index_model :
index_model_max_length: 0
index_model_max_input_length: 0
index_model_anti_quota_limit: 0
index_filter_level : 0
index_filter_workers: 1
code_model :
index_build_workers : 1
file : None
ray_address : auto
anti_quota_limit : 1
skip_build_index : True
print_request : False
py_packages :
search :
search_engine :
search_engine_token :
enable_rag_search : False
enable_rag_context : False
auto_merge : False
image_file :
image_mode : direct
image_max_iter : 1
human_as_model : False
urls :
urls_use_model : False
enable_multi_round_generate: False
command : init
doc_command : None
required_exts : None
collection : None
collections : None
description :
skip_confirm : False
exclude_files :
output :
single_file : False
--------------------------------------------------
2024-05-30 00:15:36.530 | INFO | autocoder.common.git_utils:init:15 - Initialized new Git repository at /Users/tedczj/WorkPlace/auto-coder
Successfully initialized auto-coder project in /Users/tedczj/WorkPlace/auto-coder.
# 项目根目录下生成了.auto-coder,actions 两个目录
(auto-coder) tedczj@czj-MBP auto-coder % ls -a
. .. .DS_Store .auto-coder .git .idea actions auto-coder main.py
# actions下生成了101_current_work.yml
(auto-coder) tedczj@czj-MBP auto-coder % ls -l actions
total 16
-rw-r--r--@ 1 tedczj staff 4787 May 30 00:15 101_current_work.yml
新手任务 - 计算器
- 流程:auto-coder生成promot, 用户复制promot给网页版对话模型,再把生成的代码拷回工程里
- actions 目录下新建000_example_calculator.yml
include_file:
- ./base/base.yml
- ./base/enable_index.yml
- ./base/enable_wholefile.yml
query: |
在 src 目录下创建app.py, 在该文件中实现一个计算器,使用 gradio 来实现。
tedczj@czj-MBP auto-coder % source ../auto-coder-venv/bin/activate
(auto-coder-venv) tedczj@czj-MBP auto-coder % auto-coder --file actions/000_example_calculator.yml
2024-08-11 00:35:22.364 | INFO | autocoder.auto_coder:load_include_files:70 - Loading include file: /Users/tedczj/WorkPlace/auto-coder/actions/base/base.yml
2024-08-11 00:35:22.365 | INFO | autocoder.auto_coder:load_include_files:70 - Loading include file: /Users/tedczj/WorkPlace/auto-coder/actions/base/enable_index.yml
2024-08-11 00:35:22.365 | INFO | autocoder.auto_coder:load_include_files:70 - Loading include file: /Users/tedczj/WorkPlace/auto-coder/actions/base/enable_wholefile.yml
Command Line Arguments:
--------------------------------------------------
request_id :
source_dir : /Users/tedczj/WorkPlace/auto-coder
git_url : None
target_file : /Users/tedczj/WorkPlace/auto-coder/output.txt
query : 在 src 目录下创建app.py, 在该文件中实现一个计算器,使用 gradio 来实现。
template : common
project_type : py
execute : True
package_name :
script_path :
model : deepseek_chat
model_max_length : 2000
model_max_input_length: 30000
vl_model :
sd_model :
emb_model :
text2voice_model :
voice2text_model :
index_model :
index_model_max_length: 0
index_model_max_input_length: 0
index_model_anti_quota_limit: 0
index_filter_level : 1
index_filter_workers: 4
code_model :
index_build_workers : 4
planner_model :
file : actions/000_example_calculator.yml
ray_address : auto
anti_quota_limit : 0
skip_build_index : False
print_request : False
py_packages :
search :
search_engine :
search_engine_token :
enable_rag_search : False
enable_rag_context : False
rag_url :
rag_token :
auto_merge : True
image_file :
image_mode : direct
image_max_iter : 1
human_as_model : True
urls :
urls_use_model : False
enable_multi_round_generate: False
command : None
doc_command : None
required_exts : None
collection : None
collections : None
description :
skip_confirm : False
silence : False
exclude_files :
output :
single_file : False
query_prefix : None
query_suffix : None
from_yaml : None
base_dir : None
context : None
editblock_similarity: 0.9
new_session : False
--------------------------------------------------
2024-08-11 00:35:22,425 INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...
2024-08-11 00:35:22,432 INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
2024-08-11 00:35:22.483 | INFO | autocoder.index.index:build_index_and_filter_files:456 - Building index for all files...
2024-08-11 00:35:22.483 | INFO | autocoder.index.index:build_index:255 - Total Files: 3, Need to Build Index: 1
2024-08-11 00:35:22.484 | INFO | autocoder.index.index:build_index_and_filter_files:460 - Finding related files in the index...
2024-08-11 00:35:22.484 | INFO | autocoder.index.index:get_target_files_by_query:401 - Find the related files by query according to the files...
2024-08-11 00:35:27.003 | INFO | autocoder.index.index:get_target_files_by_query:406 - Find the related files by query according to the symbols...
2024-08-11 00:35:31.331 | INFO | autocoder.index.index:build_index_and_filter_files:486 - Find related files took 8.85s
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Target Files You Selected │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │
│ ┃ File Path ┃ Reason ┃ │
│ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │
│ │ /Users/tedczj/WorkPlace/auto-coder/src/server.py │ 该文件位于 src 目录下,且主要用于创建 FastAPI 应用,可能与新创建的 app.py 文件有功能上的关联。 │ │
│ │ /Users/tedczj/WorkPlace/auto-coder/src/app.py │ 用户要求在 src 目录下创建 app.py 文件,用于实现一个计算器,使用 gradio 来实现。 │ │
│ └──────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
2024-08-11 00:37:32.236 | INFO | autocoder.dispacher.actions.action:process_content:239 - Auto generate the code...
Intercepted request to model: deepseek_chat
Instruction to model saved in /Users/tedczj/WorkPlace/auto-coder/output.txt and copied to clipboard:
当前项目目录结构:
1. 项目根目录: /Users/tedczj/WorkPlace/auto-coder
2. 项目子目录/文件列表(类似tree 命令输出):
main.py
src/
...
>
键盘移动光标选中第二行, 鼠标点ok 此时promot 已经在output.txt和剪贴板上了,复制给gpt后得到结果,粘贴在app.py中
pip install gradio
python3 ./src/app.py
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Matplotlib is building the font cache; this may take a moment.
访问 http://127.0.0.1:7860 第一次计算时特别慢,后面就好了。 这个模式是auto-coder帮你写提示词,使用在线chatbot来生成代码自己再贴回来,感觉不太丝滑,下面试试让auto-coder直接生成代码
新手任务 - hello world
- 注意这次下面的提示框给了app.py和main.py让我选,我选择了cancel, 于是写入了server.py
project_type: py
include_file:
- ./base/base.yml
- ./base/enable_index.yml
- ./base/enable_wholefile.yml
human_as_model: false
query: |
帮我在项目根目录下创建一个 src/server.py, 使用 fastapi ,创建一个 /hello 接口,返回 'hello world'
auto-coder % auto-coder --file actions/000_example.yml
2024-08-11 00:51:32.188 | INFO | autocoder.auto_coder:load_include_files:70 - Loading include file: /Users/tedczj/WorkPlace/auto-coder/actions/base/base.yml
2024-08-11 00:51:32.188 | INFO | autocoder.auto_coder:load_include_files:70 - Loading include file: /Users/tedczj/WorkPlace/auto-coder/actions/base/enable_index.yml
2024-08-11 00:51:32.189 | INFO | autocoder.auto_coder:load_include_files:70 - Loading include file: /Users/tedczj/WorkPlace/auto-coder/actions/base/enable_wholefile.yml
Command Line Arguments:
--------------------------------------------------
request_id :
source_dir : /Users/tedczj/WorkPlace/auto-coder
git_url : None
target_file : /Users/tedczj/WorkPlace/auto-coder/output.txt
query : 帮我在项目根目录下创建一个 src/server.py, 使用 fastapi ,创建一个 /hello 接口,返回 world.
template : common
project_type : py
execute : True
package_name :
script_path :
model : deepseek_chat
model_max_length : 2000
model_max_input_length: 30000
vl_model :
sd_model :
emb_model :
text2voice_model :
voice2text_model :
index_model :
index_model_max_length: 0
index_model_max_input_length: 0
index_model_anti_quota_limit: 0
index_filter_level : 1
index_filter_workers: 4
code_model :
index_build_workers : 4
planner_model :
file : actions/000_example.yml
ray_address : auto
anti_quota_limit : 0
skip_build_index : False
print_request : False
py_packages :
search :
search_engine :
search_engine_token :
enable_rag_search : False
enable_rag_context : False
rag_url :
rag_token :
auto_merge : True
image_file :
image_mode : direct
image_max_iter : 1
human_as_model : False
urls :
urls_use_model : False
enable_multi_round_generate: False
command : None
doc_command : None
required_exts : None
collection : None
collections : None
description :
skip_confirm : False
silence : False
exclude_files :
output :
single_file : False
query_prefix : None
query_suffix : None
from_yaml : None
base_dir : None
context : None
editblock_similarity: 0.9
new_session : False
--------------------------------------------------
2024-08-11 00:51:32,248 INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...
2024-08-11 00:51:32,255 INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
2024-08-11 00:51:32.304 | INFO | autocoder.index.index:build_index_and_filter_files:456 - Building index for all files...
2024-08-11 00:51:32.304 | INFO | autocoder.index.index:build_index:255 - Total Files: 3, Need to Build Index: 1
2024-08-11 00:51:32.305 | INFO | autocoder.index.index:build_index_and_filter_files:460 - Finding related files in the index...
2024-08-11 00:51:32.305 | INFO | autocoder.index.index:get_target_files_by_query:401 - Find the related files by query according to the files...
2024-08-11 00:51:40.455 | INFO | autocoder.index.index:get_target_files_by_query:406 - Find the related files by query according to the symbols...
2024-08-11 00:51:44.477 | INFO | autocoder.index.index:build_index_and_filter_files:486 - Find related files took 12.17s
╭────────────────────────╮
│ │
│ Target Files You │
│ Selected │
│ ┏━━━━━━━━━━━┳━━━━━━━━┓ │
│ ┃ File Path ┃ Reason ┃ │
│ ┡━━━━━━━━━━━╇━━━━━━━━┩ │
│ └───────────┴────────┘ │
│ │
╰────────────────────────╯
2024-08-11 00:52:00.753 | INFO | autocoder.dispacher.actions.action:process_content:239 - Auto generate the code...
2024-08-11 00:52:04.121 | INFO | autocoder.dispacher.actions.action:process_content:278 - Auto merge the code...
2024-08-11 00:52:04.291 | INFO | autocoder.common.code_auto_merge:merge_code:135 - Upsert path: /Users/tedczj/WorkPlace/auto-coder/src/server.py
2024-08-11 00:52:04.292 | INFO | autocoder.common.code_auto_merge:merge_code:139 - Merged 1 files into the project.
╭─────────────────────────────── Git Commit Summary ───────────────────────────────╮
│ Commit Information (Use /revert to revert this commit) │
│ ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │
│ ┃ Attribute ┃ Value ┃ │
│ ┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │
│ │ Commit Hash │ 2a6fc4255fe025d6f567ed173931d74b67ec819c │ │
│ │ Commit Message │ auto_coder_000_example.yml_939ffeeb3ff62730b47acecb9a6204ac │ │
│ │ Changed Files │ src/server.py │ │
│ └────────────────┴─────────────────────────────────────────────────────────────┘ │
╰──────────────────────────────────────────────────────────────────────────────────╯
File: src/server.py
╭─────────────────── File Diff ───────────────────╮
│ 1 diff --git a/src/server.py b/src/server.py │
│ 2 index e69de29..d1630cc 100644 │
│ 3 --- a/src/server.py │
│ 4 +++ b/src/server.py │
│ 5 @@ -0,0 +1,7 @@ │
│ 6 +from fastapi import FastAPI │
│ 7 + │
│ 8 +app = FastAPI() │
│ 9 + │
│ 10 +@app.get("/hello") │
│ 11 +def read_hello(): │
│ 12 + return {"message": "world"} │
│ 13 \ No newline at end of file │
╰─────────────────────────────────────────────────╯
pip install fastapi
pip install "fastapi[standard]"
fastapi dev ./src/server.py
INFO Using path src/server.py
INFO Resolved absolute path /Users/tedczj/WorkPlace/auto-coder/src/server.py
INFO Searching for package file structure from directories with __init__.py files
INFO Importing from /Users/tedczj/WorkPlace/auto-coder/src
╭─ Python module file ─╮
│ │
│ 🐍 server.py │
│ │
╰──────────────────────╯
INFO Importing module server
INFO Found importable FastAPI app
╭─ Importable FastAPI app ─╮
│ │
│ from server import app │
│ │
╰──────────────────────────╯
INFO Using import string server:app
╭────────── FastAPI CLI - Development mode ───────────╮
│ │
│ Serving at: http://127.0.0.1:8000 │
│ │
│ API docs: http://127.0.0.1:8000/docs │
│ │
│ Running in development mode, for production use: │
│ │
│ fastapi run │
│ │
╰─────────────────────────────────────────────────────╯
INFO: Will watch for changes in these directories: ['/Users/tedczj/WorkPlace/auto-coder']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [5795] using WatchFiles
INFO: Started server process [5799]
INFO: Waiting for application startup.
INFO: Application startup complete.
浏览器输入:http://127.0.0.1:8000/hello, 终于看到了hello world
问题解决
- pip install -U auto-coder 报错
cc -I/usr/include -I/usr/include/libxml2 -c /var/folders/g9/2xx_dsj950sf3ts7wxgz_w9r0000gn/T/xmlXPathInitl54m0xjd.c -o var/folders/g9/2xx_dsj950sf3ts7wxgz_w9r0000gn/T/xmlXPathInitl54m0xjd.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
<string>:67: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
Perhaps try: xcode-select --install
*********************************************************************************
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for lxml
Successfully built jieba patch pyperclip transformers-stream-generator
Failed to build lxml
ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects
xcode-select --install 后重新运行 pip install -U auto-coder , 解决
- SOCKS报错
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/httpx/_transports/default.py", line 175, in __init__
raise ImportError(
ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.
解决:pip install 'httpx[socks]'
- deepseek-chat部署失败
easy-byzerllm deploy deepseek-chat --token $MODEL_DEEPSEEK_TOKEN --alias deepseek_chat ✔ 38s auto-coder
usage: easy-byzerllm deploy [-h] --token TOKEN [--ray_address RAY_ADDRESS] [--infer_params INFER_PARAMS] [--base_url BASE_URL] [--alias ALIAS] model
easy-byzerllm deploy: error: argument --token: expected one argument
解决 echo $MODEL_DEEPSEEK_TOKEN 看下,环境变量没有生效
- easy-byzerllm chat deepseek_chat "你好" 失败
~/w/auto_coder easy-byzerllm chat deepseek_chat "你好"
Command Line Arguments:
--------------------------------------------------
command : query
ray_address : auto
model : deepseek_chat
query : 你好
template : auto
file : None
output_file :
--------------------------------------------------
✓ Ray is already running
2024-08-04 00:47:51,087 INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...
2024-08-04 00:47:51,096 INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
2024-08-04 00:47:51,570 ERROR serialization.py:425 -- Failed to unpickle serialized exception
Traceback (most recent call last):
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/ray/exceptions.py", line 50, in from_ray_exception
return pickle.loads(ray_exception.serialized_exception)
TypeError: APIStatusError.__init__() missing 2 required keyword-only arguments: 'response' and 'body'
解决:
http://127.0.0.1:8265/ 下找到对应udf workder
stdout里看到:
Error: Authentication Fails (no such user)
感觉是token问题,然后执行
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MODEL_DEEPSEEK_TOKEN" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"stream": false
}'
Authentication Fails (auth header format should be Bearer sk-...)
再检查了一下发现是环境变量里deepseek和千问的配反了
解决:
//删除部署的模型
easy-byzerllm undeploy deepseek_chat --force
编辑/etc/zshenv
//环境变量生效
source /etc/zshenv
easy-byzerllm deploy deepseek-chat --token $MODEL_DEEPSEEK_TOKEN --alias deepseek_chat
easy-byzerllm chat deepseek_chat "你好" ✔ 14s auto-coder
Command Line Arguments:
--------------------------------------------------
command : query
ray_address : auto
model : deepseek_chat
query : 你好
template : auto
file : None
output_file :
--------------------------------------------------
✓ Ray is already running
2024-08-04 01:04:17,788 INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 127.0.0.1:6379...
2024-08-04 01:04:17,797 INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
你好!欢迎使用语言模型进行交流。有什么我可以帮助你的吗?
- easy-byzerllm chat deepseek_chat "你好" 成功后电脑重启,重新执行时ray start报错
- 关联github issue: github.com/allwefantas…
easy-byzerllm chat deepseek_chat "你好"
ray start --head 1 ✘ auto-coder
Usage stats collection is enabled. To disable this, add --disable-usage-stats to the command that starts the cluster, or run the following command: ray disable-usage-stats before starting the cluster. See https://docs.ray.io/en/master/cluster/usage-stats.html for more details.
Local node IP: 127.0.0.1
Traceback (most recent call last):
File "/Users/ted/workspace/auto_coder/auto-coder/bin/ray", line 8, in <module>
sys.exit(main())
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/ray/scripts/scripts.py", line 2615, in main
return cli()
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/ray/autoscaler/_private/cli_logger.py", line 856, in wrapper
return f(*args, **kwargs)
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/ray/scripts/scripts.py", line 794, in start
node = ray._private.node.Node(
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/ray/_private/node.py", line 333, in __init__
self.start_head_processes()
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/ray/_private/node.py", line 1355, in start_head_processes
self._write_cluster_info_to_kv()
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/ray/_private/node.py", line 1310, in _write_cluster_info_to_kv
assert curr_val == self._session_name.encode("utf-8"), (
AssertionError: Session name session_2024-08-10_00-53-41_000587_59935 does not match persisted value b'session_2024-08-04_00-12-45_057942_30735'. Perhaps there was an error connecting to Redis.
解决:ray stop 并重新deploy模型
ray stop
rm -rf /tmp/ray/session_*
ray start --head
easy-byzerllm deploy deepseek-chat --token $MODEL_DEEPSEEK_TOKEN --alias deepseek_chat
byzerllm deploy --pretrained_model_type saas/qianwen \
--cpus_per_worker 0.001 \
--gpus_per_worker 0 \
--num_workers 2 \
--infer_params saas.api_key=${MODEL_QIANWEN_TOKEN} saas.model=text-embedding-v2 \
--model qianwen_emb
- auto-coder --file actions/000_example.yml 报utf-8错误
- 关联github issue: github.com/allwefantas…
2024-08-10 01:03:02,571 INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
Traceback (most recent call last):
File "/Users/ted/workspace/auto_coder/auto-coder/bin/auto-coder", line 8, in <module>
sys.exit(main())
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/autocoder/auto_coder.py", line 678, in main
dispacher.dispach()
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/autocoder/dispacher/__init__.py", line 27, in dispach
if action.run():
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/autocoder/dispacher/actions/action.py", line 218, in run
pp.run(packages=args.py_packages.split(",") if args.py_packages else [])
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/autocoder/pyproject/__init__.py", line 344, in run
for code in self.get_source_codes():
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/autocoder/pyproject/__init__.py", line 268, in get_source_codes
source_code = self.convert_to_source_code(file_path)
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/autocoder/pyproject/__init__.py", line 191, in convert_to_source_code
source_code = self.read_file_content(file_path)
File "/Users/ted/workspace/auto_coder/auto-coder/lib/python3.10/site-packages/autocoder/pyproject/__init__.py", line 187, in read_file_content
return file.read()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 64: invalid start byte
解决:
在__init__.py", line 187 那里加了一行print(file_path)
然后重新执行auto-coder --file actions/000_example.yml
找到报错信息上面最后一行file_path, 用vs_code将这个文件转为utf-8编码,然后还原__init__.py
电脑重启后的一些命令
- 系统重启后,ray也需要重启
ray stop
rm -rf /tmp/ray/session_*
ray start --head
easy-byzerllm deploy deepseek-chat --token $MODEL_DEEPSEEK_TOKEN --alias deepseek_chat
byzerllm deploy --pretrained_model_type saas/qianwen \
--cpus_per_worker 0.001 \
--gpus_per_worker 0 \
--num_workers 2 \
--infer_params saas.api_key=${MODEL_QIANWEN_TOKEN} saas.model=text-embedding-v2 \
--model qianwen_emb
curl https://api.deepseek.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MODEL_DEEPSEEK_TOKEN" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"stream": false
}'