using System.Text.Json;
using System.Text.Json.Serialization;
using AIStudio.Provider.Anthropic;
using AIStudio.Provider.Google;
using AIStudio.Provider.Groq;
using AIStudio.Provider.HuggingFace;
using AIStudio.Provider.OpenAI;
using AIStudio.Provider.OpenRouter;
using AIStudio.Provider.Requesty;
using AnthropicDelta = AIStudio.Provider.Anthropic.Delta;
using AnthropicImageUrl = AIStudio.Provider.Anthropic.SubContentImageUrl;
using AnthropicResponseStreamLine = AIStudio.Provider.Anthropic.ResponseStreamLine;
using FireworksChoice = AIStudio.Provider.Fireworks.Choice;
using FireworksDelta = AIStudio.Provider.Fireworks.Delta;
using FireworksResponseStreamLine = AIStudio.Provider.Fireworks.ResponseStreamLine;
using HuggingFaceModelsResponse = AIStudio.Provider.HuggingFace.ModelsResponse;
using MistralModel = AIStudio.Provider.Mistral.Model;
using MistralModelsResponse = AIStudio.Provider.Mistral.ModelsResponse;
using OpenAIImageUrl = AIStudio.Provider.OpenAI.SubContentImageUrl;
using OpenAIModelsResponse = AIStudio.Provider.OpenAI.ModelsResponse;
using PerplexityChoice = AIStudio.Provider.Perplexity.Choice;
using PerplexityDelta = AIStudio.Provider.Perplexity.Delta;
using PerplexityResponseStreamLine = AIStudio.Provider.Perplexity.ResponseStreamLine;
using SelfHostedModel = AIStudio.Provider.SelfHosted.Model;
using SelfHostedModelsResponse = AIStudio.Provider.SelfHosted.ModelsResponse;
namespace AIStudio.Provider;
///
/// The contracts with which System.Text.Json reads and writes the requests and answers of LLM providers, built
/// at compile time.
///
///
/// Some types System.Text.Json meets only while it runs, since no property names them: the messages and their
/// parts, which converters write as the type they are of; the annotations, which a converter reads as the type
/// their JSON tells; and whatever a request holds as an object, i.e., the values of the additional API
/// parameters, the tools, and the items of an earlier answer. A test fails for such a type which is missing
/// here.
///
/// Two types with the same name need a name of their own for their contract, else the generator builds only
/// the first of them and warns with SYSLIB1031.
///
[JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata)]
// The requests:
[JsonSerializable(typeof(ChatCompletionAPIRequest))]
[JsonSerializable(typeof(ResponsesAPIRequest))]
[JsonSerializable(typeof(ChatRequest))]
[JsonSerializable(typeof(EmbeddingRequest))]
[JsonSerializable(typeof(GoogleEmbeddingRequest))]
// The messages and their parts:
[JsonSerializable(typeof(TextMessage))]
[JsonSerializable(typeof(MultimodalMessage))]
[JsonSerializable(typeof(AssistantToolCallMessage))]
[JsonSerializable(typeof(ToolResultMessage))]
[JsonSerializable(typeof(AnthropicMessage))]
[JsonSerializable(typeof(AnthropicToolResultMessage))]
[JsonSerializable(typeof(SubContentText))]
[JsonSerializable(typeof(OpenAIImageUrl), TypeInfoPropertyName = "OpenAISubContentImageUrl")]
[JsonSerializable(typeof(SubContentImageUrlNested))]
[JsonSerializable(typeof(SubContentImageUrlData))]
[JsonSerializable(typeof(SubContentInputText))]
[JsonSerializable(typeof(SubContentInputImage))]
[JsonSerializable(typeof(SubContentImage))]
[JsonSerializable(typeof(SubContentBase64Image))]
[JsonSerializable(typeof(AnthropicImageUrl), TypeInfoPropertyName = "AnthropicSubContentImageUrl")]
// What a request holds as an object:
[JsonSerializable(typeof(string))]
[JsonSerializable(typeof(int))]
[JsonSerializable(typeof(long))]
[JsonSerializable(typeof(double))]
[JsonSerializable(typeof(decimal))]
[JsonSerializable(typeof(bool))]
[JsonSerializable(typeof(Dictionary))]
[JsonSerializable(typeof(List