diff --git a/cmd/wsh/cmd/wshcmd-ai.go b/cmd/wsh/cmd/wshcmd-ai.go index 4c59cb9aaf..85d6eb436b 100644 --- a/cmd/wsh/cmd/wshcmd-ai.go +++ b/cmd/wsh/cmd/wshcmd-ai.go @@ -26,9 +26,11 @@ var aiCmd = &cobra.Command{ } var aiFileFlags []string +var aiNewBlockFlag bool func init() { rootCmd.AddCommand(aiCmd) + aiCmd.Flags().BoolVarP(&aiNewBlockFlag, "new", "n", false, "create a new AI block") aiCmd.Flags().StringArrayVarP(&aiFileFlags, "file", "f", nil, "attach file content (use '-' for stdin)") } @@ -69,9 +71,12 @@ func aiRun(cmd *cobra.Command, args []string) { if isDefaultBlock { blockArg = "view@waveai" } - - fullORef, err := resolveSimpleId(blockArg) - if err != nil && isDefaultBlock { + var fullORef *waveobj.ORef + var err error + if !aiNewBlockFlag { + fullORef, err = resolveSimpleId(blockArg) + } + if (err != nil && isDefaultBlock) || aiNewBlockFlag { // Create new AI block if default block doesn't exist data := &wshrpc.CommandCreateBlockData{ BlockDef: &waveobj.BlockDef{ diff --git a/docs/docs/config.mdx b/docs/docs/config.mdx index 89870f6578..8b79c02f97 100644 --- a/docs/docs/config.mdx +++ b/docs/docs/config.mdx @@ -28,7 +28,7 @@ wsh editconfig | ai:preset | string | the default AI preset to use | | ai:baseurl | string | Set the AI Base Url (must be OpenAI compatible) | | ai:apitoken | string | your AI api token | -| ai:apitype | string | defaults to "open_ai", but can also set to "azure" for special Azure AI handling | +| ai:apitype | string | defaults to "open_ai", but can also set to "azure" (forspecial Azure AI handling) or "anthropic" | | ai:name | string | string to display in the Wave AI block header | | ai:model | string | model name to pass to API | | ai:apiversion | string | for Azure AI only (when apitype is "azure", this will default to "2023-05-15") | diff --git a/docs/docs/customization.mdx b/docs/docs/customization.mdx index 8c186dd0bc..7ea22d1cf2 100644 --- a/docs/docs/customization.mdx +++ b/docs/docs/customization.mdx @@ -64,3 +64,7 @@ Using widgets.json, you'll be able to remove any default widgets and add widgets You can also suppress the help widgets in the bottom right by setting the config key `widget:showhelp` to `false`.
+ +## Presets + +For more advanced customization, to set up multiple AI models, and your own tab backgrounds, check out our [Presets Documentation](./presets). diff --git a/docs/docs/faq.mdx b/docs/docs/faq.mdx index c77851edf4..1c95d55356 100644 --- a/docs/docs/faq.mdx +++ b/docs/docs/faq.mdx @@ -28,6 +28,7 @@ Here are the ollma open AI compatibility docs: https://github.com/ollama/ollama/ ```json { + "ai:*": true, "ai:baseurl": "http://localhost:11434/v1", "ai:name": "llama3.2", "ai:model": "llama3.2", @@ -35,7 +36,11 @@ Here are the ollma open AI compatibility docs: https://github.com/ollama/ollama/ } ``` -### How can I connect to Azure AI +Note: we set the `ai:*` key to true to clear all the existing "ai" keys so this config is a clean slate. + +To switch between multiple models, consider [adding AI Presets](./presets) instead. + +### How can I connect to Azure AI? Open your [config file](./config) in Wave using `wsh editconfig` (the config file is normally located at `~/.config/waveterm/settings.json`). @@ -44,6 +49,25 @@ You'll need to set your `ai:baseurl` to your Azure AI Base URL (do not include q You'll also need to set `ai:apitype` to `azure`. You can then set the `ai:model`, and `ai:apitoken` appropriately for your setup. +### How can I connect to Claude? + +Open your [config file](./config) in Wave using `wsh editconfig`. + +Set these keys: + +```json +{ + "ai:*": true, + "ai:apitype": "anthropic", + "ai:model": "claude-3-5-sonnet-latest", + "ai:apitoken": "" +} +``` + +Note: we set the `ai:*` key to true to clear all the existing "ai" keys so this config is a clean slate. + +To switch between models, consider [adding AI Presets](./presets) instead. + ### How can I see the block numbers? The block numbers will appear when you hold down Ctrl-Shift (and disappear once you release the key combo). diff --git a/docs/docs/presets.mdx b/docs/docs/presets.mdx index 0435c16520..92606d1817 100644 --- a/docs/docs/presets.mdx +++ b/docs/docs/presets.mdx @@ -8,6 +8,16 @@ Presets can be used to apply multiple setting overrides at once to either a tab You can set presets either by placing them in `~/.config/waveterm/presets.json` or by placing them in a JSON file in the `~/.config/waveterm/presets/` directory. All presets will be aggregated regardless of which file they're placed in so you can use the `presets` directory to organize them as you see fit. +:::info + +You can open up the main presets config file in Wave by running: + +``` +wsh editconfig presets.json +``` + +::: + ### File format Presets follow the following format: @@ -76,18 +86,18 @@ The following configuration keys are available for use in presets: #### AI configurations -| Key Name | Type | Function | -| ------------- | ------ | -------------------------------------------------------------------------------- | -| ai:preset | string | the default AI preset to use | -| ai:baseurl | string | Set the AI Base Url (must be OpenAI compatible) | -| ai:apitoken | string | your AI api token | -| ai:apitype | string | defaults to "open_ai", but can also set to "azure" for special Azure AI handling | -| ai:name | string | string to display in the Wave AI block header | -| ai:model | string | model name to pass to API | -| ai:apiversion | string | for Azure AI only (when apitype is "azure", this will default to "2023-05-15") | -| ai:orgid | string | | -| ai:maxtokens | int | max tokens to pass to API | -| ai:timeoutms | int | timeout (in milliseconds) for AI calls | +| Key Name | Type | Function | +| ------------- | ------ | -------------------------------------------------------------------------------------------------- | +| ai:preset | string | the default AI preset to use | +| ai:baseurl | string | Set the AI Base Url (must be OpenAI compatible) | +| ai:apitoken | string | your AI api token | +| ai:apitype | string | defaults to "open_ai", but can also set to "azure" (for special Azure AI handling), or "anthropic" | +| ai:name | string | string to display in the Wave AI block header | +| ai:model | string | model name to pass to API | +| ai:apiversion | string | for Azure AI only (when apitype is "azure", this will default to "2023-05-15") | +| ai:orgid | string | | +| ai:maxtokens | int | max tokens to pass to API | +| ai:timeoutms | int | timeout (in milliseconds) for AI calls | #### Background configurations diff --git a/docs/docs/releasenotes.mdx b/docs/docs/releasenotes.mdx index 6c1c3e9df7..fceabb513d 100644 --- a/docs/docs/releasenotes.mdx +++ b/docs/docs/releasenotes.mdx @@ -6,6 +6,20 @@ sidebar_position: 200 # Release Notes +### v0.9.2 — Nov 11, 2024 + +New minor release with bug fixes and new features! Fixed the bug around making Wave fullscreen (also affecting certain window managers like Hyprland). We've also put a lot of work into the doc site (https://docs.waveterm.dev), including documenting how [Widgets](./widgets) and [Presets](./presets) work! + +- Updated documentation +- Wave AI now supports the Anthropic API! Checkout the [FAQ](./faq) for how to use the Claude models with Wave AI. +- Removed defaultwidgets.json and unified it to widgets.json. Makes it more straightforward to override the default widgets. +- New resolvers for `-b` param in `wsh`. "tab:N" for accessing the nth tab, "[view]" and "[view]:N" for accessing blocks of a particlar view. +- New `wsh ai` command to send AI chats (and files) directly to a new or existing AI block +- wsh setmeta/getmeta improvements. Allow setmeta to take a json file (and also read from stdin), also better output formats for getmeta (compatible with setmeta). +- [bugfix] Set max completion tokens in the OpenAI API so we can now work with o1 models (also fallback to non-streaming mode) +- [bugfix] Fixed content resizing when entering "full screen" mode. This bug also affected certain window managers (like Hyperland) +- Lots of other small bug fixes, docs updates, and dependency bumps + ### v0.9.1 — Nov 1, 2024 Minor bug fix release to follow-up on the v0.9.0 build. Lots of issues fixed (especially for Windows). diff --git a/docs/docs/wsh.mdx b/docs/docs/wsh.mdx index 0bf6afc646..8f194d6e85 100644 --- a/docs/docs/wsh.mdx +++ b/docs/docs/wsh.mdx @@ -106,6 +106,26 @@ wsh getmeta -b [other-tab-id] "bg:*" --clear-prefix | wsh setmeta -b tab --json --- +## ai + +Send messages to new or existing AI blocks directly from the CLI. `-f` passes a file. note that there is a maximum size of 10k for messages and files, so use a tail/grep to cut down file sizes before passing. The `-f` option works great for small files though like shell scripts or `.zshrc` etc. + +By default the messages get sent to the first AI block (by blocknum). If no AI block exists, then a new one will be created. Use `-n` to force creation of a new AI block. Use `-b` to target a specific AI block. + +``` +wsh ai "how do i write an ls command that sorts files in reverse size order" +wsh ai -f <(tail -n 20 "my.log") -- "any idea what these error messages mean" +wsh ai -f README.md "help me update this readme file" + +# creates a new AI block +wsh ai -n "tell me a story" + +# targets block number 5 +wsh ai -b 5 "tell me more" +``` + +--- + ## editconfig You can easily open up any of Wave's config files using this command.