feat: add non-streaming LLM API, tool registry, and web_search tool
Replace SSE streaming with non-streaming JSON for Anthropic API. Add llm_chat_tools() returning structured llm_response_t with text and tool_use blocks. Implement tool registry with dispatch-by-name and web_search tool via Brave Search API (direct + proxy support). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
34
main/tools/tool_registry.h
Normal file
34
main/tools/tool_registry.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *description;
|
||||
const char *input_schema_json; /* JSON Schema string for input */
|
||||
esp_err_t (*execute)(const char *input_json, char *output, size_t output_size);
|
||||
} mimi_tool_t;
|
||||
|
||||
/**
|
||||
* Initialize tool registry and register all built-in tools.
|
||||
*/
|
||||
esp_err_t tool_registry_init(void);
|
||||
|
||||
/**
|
||||
* Get the pre-built tools JSON array string for the API request.
|
||||
* Returns NULL if no tools are registered.
|
||||
*/
|
||||
const char *tool_registry_get_tools_json(void);
|
||||
|
||||
/**
|
||||
* Execute a tool by name.
|
||||
*
|
||||
* @param name Tool name (e.g. "web_search")
|
||||
* @param input_json JSON string of tool input
|
||||
* @param output Output buffer for tool result text
|
||||
* @param output_size Size of output buffer
|
||||
* @return ESP_OK on success, ESP_ERR_NOT_FOUND if tool unknown
|
||||
*/
|
||||
esp_err_t tool_registry_execute(const char *name, const char *input_json,
|
||||
char *output, size_t output_size);
|
||||
Reference in New Issue
Block a user