Files
moloapp/src/deepseek/calls.h
T

59 lines
2.0 KiB
C++

#pragma once
// The ONE table of REST calls this module makes. tools/check_spec.py checks
// every row against DeepSeek's published API reference (the pages rendered
// from their OpenAPI document) and the guides. Code builds every path from
// this table, never from a literal.
#include <cstddef>
#include <string>
#include "clients/request.h"
namespace molo::deepseek {
// Which ApiClient serves the row: OpenAI-compatible surface (Bearer) or the
// Anthropic-compatible surface (x-api-key). Beta rows live under /beta on the
// OpenAI-compatible surface.
enum class Surface { kOpenai, kAnthropic };
enum class Call {
kChat, kChatBeta, kFim, kResponses, kModels, kBalance,
kFileCreate, kFileList, kFileGet, kFileDelete,
kSearch, kFetch,
kMessages,
kAnthropicFileCreate, kAnthropicFileList, kAnthropicFileGet, kAnthropicFileDelete,
};
struct CallSpec {
Call call;
Surface surface;
const char* http_method; // GET POST DELETE
const char* path; // full path from the host, "{file_id}" placeholder
const char* doc; // reference page ("api/...") or guide ("guides/...")
const char* body_fields; // comma list: request body fields we send
const char* query_params; // comma list: query parameters we send
const char* response; // response schema name in the schema table
};
struct SchemaFields {
const char* schema;
const char* doc;
const char* fields; // comma list: fields we read
};
struct Calls {
static const CallSpec& spec_of(Call call);
static clients::Method method_of(Call call);
static std::size_t count();
static const CallSpec& at(std::size_t index);
static std::size_t schema_count();
static const SchemaFields& schema_at(std::size_t index);
// Path with {file_id} replaced by a validated id (llm::Service::valid_id).
static std::string render(Call call, const std::string& id = "");
// Header the Anthropic-compatible Files endpoints require.
static const char* anthropic_files_beta();
};
} // namespace molo::deepseek