Commit Graph

18 Commits

Author SHA1 Message Date
Paul Harrison 0698919cb6 Incorporate custom bots into chat CLI
This commit will add the ability to create custom bots in the form of
automatically prepending additional bot-specific context to your chat
session. A new `chat` CLI argument will be added allowing users to
provide the name of an existing bot. For example:

```
llm chat -b "My Bot"
```

An additional `bot` CLI is added for creating and removing bots.

Closes #13
2024-06-27 17:07:28 +01:00
Paul Harrison 76bee1aed9 Update default history directory 2024-02-23 11:25:27 +00:00
Paul Harrison ff836e617c Get default chat paramters from settings file
In the current CLI implementation, default values for the model,
temperature, and history directory were provided as defaults to the
`typer` CLI interface. This bypassed the ability to set values via
environment variables and relied on `typer` rather than `pydantic` to
validate the history directory. This prevented the directory's creation
when it doesn't exist.

This commit sets the default values in the CLI to `None` and thus relies
on the `OpenAISettings` class for default values and parameter
validation.
2024-02-23 11:15:09 +00:00
Paul Harrison b859c8bb95 Fix failing cost calculation test
When updating the model pricing in commit 50fa0cc5ae I forgot to update
the associated test. As well as fixing this test, this commit also
updates the calculation to use `math.floor` instead of `round` to round
to six decimal places. This is because the `round` function appeared to
round incorrectly. For example, when running the test, 0.0000275 was
rounded to 0.000028 instead of the expected 0.000028.
2024-02-23 11:12:53 +00:00
Paul Harrison aade152486 Add GPT-4-turbo-preview to enabled models 2024-02-17 16:13:54 +00:00
Paul Harrison 50fa0cc5ae Update GPT-3 pricing 2024-02-17 16:02:29 +00:00
Paul Harrison 2d10e3ff40 Update openai to v1.9
The update from openai 0.x to 1.x introduced many breaking changes. This
commit makes the required refactoring to address these changes.

Closes #9
2024-01-23 23:41:35 +01:00
Paul Harrison fc07f3132f Bump to v1.0 2023-09-29 14:28:19 +01:00
Paul Harrison e028c84938 Set default history directory to ~/.llm_chat 2023-09-27 15:33:22 +01:00
Paul Harrison 68fc11c450 Name conversation
Closes #4
2023-09-14 18:02:45 +01:00
Paul Harrison f5c7c40cc8 Load previous conversation
This commit adds the additional CLI command `load`, which accepts the
path to a previously saved conversation from which to load previous
messages. The previous cost and token counts are not loaded as theses
are deemed functions of the chat session rathr than the conversation
and are stored with conversation purely for future reference.
2023-09-14 08:17:08 +02:00
Paul Harrison 8c17d4165a Store conversation history on session end
At the end of each sesssion the conversation is stored to a directory
(defaulting to `.history` in the currrent working directory) as a JSON
object. Note, the session must be ended by sending the quit message (/q)
for the conversation to be saved. Ctrl+C will not work.
2023-08-24 18:22:15 +01:00
Paul Harrison 1670383fee Display running cost in USD after each response 2023-08-24 15:23:32 +01:00
Paul Harrison 2cd623e960 Optionally provide context files to chat session
This commit enables the user to provide one or more text files as
context for their chat session. These will be provided as system
messages to OpenAI's API, one message per file.
2023-08-23 09:35:33 +01:00
Paul Harrison 7cbde55aac Implement basic command line interface
Implements a basic CLI using Typer, Rich, and Prompt Toolkit. I couldn't
work out how to propoerly mock/fake the Rich console or the prompt
session from Prompt Toolkit, so I created dummy functions to work around
them and just test the basic application flow rather than user inputs
and outputs to the terminal.
2023-08-22 10:02:02 +01:00
Paul Harrison 0015ae4bff Add linting checks and code formatting
Linting checks are performed using Ruff, Mypy, and Pydocstyle. Code
formatting is performed using Black and Isort. A Makefile is also added
with linting and formatting commands for convenience.
2023-08-16 10:10:06 +01:00
Paul Harrison c9f01c7dc2 Basic interface to OpenAI's chat completion API
This commit implements a basic interface to hold a conversation with
OpenAI's GPT models via their API, using OpenAI's Python SDK. In
addition to this interface, the commit incorporates Pydantic for
managing settings via environment variables.
2023-08-14 12:49:38 +01:00
Paul Harrison dd9a8c96aa Initial commit 2023-08-13 19:53:05 +01:00