Class: OmniAI::Google::Chat

Inherits:
Chat
  • Object
show all
Defined in:
lib/omniai/google/chat.rb,
lib/omniai/google/chat/text_serializer.rb,
lib/omniai/google/chat/tool_serializer.rb,
lib/omniai/google/chat/media_serializer.rb,
lib/omniai/google/chat/usage_serializer.rb,
lib/omniai/google/chat/choice_serializer.rb,
lib/omniai/google/chat/content_serializer.rb,
lib/omniai/google/chat/message_serializer.rb,
lib/omniai/google/chat/payload_serializer.rb,
lib/omniai/google/chat/function_serializer.rb,
lib/omniai/google/chat/tool_call_serializer.rb,
lib/omniai/google/chat/tool_call_result_serializer.rb

Overview

A Google chat implementation.

Usage:

chat = OmniAI::Google::Chat.new(client: client)
chat.completion('Tell me a joke.')
chat.completion(['Tell me a joke.'])
chat.completion({ role: 'user', content: 'Tell me a joke.' })
chat.completion([{ role: 'system', content: 'Tell me a joke.' }])

Defined Under Namespace

Modules: ChoiceSerializer, ContentSerializer, FunctionSerializer, MediaSerializer, MessageSerializer, Model, PayloadSerializer, TextSerializer, ToolCallResultSerializer, ToolCallSerializer, ToolSerializer, UsageSerializer

Constant Summary collapse

DEFAULT_MODEL =
Model::GEMINI_PRO
JSON_MIME_TYPE =
'application/json'
CONTEXT =

Returns:

  • (Context)
Context.build do |context|
  context.serializers[:text] = TextSerializer.method(:serialize)
  context.deserializers[:text] = TextSerializer.method(:deserialize)

  context.serializers[:file] = MediaSerializer.method(:serialize)
  context.serializers[:url] = MediaSerializer.method(:serialize)

  context.serializers[:tool_call] = ToolCallSerializer.method(:serialize)
  context.deserializers[:tool_call] = ToolCallSerializer.method(:deserialize)

  context.serializers[:tool_call_result] = ToolCallResultSerializer.method(:serialize)
  context.deserializers[:tool_call_result] = ToolCallResultSerializer.method(:deserialize)

  context.serializers[:function] = FunctionSerializer.method(:serialize)
  context.deserializers[:function] = FunctionSerializer.method(:deserialize)

  context.serializers[:usage] = UsageSerializer.method(:serialize)
  context.deserializers[:usage] = UsageSerializer.method(:deserialize)

  context.serializers[:payload] = PayloadSerializer.method(:serialize)
  context.deserializers[:payload] = PayloadSerializer.method(:deserialize)

  context.serializers[:choice] = ChoiceSerializer.method(:serialize)
  context.deserializers[:choice] = ChoiceSerializer.method(:deserialize)

  context.serializers[:message] = MessageSerializer.method(:serialize)
  context.deserializers[:message] = MessageSerializer.method(:deserialize)

  context.deserializers[:content] = ContentSerializer.method(:deserialize)

  context.serializers[:tool] = ToolSerializer.method(:serialize)
end