Class GeminiExtensions
- Namespace
- Uralstech.UAI.Abstraction.Providers.Gemini
Extensions to convert between generic and Gemini types.
public static class GeminiExtensions
- Inheritance
-
objectGeminiExtensions
Methods
ToGemini(IReadOnlyList<Message>, out GeminiContent)
Converts a collection of generic messages to an array of Gemini messages.
public static UGemini.Models.Content.GeminiContent[] ToGemini(this IReadOnlyList<Message> messages, out UGemini.Models.Content.GeminiContent systemMessage)
Parameters
messages
IReadOnlyList<Message>systemMessage
GeminiContentSpecial handling for system role.
Returns
- GeminiContent[]
Exceptions
- InvalidOperationException
Thrown if more than one system message is found in the messages.
ToGemini(IReadOnlyList<Function>)
Converts a collection of generic functions to an array of UGemini.Models.Generation.Tools.Declaration.GeminiTools.
public static UGemini.Models.Generation.Tools.Declaration.GeminiTool ToGemini(this IReadOnlyList<Function> functions)
Parameters
functions
IReadOnlyList<Function>
Returns
- GeminiTool
ToGemini(Message)
Converts a generic message to an Gemini message. System will throw an error as it requires special handling.
public static UGemini.Models.Content.GeminiContent ToGemini(this Message message)
Parameters
message
Message
Returns
- GeminiContent
ToGemini(Role)
Converts a generic role to an Gemini role. System will throw an error as it requires special handling.
public static UGemini.Models.Content.GeminiRole ToGemini(this Role role)
Parameters
role
Role
Returns
- GeminiRole
Exceptions
- NotImplementedException
Thrown if a generic role has no known Gemini equivalent.
ToGemini(Function)
Converts a generic function to an Gemini function.
public static UGemini.Models.Generation.Tools.Declaration.GeminiFunctionDeclaration ToGemini(this Function function)
Parameters
function
Function
Returns
- GeminiFunctionDeclaration
Exceptions
- NotImplementedException
Thrown if a generic ParameterType has no known Gemini equivalent.
ToGeneric(IReadOnlyList<GeminiContent>)
Converts a collection of Gemini messages to an array of generic messages.
public static Message[] ToGeneric(this IReadOnlyList<UGemini.Models.Content.GeminiContent> messages)
Parameters
messages
IReadOnlyList<UGemini.Models.Content.GeminiContent>
Returns
- Message[]
ToGeneric(GeminiContent)
Converts an Gemini message to a generic message.
public static Message ToGeneric(this UGemini.Models.Content.GeminiContent message)
Parameters
message
GeminiContent
Returns
ToGeneric(GeminiRole)
Converts an Gemini role to a generic role.
public static Role ToGeneric(this UGemini.Models.Content.GeminiRole role)
Parameters
role
GeminiRole
Returns
Exceptions
- NotImplementedException
Thrown if a Gemini role has no known generic equivalent.
ToGeneric(GeminiUsageMetadata)
Converts an Gemini function to a generic function.
public static Usage ToGeneric(this UGemini.Models.Generation.Candidate.GeminiUsageMetadata usage)
Parameters
usage
GeminiUsageMetadata