Commit Graph

254 Commits

Author SHA1 Message Date
a441866f2f Configure database logging to file 2024-09-30 16:10:51 +00:00
ce7b07ad95 tui: rename 2024-09-30 04:32:47 +00:00
2fed682969 tui: Chat view footer rewrite
Rewrote footer handling to better handle truncation, and use
`ActiveModel` to return the (stylized) active model
2024-09-26 18:32:33 +00:00
69cdc0a5aa tui: Add setting view with support for changing the current model 2024-09-26 18:32:22 +00:00
3ec2675632 tui: Error handling tweak
Moved errors to bottom of screen, fix infinite loop by typing errors
properly
2024-09-23 04:43:26 +00:00
172bfc57e1 Allow specifying --agent none to mean no agent 2024-09-23 03:04:43 +00:00
a46d211e10 Improve TUI system prompt handling
+ allow setting a default agent
2024-09-23 03:00:03 +00:00
676aa7b004 Refactor TUI rendering handling and general cleanup
Improves render handling by moving the responsibility of laying out the
whole UI from each view and into the main `tui` model. Our `ViewModel`
interface has now diverged from bubbletea's `Model` and introduces
individual `Header`, `Content`, and `Footer` methods for rendering those
UI elements.

Also moved away from using value receivers on our Update and View
functions (as is common across Bubbletea) to pointer receivers, which
cleaned up some of the weirder aspects of the code (e.g. before we
essentially had no choice but to do our rendering in `Update` in order
to calculate and update the final height of the main content's
`viewport`).
2024-09-23 02:49:08 +00:00
b7c89a4dd1 Update TODO.md 2024-09-21 20:13:47 +00:00
b8e3172ce0 Start new conversations from TUI 2024-09-21 02:47:03 +00:00
a1fdf3f7cd Deprecation fix 2024-09-21 02:46:51 +00:00
a488ec4fd8 Fixed message loading
Root messages weren't being loaded since the refactor, and there was
dead code
2024-09-21 02:32:54 +00:00
463ca9ef40 TUI view management and input handling cleanup 2024-09-16 16:18:18 +00:00
24b5cdbbf6 More monior TUI refactor/cleanup
`tui/tui.go` is no longer responsible for passing window resize updates
to all views, instead we request a new window size message to be sent at
the same time we enter the view, allowing the view to catch and handle
it.

Add `Initialized` to `tui/shared/View` model, now we only call
`Init` on a view before entering it for the first time, rather than
calling `Init` on all views when the application starts.

Renames file, small cleanups
2024-09-16 14:04:08 +00:00
7c0bfefc65 Update deps 2024-09-16 03:49:04 +00:00
443c8096d3 TUI refactor
- Clean up, improved startup logic, initial conversation load
- Moved converation/message business logic (mostly) into `model/tui`
2024-09-16 00:48:45 +00:00
1570988b98 Fix LatestConversationMessages preload
Load the conversation's selected root as well
2024-09-16 00:37:42 +00:00
434fc4672b Allow custom headers on OpenAI providers (to be added to more later) 2024-08-12 17:14:53 +00:00
fe838f400f Minor adjustment to seleted message style 2024-07-10 01:21:06 +00:00
e59ce973b6 Add conversation deletion to conversations view 2024-07-08 06:40:52 +00:00
4ef841e945 Add modify_file tool
Removed file_insert_lines, file_replace_lines
2024-07-01 08:09:04 +00:00
c68084f8a5 Update TODO 2024-06-24 17:45:18 +00:00
8ca044b6af Update README.md 2024-06-23 21:42:23 +00:00
6f5cf68208 Update TODO.md 2024-06-23 21:42:23 +00:00
914d9ac0c1 Renamed RequestParameters.ToolBag to Toolbox 2024-06-23 19:10:03 +00:00
8ddac2f820 Introduce "agents"
An agent is currently a name given to a system prompt and a set of
tools which the agent has access to.

This resolves the previous issue of the set of configured tools being
available in *all* contexts, which wasn't always desired. Tools are now
only available when an agent is explicitly requested using the
`-a/--agent` flag.

Agents are expected to be expanded on: the concept of task-specilized
agents (e.g. coding), the ability to define a set of files an agent
should always have access to for RAG purposes, etc.

Other changes:

- Removes the "tools" top-level config structure (though this is expected
to come back along with the abillity to define custom tools).

- Renamed `pkg/agent` to `pkg/agents`
2024-06-23 19:05:30 +00:00
cea5118cac Only include user and assistant messages when generating titles
(again)
2024-06-23 18:55:04 +00:00
a43a91c6ff Update system prompt handling (again)
Add `api.ApplySystemPrompt`, renamed `GetSystemPrompt` to
`DefaultSystemPrompt`.
2024-06-23 18:36:51 +00:00
ba7018af11 Update config handling
- Stop using pointers where unnecessary
- Removed default system prompt
- Set indent level to 2 when writing config
- Update ordering of config struct, which affects marshalling
- Make provider `name` optional, defaulting to the provider's `kind`
2024-06-23 16:28:21 +00:00
f89cc7b410 Add validation to command line flags + update system prompt handling
Renamed `applyPromptFlags` to `applyGenerationFlags` and added
`validateGenerationFlags`
2024-06-23 06:08:15 +00:00
677cfcfebf Slight cleanup to openai
Remove /v1 from base url, removed some slight repetition
2024-06-23 04:17:53 +00:00
11402c5534 Update to yaml.v3
Bonus: better rendering of tool results in the chat
2024-06-23 04:04:01 +00:00
a1fc8a637b Include types in provider files, splitting wasn't ergonomic 2024-06-23 01:48:31 +00:00
94d84ba7d7 Support Anthropic's native tool calling API 2024-06-23 01:47:31 +00:00
c50b6b154d Add TODO.md 2024-06-21 12:56:11 -06:00
31df055430 Always show tool calls, toggle whether results are hidden 2024-06-21 06:05:00 +00:00
c30e652103 Cleaned up assistant cursor handling 2024-06-21 05:52:59 +00:00
3fde58b77d Package restructure and API changes, several fixes
- More emphasis on `api` package. It now holds database model structs
  from `lmcli/models` (which is now gone) as well as the tool spec,
  call, and result types. `tools.Tool` is now `api.ToolSpec`.
  `api.ChatCompletionClient` was renamed to
  `api.ChatCompletionProvider`.

- Change ChatCompletion interface and implementations to no longer do
  automatic tool call recursion - they simply return a ToolCall message
  which the caller can decide what to do with (e.g. prompt for user
  confirmation before executing)

- `api.ChatCompletionProvider` functions have had their ReplyCallback
  parameter removed, as now they only return a single reply.

- Added a top-level `agent` package, moved the current built-in tools
  implementations under `agent/toolbox`. `tools.ExecuteToolCalls` is now
  `agent.ExecuteToolCalls`.

- Fixed request context handling in openai, google, ollama (use
  `NewRequestWithContext`), cleaned up request cancellation in TUI

- Fix tool call tui persistence bug (we were skipping message with empty
  content)

- Now handle tool calling from TUI layer

TODO:
- Prompt users before executing tool calls
- Automatically send tool results to the model (or make this toggleable)
2024-06-21 05:24:02 +00:00
85a2abbbf3 Use @ as the separator between model and provider
Also put the provider after the model (e.g. `gpt-4o@openai`,
`openai/gpt-4o@openrouter`. The aim here was to reduce clashing and
confusion with existing model naming conventions.
2024-06-20 23:37:11 +00:00
dfe43179c0 Include token count in api.Chunk
And calculate the tokens/chunk for gemini responses, fixing the tok/s
meter for gemini models.

Further, only consider the first candidate of streamed gemini responses.
2024-06-09 20:49:18 +00:00
42c3297e54 Make Conversation a pointer refernece on Message
Instead of a value, which lead some odd handling of conversation
references.

Also fixed some formatting and removed an unnecessary (and probably
broken) setting of ConversationID in a call to
`cmdutil.HandleConversationReply`
2024-06-09 18:51:44 +00:00
a22119f738 Better handling of newly saved conversations
When a new conversation is created in the chat view's
`persistConversation`, we now set `rootMessages` appropriately.
2024-06-09 18:51:44 +00:00
a2c860252f Refactor pkg/lmcli/provider
Moved `ChangeCompletionInterface` to `pkg/api`, moved individual
providers to `pkg/api/provider`
2024-06-09 18:31:43 +00:00
d2d946b776 Wrap chunk content in a Chunk type
Preparing to include additional information with each chunk (e.g. token
count)
2024-06-09 18:31:43 +00:00
c963747066 Store fixes
We were taking double pointers (`**T`) in some areas, and in
we were not setting foreign references correctly in `StartConversation`
and `Reply`.
2024-06-09 18:31:40 +00:00
e334d9fc4f Remove forgotten printf 2024-06-09 16:19:22 +00:00
c1ead83939 Rename shared.State to shared.Shared 2024-06-09 16:19:19 +00:00
c9e92e186e Chat view cleanup
Replace `waitingForReply` and the `status` string with the `state`
variable.
2024-06-09 16:19:17 +00:00
45df957a06 Fixes to message/conversation handling in tui chat view
This set of changes fixes root/child message cycling and ensures all
database operations happen within a `tea.Cmd`
2024-06-08 21:28:29 +00:00
136c463924 Split chat view into files 2024-06-02 22:40:46 +00:00