feat(clients): deepseek: chat, beta, responses, anthropic, files, search, fetch, spec checker, demo
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
// Files API: image uploads referenced by file_id (file-api-...) from chat,
|
||||
// Responses and Anthropic-compatible requests. Two surfaces, two shapes:
|
||||
// Files (OpenAI-compatible, /files) and AnthropicFiles (/anthropic/v1/files,
|
||||
// header anthropic-beta: files-api-2025-04-14). Files are account-wide.
|
||||
// Delete is an explicit method with no default and no implicit call.
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "deepseek/types.h"
|
||||
#include "llm/api_client.h"
|
||||
|
||||
namespace molo::deepseek {
|
||||
|
||||
struct UploadParams {
|
||||
std::string filename; // 1..512 bytes
|
||||
std::string data; // JPEG, PNG, GIF or WebP bytes, 1..64 MiB (magic bytes checked)
|
||||
std::optional<long> expires_after_seconds; // 3600..2592000; unset keeps the file
|
||||
void validate() const;
|
||||
// jpeg, png, gif, webp, or "" when the bytes are none of them
|
||||
static std::string sniff(const std::string& data);
|
||||
};
|
||||
|
||||
struct FileListParams {
|
||||
std::string after; // file_id cursor
|
||||
int limit = 1000; // 1..1000
|
||||
std::string order; // "", asc, desc
|
||||
void validate() const;
|
||||
};
|
||||
|
||||
struct FileDeleted {
|
||||
std::string id;
|
||||
bool deleted = false;
|
||||
};
|
||||
|
||||
class Files : public llm::Service {
|
||||
public:
|
||||
static constexpr const char* kPurpose = "user_data";
|
||||
explicit Files(std::shared_ptr<llm::ApiClient> client) : llm::Service(std::move(client)) {}
|
||||
FileInfo upload(const UploadParams& params);
|
||||
FileList list(const FileListParams& params = {});
|
||||
// Follows `after` up to DeepseekCaps::kMaxFilePages pages; truncated is set
|
||||
// when more remain.
|
||||
FileList list_all(int page_limit = 1000);
|
||||
FileInfo get(const std::string& file_id);
|
||||
FileDeleted remove(const std::string& file_id); // explicit, irreversible
|
||||
};
|
||||
|
||||
struct AnthropicFileListParams {
|
||||
std::string after_id; // exclusive with before_id
|
||||
std::string before_id;
|
||||
int limit = 20; // 1..1000
|
||||
void validate() const;
|
||||
};
|
||||
|
||||
class AnthropicFiles : public llm::Service {
|
||||
public:
|
||||
explicit AnthropicFiles(std::shared_ptr<llm::ApiClient> client)
|
||||
: llm::Service(std::move(client)) {}
|
||||
FileInfo upload(const UploadParams& params);
|
||||
FileList list(const AnthropicFileListParams& params = {});
|
||||
FileInfo get(const std::string& file_id);
|
||||
FileDeleted remove(const std::string& file_id); // answers {"id","type":"file_deleted"}
|
||||
};
|
||||
|
||||
} // namespace molo::deepseek
|
||||
Reference in New Issue
Block a user