Giter VIP home page Giter VIP logo

ai-cli-lib's People

Contributors

dspinellis avatar gitmsr avatar kapolos avatar karatse avatar koppor 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  avatar  avatar  avatar

ai-cli-lib's Issues

Better error message

I try to follow README.md and have following config file

[general]
ai=openai
[openai]
key=sk-N6H...
model=gpt-4

The error message is

/home/koppor/.aicliconfig(2): Initialization file error.

It could be more verbose

Error: "all messages must have non-empty content except for the optional final assistant message"

Running bash under MacOS and using Anthropic I get the error

"all messages must have non-empty content except for the optional final assistant message"

after the first use of ctrl-X A.

It could be a usage error by me...

Here is a log file:

{
  "model": "claude-3-sonnet-20240229",
  "max_tokens": 256,
  "system": "You are an assistant who provides executable commands for the bash command-line interface. You only provide the requested command on a single line, without any explanations, hints or other adornments. Stop providing output after the providing the requested command. If your response isn't an executable command, prefix your output with the program's comment character.",
  "messages": [
    {"role": "user", "content": "List files in current directory"},
    {"role": "assistant", "content": "ls"},
    {"role": "user", "content": "How many JavaScript files in the current directory contain the word bar?"},
    {"role": "assistant", "content": "grep -lw bar *.js | wc -l"},
    {"role": "user", "content": "xyzzy"},
    {"role": "assistant", "content": "# Sorry I can't help."},
    {"role": "user", "content": "Before my final prompt to which I expect a reply, I am also supplying you as context with one or more previously issued commands, to which you simply reply OK"},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": "exit"},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": "hello"},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": "exit"},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": "list all files"}
  ]
}
{"id":"msg_0145uVDCZc1xf4HyvQyvvE2S","type":"message","role":"assistant","content":[{"type":"text","text":"ls"}],"model":"claude-3-sonnet-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":202,"output_tokens":4}}{
  "model": "claude-3-sonnet-20240229",
  "max_tokens": 256,
  "system": "You are an assistant who provides executable commands for the bash command-line interface. You only provide the requested command on a single line, without any explanations, hints or other adornments. Stop providing output after the providing the requested command. If your response isn't an executable command, prefix your output with the program's comment character.",
  "messages": [
    {"role": "user", "content": "List files in current directory"},
    {"role": "assistant", "content": "ls"},
    {"role": "user", "content": "How many JavaScript files in the current directory contain the word bar?"},
    {"role": "assistant", "content": "grep -lw bar *.js | wc -l"},
    {"role": "user", "content": "xyzzy"},
    {"role": "assistant", "content": "# Sorry I can't help."},
    {"role": "user", "content": "Before my final prompt to which I expect a reply, I am also supplying you as context with one or more previously issued commands, to which you simply reply OK"},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": "exit"},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": ""},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": "ls"},
    {"role": "assistant", "content": "OK"},
    {"role": "user", "content": "list all files including subdirectories"}
  ]
}
{"type":"error","error":{"type":"invalid_request_error","message":"messages: all messages must have non-empty content except for the optional final assistant message"}}

some indicator that ai-cli-lib is enabled and/or running

Have some way to know if ai-cli-lib has been loaded. It could be a simple message to stdout, or a different promt.

Similarly, is it possible to have a way to know if the current prompt has been submitted and it is waiting for a response.

Leaking secrets

The context option seems to grab N-history lines and send them to the AI. This is potentially a security concern and might be good to document it in the readme. For example, in Postgresql a user might change the password of an account using ALTER user X With password. There might be similar concerns in other programs.

prompt for different tools

The [prompt] section in the configuration is used for all tools.

Permit a different prompt for different tools. I think the most flexible way is to have an environment variable that can be set before running the program. This way the prompt can be configured per run for the same tool. For example, for SQLite, the prompt can be set for different databases. By default, the configuration file prompt would be used.

License files should be placed in top-level directory

Commit 5babeb8 reorganized the directory structure. However, the license files were accidentally moved to the src/ directory instead of appearing in the top-level directory. The intention is to have them in the top-level directory to properly display the project's licensing terms.

History and context

Every query to the AI uses context number of entries from the history.

However, the history also records the prompt before it is translated.

I think I like having the prompt in the history. But the prompt should not be submitted as part of the context. For example, this is my current history

 create table students(sid int, grade int);
 SELECT sid, MAX(grade) FROM students GROUP BY sid HAVING grade = (SELECT MAX(grade) FROM students);
 how to create table students(sid, sname) with primary key sid
 CREATE TABLE students (sid INTEGER PRIMARY KEY, sname TEXT);

So if the context is 2, then the last two lines will be context. Instead, the SELECT and last CREATE should be sent.
Perhaps one way is to mark prompts as history. One way would be to add, in the tool section, the comment for the tool (in the case of sqlite, it would be --, then write to the history this:

 create table students(sid int, grade int);
 SELECT sid, MAX(grade) FROM students GROUP BY sid HAVING grade = (SELECT MAX(grade) FROM students);
 --how to create table students(sid, sname) with primary key sid
 CREATE TABLE students (sid INTEGER PRIMARY KEY, sname TEXT);

and when scanning the history, skip lines that start with the comment.

Another solution is simply not add the prompt to the history.

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.