| commit | 72252cbcb97840d724133be67c4c69cc69ebb2d3 | [log] [tgz] |
|---|---|---|
| author | Philip Zeyliger <philip@bold.dev> | Sat May 10 17:00:08 2025 -0700 |
| committer | Philip Zeyliger <philip@bold.dev> | Sat May 10 17:00:08 2025 -0700 |
| tree | a361499dc3fa6b9af2be3e74cfd59fd8ba34690e | |
| parent | 7ce5fb76d8748ebf73c5adf9d6cd8eb67716fba8 [diff] |
llm and everything: Update ToolResult to use []Content instead of string for multimodal support This was a journey. The sketch-generated summary below is acceptable, but I want to tell you about it in my voice too. The goal was to send screenshots to Claude, so that it could... look at them. Currently the take screenshot and read screenshot tools are different, and they'll need to be renamed/prompt-engineered a bit, but that's all fine. The miserable part was that we had to change the return value of tool from string to Content[], and this crosses several layers: - llm.Tool - llm.Content - ant.Content & openai and gemini friends - AgentMessage [we left this alone] Extra fun is that Claude's API for sending images has nested Content fields, and empty string and missing needs to be distinguished for the Text field (because lots of shell commands return the empty string!). For the UI, I made us transform the results into a string, dropping images. This would have been yet more churn for not much obvious benefit. Plus, it was going to break skaband's compatibility, and ... yet more work. OpenAI and Gemini don't obviously support images in this same way, so they just don't get the tools. ~~~~~~~~~~ Sketch said: This architectural change transforms tool results from plain strings to []Content arrays, enabling multimodal interaction in the system. Key changes include: - Core structural changes: - Modified ToolResult type from string to []Content across all packages - Added MediaType field to Content struct for MIME type support - Created TextContent and ImageContent helper functions - Updated all tool.Run implementations to return []Content - Image handling: - Implemented base64 image support in Anthropic adapter - Added proper media type detection and content formatting - Created browser_read_image tool for displaying screenshots - Updated browser_screenshot to provide usable image paths - Adapter improvements: - Updated all LLM adapters (ANT, OAI, GEM) to handle content arrays - Added specialized image content handling in the Anthropic adapter - Ensured proper JSON serialization/deserialization for all content types - Improved test coverage for content arrays - UI enhancements: - Added omitempty tags to reduce JSON response size - Updated TypeScript types to handle array content - Made field naming consistent (tool_error vs is_error) - Preserved backward compatibility for existing consumers Co-Authored-By: sketch <hello@sketch.dev> Change-ID: s1a2b3c4d5e6f7g8h
Sketch is an agentic coding tool.
Sketch runs in your terminal, has a web UI, understands your code, and helps you get work done. To keep your environment pristine, sketch starts a docker container and outputs its work onto a branch in your host git repository.
Sketch helps with most programming environments, but Go is Sketch's specialty.
To get started:
go install sketch.dev/cmd/sketch@latest sketch
Currently sketch runs on macOS and linux. It uses docker for containers.
macOS: brew install colima (or an equivalent, like Docker Desktop or Orbstack) linux: apt install docker.io (or equivalent for your distro) WSL2: install Docker Desktop for Windows (docker entirely inside WSL2 is tricky)
The sketch.dev service is used to provide access to an LLM service and give you a way to access the web UI from anywhere.
We have a discord server to discuss sketch.
Join if you want! https://discord.gg/6w9qNRUDzS
See CONTRIBUTING.md
Sketch is open source. It is right here in this repository! Have a look around and mod away.
If you want to run sketch entirely without the sketch.dev service, you can set the flag -skaband-addr="" and then provide an ANTHROPIC_API_KEY environment variable. (More LLM services coming soon!)