LaoshuBaby / liulianmao

A LLM client for use from the command line or IDE. 一个在命令行或者IDE中使用的大语言模型客户端
https://pypi.org/project/liulianmao/
MIT License
15 stars 3 forks source link

Can't work if not running in root folder #9

Open LaoshuBaby opened 4 months ago

LaoshuBaby commented 4 months ago

在 @Ovler-Young 的 https://github.com/LaoshuBaby/liulianmao/commit/f9b89c9aa93bee1a85dacb2bb3732c9ecc85627d 之后

PS C:\Git\LaoshuBaby\liulianmao\src\liulianmao> py __main__.py -s zhipu -fa
Traceback (most recent call last):
  File "C:\Git\LaoshuBaby\liulianmao\src\liulianmao\__main__.py", line 7, in <module>
    LIULIANMAO_VERSION = toml.load("pyproject.toml")["tool"]["poetry"]["version"]
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Environment\Python\Python311\Lib\site-packages\toml\decoder.py", line 133, in load
    with io.open(_getpath(f), encoding='utf-8') as ffile:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'pyproject.toml'

而切换到 / 目录下

PS C:\Git\LaoshuBaby\liulianmao> py src/liulianmao/__main__.py -s zhipu -fa 
2024-06-28 19:59:12.207 | SUCCESS  | hellologger:get_logger:150 - 
==============================
[Hellologger 0.2.2.post1] logger enabled

这里我能想到的方法就是通过 __file__ 构造绝对路径然后一层一层定位到上面的 pyproject.toml

(此外这样还有一个问题,如果打包的话,pyproject.toml 应该是打包不进 site-packages 的)

我暂时把它cherry pick到 review_suggestion 分支了,因为 @boholder 老师之前也提到了这个问题 https://github.com/LaoshuBaby/liulianmao/blob/5e98a1ce7a8565753f8afe493547f0a91b64672e/pyproject.toml#L3-L7 所以作为苟管理,我建议还是慢慢修(然后main分支上我先退掉了不然run都run不起来了)

Ovler-Young commented 4 months ago

这个就是print版本号 那么revert f9b89c9aa93bee1a85dacb2bb3732c9ecc85627d 中的删除 src/liulianmao/const.py 部分,然后把下一commit中的 from const import LIULIANMAO_VERSION 这行revert回来就行。