40 lines
1.7 KiB
C++
40 lines
1.7 KiB
C++
#pragma once
|
|
|
|
// Builders for entries of the request `tools` array: ordinary function tools
|
|
// and OpenRouter server tools ("openrouter:*", run by OpenRouter itself, see
|
|
// https://openrouter.ai/docs/guides/features/server-tools). The tool type
|
|
// names come from the spec schema ChatFunctionTool; a generic envelope
|
|
// ChatDynamicServerTool accepts any registered `openrouter:*` type, so
|
|
// server() takes any well-formed name.
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "clients/body/json.h"
|
|
#include "llm/chat_types.h"
|
|
|
|
namespace molo::openrouter {
|
|
|
|
class ServerTools {
|
|
public:
|
|
// {"type":"function","function":{"name","description","parameters"[,"strict"]}}
|
|
static clients::body::Json function(const std::string& name, const std::string& description,
|
|
const clients::body::Json& parameters,
|
|
bool strict = false);
|
|
static clients::body::Json function(const llm::ToolSpec& spec);
|
|
|
|
// {"type":"openrouter:<name>"[,"parameters":{...}]}. `type` must start with
|
|
// "openrouter:" and use [a-z0-9_:] after it. `parameters` null: omitted.
|
|
static clients::body::Json server(const std::string& type,
|
|
const clients::body::Json& parameters = clients::body::Json());
|
|
|
|
static clients::body::Json web_search(const clients::body::Json& parameters = clients::body::Json());
|
|
static clients::body::Json web_fetch(const clients::body::Json& parameters = clients::body::Json());
|
|
static clients::body::Json datetime(const clients::body::Json& parameters = clients::body::Json());
|
|
|
|
// Server tool types named by the spec (not exhaustive: see server()).
|
|
static const std::vector<std::string>& known_types();
|
|
};
|
|
|
|
} // namespace molo::openrouter
|