schemaToTool unwraps a tool schema (the map[string]any shape shared by bash and the file tools) into the typed llm.Tool the chat payload expects.
(s map[string]any)
| 695 | // buildTools exposes the four local tools every turn: bash, read_file, |
| 696 | // write_file, edit_file. No loop/control tool; a turn ends when the model |
| 697 | // stops emitting tool calls (see handleStreamClosed). |
| 698 | func (m *Model) buildTools() []llm.Tool { |
| 699 | return []llm.Tool{ |
| 700 | schemaToTool(tools.BashSchema()), |
| 701 | schemaToTool(tools.ReadFileSchema()), |
| 702 | schemaToTool(tools.WriteFileSchema()), |
| 703 | schemaToTool(tools.EditFileSchema()), |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | // schemaToTool unwraps a tool schema (the map[string]any shape shared by bash |
| 708 | // and the file tools) into the typed llm.Tool the chat payload expects. |
| 709 | func schemaToTool(s map[string]any) llm.Tool { |
| 710 | fn := s["function"].(map[string]any) |