dspinellis / ai-cli-lib Goto Github PK
View Code? Open in Web Editor NEWAdd AI capabilities to any readline-enabled command-line program
License: Apache License 2.0
Add AI capabilities to any readline-enabled command-line program
License: Apache License 2.0
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
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"}}
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.
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.
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.
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.
Hello, I m new to AI... and maybe something in my setup is not correct.
When I hit ^X+a I got this
llama.cpp did not provide a suitable response.
I m on Slackware current.
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.
The script can then be simply sourced by .bashrc
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.