Giter Club home page Giter Club logo

ai-cli's People

Contributors

coolelectronics avatar gingernaut avatar yufeikang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ai-cli's Issues

json.decoder.JSONDecodeError: Expecting value: line 2 column 14 (char 15)

Traceback (most recent call last):
File "/home/focus/.local/bin/ai", line 5, in
from ai_cli.cli import cli
File "/home/focus/.local/lib/python3.11/site-packages/ai_cli/cli.py", line 10, in
from ai_cli.bot import Bot, get_bot
File "/home/focus/.local/lib/python3.11/site-packages/ai_cli/bot/init.py", line 12, in
from ai_cli.setting import Setting
File "/home/focus/.local/lib/python3.11/site-packages/ai_cli/setting.py", line 108, in
setting = read_setting()
^^^^^^^^^^^^^^
File "/home/focus/.local/lib/python3.11/site-packages/ai_cli/setting.py", line 97, in read_setting
return Setting.from_dict(json.load(f))
^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/init.py", line 293, in load
return loads(fp.read(),
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 14 (char 15)

Rich库无法输入多行聊天

如题。我看了rich库的实现,ask似乎没有输入多行的选项,导致没法复制多行到聊天窗口里。

Error when execute ai commands

Traceback (most recent call last):
File "/Users/tai/Library/Python/3.9/bin/ai", line 5, in
from ai_cli.cli import cli
File "/Users/tai/Library/Python/3.9/lib/python/site-packages/ai_cli/cli.py", line 10, in
from ai_cli.bot import Bot, get_bot
File "/Users/tai/Library/Python/3.9/lib/python/site-packages/ai_cli/bot/init.py", line 12, in
from EdgeGPT import Chatbot, ConversationStyle
File "/Users/tai/Library/Python/3.9/lib/python/site-packages/EdgeGPT.py", line 953, in
class Query:
File "/Users/tai/Library/Python/3.9/lib/python/site-packages/EdgeGPT.py", line 962, in Query
Cookie.import_data()
File "/Users/tai/Library/Python/3.9/lib/python/site-packages/EdgeGPT.py", line 934, in import_data
cls.current_filepath = cls.files()[cls.current_file_index]
IndexError: list index out of range

Hi, I encouter this error when running ai setting -e or other ai-commands. Hope you could help

Thanks
Tai

OPENAI_API_BASE and OPENAI_API_KEY have no effect

I've set OPENAI_API_BASE and OPENAI_API_KEY as environment variable. The ai ask command shows "asking" forever while giving "--endpoint" and "--api-key" works.

After investigation I notice that a settings.json will be generated under ~/.config/ai_cli with default "api_key" and "endpoint" set. The issue may be caused by current configuration workflow and precedence. Manually changing the settings.json file also works.

Nothing ever works

testing env

  • ubuntu 20.04
  • python 3.8

Nothing works when trying to use options.

$ ai -b BardBot
usage: ai [-h] [--api-key [API_KEY]] [--no-stream] [--raw] [--model [MODEL]] [--log-level [{DEBUG,INFO,WARNING,ERROR,CRITICAL}]]
          [--bot [{GPTBot,BingBot,BardBot}]] [--debug] [--multi-line] [--endpoint [ENDPOINT]] [--proxy [PROXY]]
          {ask,chat,translate,setting,review,commit} ...

chatGPT cli.

positional arguments:
  {ask,chat,translate,setting,review,commit}
                        command to run
    ask                 ask a question
    chat                chat with the assistant
    translate           translate a text
    setting             view/edit the setting, the setting will be saved in ~/.ai_cli.json
    review              let the assistant review your code
    commit              let the assistant help you write a commit message

optional arguments:
  -h, --help            show this help message and exit
  --api-key [API_KEY]   the API key to use, defaults to OPENAI_API_KEY env var, or asks you to enter it
  --no-stream, -ns      non stream the response, default is to live stream the response
  --raw, --no-markdown  default the content will be rendered as markdown, this will disable that
  --model [MODEL], -m [MODEL]
                        the model to use
  --log-level [{DEBUG,INFO,WARNING,ERROR,CRITICAL}], -l [{DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                        the log level to use, defaults to INFO
  --bot [{GPTBot,BingBot,BardBot}], -b [{GPTBot,BingBot,BardBot}]
                        the bot to use, defaults to GPTBot
  --debug, -d           enable debug mode, this will print the request and response to the console
  --multi-line, -ml     enable multi line mode, this will enable multi line input, when enabled, you can end the input with Ctrl+D
  --endpoint [ENDPOINT], -e [ENDPOINT]
                        the endpoint to use, default is https://api.openai.com/v1. You can use this to resolve the issue of the api
                        endpoint is blocked in your country. OPENAI_API_BASE env var will also work.
  --proxy [PROXY], -p [PROXY]
                        the proxy to use, if env var HTTP_PROXY/HTTPS+PROXY/SOCKS_PROXY/ALL_PROXY is set, this will default to that. When
                        use socks proxy. you need install pysocks first. pip install pysocks

EdgeGPT should be updated

Original package is not working anymore.
But EdgeGPT-fork is ok (tested with edge-gpt.exe)

Though, even after upgrading I experience an error:

Asking...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\AI\ai-cli\venv\Scripts\ai.exe\__main__.py", line 7, in <module>
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 494, in cli
    main()
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 486, in main
    CMD[command]()
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 375, in ask_cmd
    ask(args.question, stream=stream)
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 292, in ask
    response = _ask(question, stream=stream)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 283, in _ask
    bot: Bot = get_bot(setting=setting, bot_type=bot_type)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\bot\__init__.py", line 168, in get_bot
    bot = BingBot(setting)
          ^^^^^^^^^^^^^^^^
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\bot\bing.py", line 49, in __init__
    self.bot = Chatbot(cookies=bing_cookies)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\ai-cli\venv\Lib\site-packages\EdgeGPT\EdgeGPT.py", line 27, in __init__
    self.chat_hub: ChatHub = ChatHub(
                             ^^^^^^^^
  File "D:\AI\ai-cli\venv\Lib\site-packages\EdgeGPT\chathub.py", line 49, in __init__
    self.sec_access_token = conversation.struct["secAccessToken"] or None
                            ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'secAccessToken'

Not compatible with recent openai package

Traceback (most recent call last):
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\bot\__init__.py", line 148, in _ask
    response = openai.ChatCompletion.create(model=self.model, messages=messages, stream=stream)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\ai-cli\venv\Lib\site-packages\openai\lib\_old_api.py", line 39, in __call__
    raise APIRemovedInV1(symbol=self._symbol)
openai.lib._old_api.APIRemovedInV1:

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\AI\ai-cli\venv\Scripts\ai.exe\__main__.py", line 7, in <module>
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 494, in cli
    main()
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 486, in main
    CMD[command]()
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 375, in ask_cmd
    ask(args.question, stream=stream)
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\cli.py", line 293, in ask
    for content in response:
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\bot\__init__.py", line 111, in <genexpr>
    return (self.history.add_answer(question_id, a) for a in self._ask(question, stream=stream))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\AI\ai-cli\venv\Lib\site-packages\ai_cli\bot\__init__.py", line 155, in _ask
    except openai.error.RateLimitError:
           ^^^^^^^^^^^^
AttributeError: module 'openai' has no attribute 'error'

疑问 violation 邮件

一直收到openai 的邮件说:After a thorough investigation, we have determined that you or a member of your organization are using the OpenAI API in ways that violate our policies.

但却还能继续chat…

add summarise command

could you please add summarise command, which can put long grapth to short sentences.

如何使用http/socks代理的情况下使用这个脚本?谢谢

虽然已经设置了终端中的环境变量(oh-my-zsh,proxy工具),但是并不有效。

Assistant:
Asking...WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f17728a3b80>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /v1/chat/completions
Asking...WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f17728a3d60>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /v1/chat/completions

ValueError: Unknown level: '<ai_cli.setting.SettingField object at 0x7f329f91d4f0>'

Traceback (most recent call last):
File "/home/focus/.local/bin/ai", line 5, in
from ai_cli.cli import cli
File "/home/focus/.local/lib/python3.9/site-packages/ai_cli/cli.py", line 214, in
init_logging(setting.log_level.get_value() if not args.debug else "DEBUG")
File "/home/focus/.local/lib/python3.9/site-packages/ai_cli/init.py", line 20, in init_logging
logging.getLogger("ai_cli").setLevel(level=log_level)
File "/usr/local/python3/lib/python3.9/logging/init.py", line 1409, in setLevel
self.level = _checkLevel(level)
File "/usr/local/python3/lib/python3.9/logging/init.py", line 194, in _checkLevel
raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: '<ai_cli.setting.SettingField object at 0x7f329f91d4f0>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.