From 22c9758666baa592f1f69c3f1d2fb842efadd56a Mon Sep 17 00:00:00 2001 From: Jamie Gaskins Date: Thu, 8 Aug 2024 19:35:52 -0500 Subject: [PATCH] Add initial documentation --- .gitignore | 1 - README.md | 30 +- docs/404.html | 422 +++++++ docs/Anthropic.html | 648 ++++++++++ docs/Anthropic/API.html | 629 ++++++++++ docs/Anthropic/Client.html | 658 ++++++++++ docs/Anthropic/ContentBlockDelta.html | 710 +++++++++++ docs/Anthropic/ContentBlockStart.html | 710 +++++++++++ .../ContentBlockStart/ContentBlock.html | 708 +++++++++++ docs/Anthropic/ContentBlockStop.html | 650 ++++++++++ docs/Anthropic/Converters.html | 487 ++++++++ docs/Anthropic/Converters/TimeSpan.html | 542 ++++++++ docs/Anthropic/Error.html | 621 ++++++++++ docs/Anthropic/Error/APIError.html | 544 ++++++++ docs/Anthropic/Error/AuthenticationError.html | 544 ++++++++ docs/Anthropic/Error/InvalidRequestError.html | 544 ++++++++ docs/Anthropic/Error/NotFoundError.html | 544 ++++++++ docs/Anthropic/Error/OverloadedError.html | 544 ++++++++ docs/Anthropic/Error/PermissionError.html | 544 ++++++++ docs/Anthropic/Error/RateLimitError.html | 544 ++++++++ docs/Anthropic/Error/Response.html | 670 ++++++++++ docs/Anthropic/Error/Response/Error.html | 670 ++++++++++ docs/Anthropic/Event.html | 664 ++++++++++ docs/Anthropic/EventMessage.html | 690 +++++++++++ docs/Anthropic/EventSource.html | 677 ++++++++++ docs/Anthropic/GeneratedMessage.html | 937 ++++++++++++++ docs/Anthropic/GeneratedMessage/Content.html | 667 ++++++++++ .../GeneratedMessage/Content/Type.html | 608 +++++++++ .../GeneratedMessage/StopReason.html | 656 ++++++++++ docs/Anthropic/GeneratedMessage/Text.html | 671 ++++++++++ docs/Anthropic/GeneratedMessage/ToolUse.html | 690 +++++++++++ .../ToolUse/PossibleSchema.html | 513 ++++++++ .../GeneratedMessage/ToolUse/Schema.html | 636 ++++++++++ docs/Anthropic/GeneratedMessage/Usage.html | 670 ++++++++++ docs/Anthropic/Image.html | 753 +++++++++++ docs/Anthropic/Image/Source.html | 746 +++++++++++ docs/Anthropic/Image/Source/MediaType.html | 696 +++++++++++ docs/Anthropic/Image/Source/Type.html | 584 +++++++++ docs/Anthropic/Message.html | 689 +++++++++++ docs/Anthropic/Message/Role.html | 608 +++++++++ docs/Anthropic/MessageContent.html | 669 ++++++++++ docs/Anthropic/MessageDelta.html | 710 +++++++++++ docs/Anthropic/MessageDelta/Delta.html | 670 ++++++++++ docs/Anthropic/MessageDelta/Usage.html | 651 ++++++++++ docs/Anthropic/MessageStart.html | 691 +++++++++++ docs/Anthropic/MessageStop.html | 650 ++++++++++ docs/Anthropic/MessageStream.html | 650 ++++++++++ docs/Anthropic/Messages.html | 613 +++++++++ docs/Anthropic/Messages/Body.html | 610 +++++++++ docs/Anthropic/Messages/Query.html | 610 +++++++++ docs/Anthropic/Messages/Request.html | 917 ++++++++++++++ docs/Anthropic/Model.html | 632 ++++++++++ docs/Anthropic/Ping.html | 650 ++++++++++ docs/Anthropic/Resource.html | 532 ++++++++ docs/Anthropic/Text.html | 731 +++++++++++ docs/Anthropic/TextDelta.html | 651 ++++++++++ docs/Anthropic/TextOrImageContent.html | 627 ++++++++++ docs/Anthropic/Tool.html | 727 +++++++++++ docs/Anthropic/Tool/Handler.html | 696 +++++++++++ docs/Anthropic/ToolResult.html | 747 +++++++++++ docs/Anthropic/ToolUse.html | 728 +++++++++++ docs/css/style.css | 980 +++++++++++++++ docs/index.html | 687 +++++++++++ docs/index.json | 1 + docs/js/doc.js | 1099 +++++++++++++++++ docs/search-index.js | 1 + src/api.cr | 2 +- src/client.cr | 21 + src/event_source.cr | 12 +- src/generated_message.cr | 1 - src/messages.cr | 9 +- 71 files changed, 41068 insertions(+), 26 deletions(-) create mode 100644 docs/404.html create mode 100644 docs/Anthropic.html create mode 100644 docs/Anthropic/API.html create mode 100644 docs/Anthropic/Client.html create mode 100644 docs/Anthropic/ContentBlockDelta.html create mode 100644 docs/Anthropic/ContentBlockStart.html create mode 100644 docs/Anthropic/ContentBlockStart/ContentBlock.html create mode 100644 docs/Anthropic/ContentBlockStop.html create mode 100644 docs/Anthropic/Converters.html create mode 100644 docs/Anthropic/Converters/TimeSpan.html create mode 100644 docs/Anthropic/Error.html create mode 100644 docs/Anthropic/Error/APIError.html create mode 100644 docs/Anthropic/Error/AuthenticationError.html create mode 100644 docs/Anthropic/Error/InvalidRequestError.html create mode 100644 docs/Anthropic/Error/NotFoundError.html create mode 100644 docs/Anthropic/Error/OverloadedError.html create mode 100644 docs/Anthropic/Error/PermissionError.html create mode 100644 docs/Anthropic/Error/RateLimitError.html create mode 100644 docs/Anthropic/Error/Response.html create mode 100644 docs/Anthropic/Error/Response/Error.html create mode 100644 docs/Anthropic/Event.html create mode 100644 docs/Anthropic/EventMessage.html create mode 100644 docs/Anthropic/EventSource.html create mode 100644 docs/Anthropic/GeneratedMessage.html create mode 100644 docs/Anthropic/GeneratedMessage/Content.html create mode 100644 docs/Anthropic/GeneratedMessage/Content/Type.html create mode 100644 docs/Anthropic/GeneratedMessage/StopReason.html create mode 100644 docs/Anthropic/GeneratedMessage/Text.html create mode 100644 docs/Anthropic/GeneratedMessage/ToolUse.html create mode 100644 docs/Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html create mode 100644 docs/Anthropic/GeneratedMessage/ToolUse/Schema.html create mode 100644 docs/Anthropic/GeneratedMessage/Usage.html create mode 100644 docs/Anthropic/Image.html create mode 100644 docs/Anthropic/Image/Source.html create mode 100644 docs/Anthropic/Image/Source/MediaType.html create mode 100644 docs/Anthropic/Image/Source/Type.html create mode 100644 docs/Anthropic/Message.html create mode 100644 docs/Anthropic/Message/Role.html create mode 100644 docs/Anthropic/MessageContent.html create mode 100644 docs/Anthropic/MessageDelta.html create mode 100644 docs/Anthropic/MessageDelta/Delta.html create mode 100644 docs/Anthropic/MessageDelta/Usage.html create mode 100644 docs/Anthropic/MessageStart.html create mode 100644 docs/Anthropic/MessageStop.html create mode 100644 docs/Anthropic/MessageStream.html create mode 100644 docs/Anthropic/Messages.html create mode 100644 docs/Anthropic/Messages/Body.html create mode 100644 docs/Anthropic/Messages/Query.html create mode 100644 docs/Anthropic/Messages/Request.html create mode 100644 docs/Anthropic/Model.html create mode 100644 docs/Anthropic/Ping.html create mode 100644 docs/Anthropic/Resource.html create mode 100644 docs/Anthropic/Text.html create mode 100644 docs/Anthropic/TextDelta.html create mode 100644 docs/Anthropic/TextOrImageContent.html create mode 100644 docs/Anthropic/Tool.html create mode 100644 docs/Anthropic/Tool/Handler.html create mode 100644 docs/Anthropic/ToolResult.html create mode 100644 docs/Anthropic/ToolUse.html create mode 100644 docs/css/style.css create mode 100644 docs/index.html create mode 100644 docs/index.json create mode 100644 docs/js/doc.js create mode 100644 docs/search-index.js diff --git a/.gitignore b/.gitignore index 0bbd4a9..82f1ad5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/docs/ /lib/ /bin/ /.shards/ diff --git a/README.md b/README.md index 4c8656a..6b126c4 100644 --- a/README.md +++ b/README.md @@ -18,20 +18,30 @@ Client for the Anthropic API. Supports tool use and running those tools automati ```crystal require "anthropic" +``` + +The main entrypoint is via the `Anthropic::Client`. You can instantiate it explicitly with an API key: -# Instantiate it explicitly with an API key +```crystal claude = Anthropic::Client.new("sk-and-api-03-asdfasdfasdf") +``` + +Or you can omit the API key to automatically read it from the `ANTHROPIC_API_KEY` environment variable: -# If you omit the API key, it will be retrieved from the -# ANTHROPIC_API_KEY environment variable +```crystal claude = Anthropic::Client.new +``` -puts claude.messages.create( +Next, use the `Anthropic::Messages#create` method to send your prompt: + +```crystal +response = claude.messages.create( # Pass a string representing the model name, or retrieve the full model # name via the shorthand with Anthropic.model_name. model: Anthropic.model_name(:sonnet), - # Define a system prompt if you want to give the AI a persona to use + # Define a system prompt if you want to give the AI a persona to use or some + # instructions on how to respond to the prompt. system: "You are an expert in the Crystal programming language", # You can pass the full list of messages, including messages it gave you @@ -50,10 +60,12 @@ puts claude.messages.create( # will be more stochastic. temperature: 0.5, - # You can pass an `Array` of tools to give the client a way to run custom code - # in your app. See below for additional information on how to define those. - # The more tools you pass in with a request, the more tokens the request will - # use, so you should keep this to a reasonable size. + # You can optionally pass an `Array` of tools to give the client a way to run + # custom code in your app. See below for additional information on how to + # define those. The more tools you pass in with a request, the more tokens the + # request will use, so you should keep this to a reasonable size. + # + # If no tools are specified, the model won't try to run any. tools: [ GitHubUserLookup, GoogleDriveSearch.new(google_oauth_token), diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..be79971 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,422 @@ + + + + + + + + + + + + + + + + + anthropic main-dev + + + + + + + + + + +
+

+ 404 Not Found +

+ +

+ This page is unavailable in this version of the API docs. +

+ +

+ You can use the sidebar to search for your page, or try a different + Crystal version. +

+ +
+ + diff --git a/docs/Anthropic.html b/docs/Anthropic.html new file mode 100644 index 0000000..a567b21 --- /dev/null +++ b/docs/Anthropic.html @@ -0,0 +1,648 @@ + + + + + + + + + + + + + + + + + Anthropic - anthropic main-dev + + + + + + + + + + +
+

+ + module Anthropic + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + api.cr + +
+ + + error.cr + +
+ + + event_source.cr + +
+ + + message_content.cr + +
+ + + messages.cr + +
+ + + model.cr + +
+ + + resource.cr + +
+ + + tool.cr + +
+ + + version.cr + +
+ + + + + +

+ + + + Constant Summary +

+ +
+ +
+ VERSION = "0.1.0" +
+ + +
+ + + + + +

+ + + + Class Method Summary +

+ + + + + + + + +
+ +
+ + + + +

+ + + + Class Method Detail +

+ +
+
+ + def self.model_name(model : Model) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.tool(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool + + # +
+ +
+
+ +
+
+ +
+
+ + def self.tools(array : Array(Tool)) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.tools(array : Enumerable) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.tools(array : Nil) + + # +
+ +
+
+ +
+
+ + + + + + + +
+ + + diff --git a/docs/Anthropic/API.html b/docs/Anthropic/API.html new file mode 100644 index 0000000..71f7ed4 --- /dev/null +++ b/docs/Anthropic/API.html @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + Anthropic::API - anthropic main-dev + + + + + + + + + + +
+

+ + abstract struct Anthropic::API + +

+ + + + + + + + + + + + + + + +

+ + + + Direct Known Subclasses +

+ + + + + + + +

+ + + + Defined in: +

+ + + api.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(client : Anthropic::Client) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def client : Client + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Client.html b/docs/Anthropic/Client.html new file mode 100644 index 0000000..0cb8ba9 --- /dev/null +++ b/docs/Anthropic/Client.html @@ -0,0 +1,658 @@ + + + + + + + + + + + + + + + + + Anthropic::Client - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Client + +

+ + + + + + + +

+ + + + Overview +

+ +

The Anthropic::Client is the entrypoint for using the Anthropic API in +Crystal.

+
claude = Anthropic::Client.new # get API key from the ENV
+puts claude.messages.create(
+  model: Anthropic.model_name(:haiku),
+  messages: [Anthropic::Message.new("Write a haiku about the Crystal programming language")],
+  max_tokens: 4096,
+)
+# Sparkling Crystal code,
+# Elegant and swift syntax,
+# Shines with precision.
+

The client is concurrency-safe, so you don't need to wrap requests in a mutex +or manage a connection pool yourself.

+ + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + client.cr + +
+ + + messages.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(api_key : String = ENV["ANTHROPIC_API_KEY"], base_uri : URI = URI.parse(ENV.fetch("ANTHROPIC_BASE_URL", "https://api.anthropic.com")), log : Log = Log.for(self.class)) + + # +
+ +
+ +

Instantiate a new client with the API key provided either directly or via +the ANTHROPIC_API_KEY environment variable. You can optionally provide a +base URI to connect to if you are using a different but compatible API +provider.

+
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def api_key : String + + # +
+ +
+
+ +
+
+ +
+
+ + def base_uri : URI + + # +
+ +
+
+ +
+
+ +
+
+ + def messages + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/ContentBlockDelta.html b/docs/Anthropic/ContentBlockDelta.html new file mode 100644 index 0000000..23aa96c --- /dev/null +++ b/docs/Anthropic/ContentBlockDelta.html @@ -0,0 +1,710 @@ + + + + + + + + + + + + + + + + + Anthropic::ContentBlockDelta - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::ContentBlockDelta + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def delta : TextDelta + + # +
+ +
+
+ +
+
+ +
+
+ + def index : Int64 + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/ContentBlockStart.html b/docs/Anthropic/ContentBlockStart.html new file mode 100644 index 0000000..8134b67 --- /dev/null +++ b/docs/Anthropic/ContentBlockStart.html @@ -0,0 +1,710 @@ + + + + + + + + + + + + + + + + + Anthropic::ContentBlockStart - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::ContentBlockStart + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def content_block : ContentBlock | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def index : Int64 + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/ContentBlockStart/ContentBlock.html b/docs/Anthropic/ContentBlockStart/ContentBlock.html new file mode 100644 index 0000000..6c93123 --- /dev/null +++ b/docs/Anthropic/ContentBlockStart/ContentBlock.html @@ -0,0 +1,708 @@ + + + + + + + + + + + + + + + + + Anthropic::ContentBlockStart::ContentBlock - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::ContentBlockStart::ContentBlock + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def id : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def input : JSON::Any | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def name : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def type : GeneratedMessage::Content::Type | Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/ContentBlockStop.html b/docs/Anthropic/ContentBlockStop.html new file mode 100644 index 0000000..eddcbee --- /dev/null +++ b/docs/Anthropic/ContentBlockStop.html @@ -0,0 +1,650 @@ + + + + + + + + + + + + + + + + + Anthropic::ContentBlockStop - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::ContentBlockStop + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Converters.html b/docs/Anthropic/Converters.html new file mode 100644 index 0000000..47af878 --- /dev/null +++ b/docs/Anthropic/Converters.html @@ -0,0 +1,487 @@ + + + + + + + + + + + + + + + + + Anthropic::Converters - anthropic main-dev + + + + + + + + + + +
+

+ + module Anthropic::Converters + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + messages.cr + +
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Converters/TimeSpan.html b/docs/Anthropic/Converters/TimeSpan.html new file mode 100644 index 0000000..f9f6cec --- /dev/null +++ b/docs/Anthropic/Converters/TimeSpan.html @@ -0,0 +1,542 @@ + + + + + + + + + + + + + + + + + Anthropic::Converters::TimeSpan - anthropic main-dev + + + + + + + + + + +
+

+ + module Anthropic::Converters::TimeSpan + +

+ + + + + + + + + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + messages.cr + +
+ + + + + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def to_json(value : Time::Span, json : JSON::Builder) + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Error.html b/docs/Anthropic/Error.html new file mode 100644 index 0000000..678ea60 --- /dev/null +++ b/docs/Anthropic/Error.html @@ -0,0 +1,621 @@ + + + + + + + + + + + + + + + + + Anthropic::Error - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error + +

+ + + + + + + + + + + + + + + +

+ + + + Direct Known Subclasses +

+ + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + +

+ + + + Class Method Summary +

+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(message : String) + + # +
+ +
+
+ +
+
+ + + + +

+ + + + Class Method Detail +

+ +
+
+ + def self.from_response_body(body : String) + + # +
+ +
+
+ +
+
+ + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/APIError.html b/docs/Anthropic/Error/APIError.html new file mode 100644 index 0000000..a6dfb2d --- /dev/null +++ b/docs/Anthropic/Error/APIError.html @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::APIError - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error::APIError + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + + + + + + + + + +
+ + + + + + +

Constructor methods inherited from class Anthropic::Error

+ + + + new(message : String) + new + + + + + + +

Class methods inherited from class Anthropic::Error

+ + + + from_response_body(body : String) + from_response_body + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/AuthenticationError.html b/docs/Anthropic/Error/AuthenticationError.html new file mode 100644 index 0000000..efa8cac --- /dev/null +++ b/docs/Anthropic/Error/AuthenticationError.html @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::AuthenticationError - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error::AuthenticationError + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + + + + + + + + + +
+ + + + + + +

Constructor methods inherited from class Anthropic::Error

+ + + + new(message : String) + new + + + + + + +

Class methods inherited from class Anthropic::Error

+ + + + from_response_body(body : String) + from_response_body + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/InvalidRequestError.html b/docs/Anthropic/Error/InvalidRequestError.html new file mode 100644 index 0000000..6d77523 --- /dev/null +++ b/docs/Anthropic/Error/InvalidRequestError.html @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::InvalidRequestError - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error::InvalidRequestError + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + + + + + + + + + +
+ + + + + + +

Constructor methods inherited from class Anthropic::Error

+ + + + new(message : String) + new + + + + + + +

Class methods inherited from class Anthropic::Error

+ + + + from_response_body(body : String) + from_response_body + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/NotFoundError.html b/docs/Anthropic/Error/NotFoundError.html new file mode 100644 index 0000000..9e84d7a --- /dev/null +++ b/docs/Anthropic/Error/NotFoundError.html @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::NotFoundError - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error::NotFoundError + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + + + + + + + + + +
+ + + + + + +

Constructor methods inherited from class Anthropic::Error

+ + + + new(message : String) + new + + + + + + +

Class methods inherited from class Anthropic::Error

+ + + + from_response_body(body : String) + from_response_body + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/OverloadedError.html b/docs/Anthropic/Error/OverloadedError.html new file mode 100644 index 0000000..a42fe01 --- /dev/null +++ b/docs/Anthropic/Error/OverloadedError.html @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::OverloadedError - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error::OverloadedError + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + + + + + + + + + +
+ + + + + + +

Constructor methods inherited from class Anthropic::Error

+ + + + new(message : String) + new + + + + + + +

Class methods inherited from class Anthropic::Error

+ + + + from_response_body(body : String) + from_response_body + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/PermissionError.html b/docs/Anthropic/Error/PermissionError.html new file mode 100644 index 0000000..14dc1d6 --- /dev/null +++ b/docs/Anthropic/Error/PermissionError.html @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::PermissionError - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error::PermissionError + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + + + + + + + + + +
+ + + + + + +

Constructor methods inherited from class Anthropic::Error

+ + + + new(message : String) + new + + + + + + +

Class methods inherited from class Anthropic::Error

+ + + + from_response_body(body : String) + from_response_body + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/RateLimitError.html b/docs/Anthropic/Error/RateLimitError.html new file mode 100644 index 0000000..a2b2d0c --- /dev/null +++ b/docs/Anthropic/Error/RateLimitError.html @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::RateLimitError - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::Error::RateLimitError + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + + + + + + + + + +
+ + + + + + +

Constructor methods inherited from class Anthropic::Error

+ + + + new(message : String) + new + + + + + + +

Class methods inherited from class Anthropic::Error

+ + + + from_response_body(body : String) + from_response_body + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Error/Response.html b/docs/Anthropic/Error/Response.html new file mode 100644 index 0000000..2bbd96b --- /dev/null +++ b/docs/Anthropic/Error/Response.html @@ -0,0 +1,670 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::Response - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Error::Response + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def error : Error + + # +
+ +
+
+ +
+
+ +
+
+ + def type : String + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Error/Response/Error.html b/docs/Anthropic/Error/Response/Error.html new file mode 100644 index 0000000..55df3f2 --- /dev/null +++ b/docs/Anthropic/Error/Response/Error.html @@ -0,0 +1,670 @@ + + + + + + + + + + + + + + + + + Anthropic::Error::Response::Error - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Error::Response::Error + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + error.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def message : String + + # +
+ +
+
+ +
+
+ +
+
+ + def type : String + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Event.html b/docs/Anthropic/Event.html new file mode 100644 index 0000000..d1545dc --- /dev/null +++ b/docs/Anthropic/Event.html @@ -0,0 +1,664 @@ + + + + + + + + + + + + + + + + + Anthropic::Event - anthropic main-dev + + + + + + + + + + +
+

+ + abstract struct Anthropic::Event + +

+ + + + + + + + + + + + + + + +

+ + + + Direct Known Subclasses +

+ + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + +

+ + + + Macro Summary +

+ + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new + + # +
+ +
+
+ +
+
+ + + + + + +

+ + + + Macro Detail +

+ +
+
+ + macro define(type) + + # +
+ +
+
+ +
+
+ + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def initialize + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/EventMessage.html b/docs/Anthropic/EventMessage.html new file mode 100644 index 0000000..5c30c1a --- /dev/null +++ b/docs/Anthropic/EventMessage.html @@ -0,0 +1,690 @@ + + + + + + + + + + + + + + + + + Anthropic::EventMessage - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::EventMessage + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def clone + + # +
+ +
+
+ +
+
+ +
+
+ + def copy_with(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry) + + # +
+ +
+
+ +
+
+ +
+
+ + def data : Array(String) + + # +
+ +
+
+ +
+
+ +
+
+ + def event : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def id : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def retry : Int64 | Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/EventSource.html b/docs/Anthropic/EventSource.html new file mode 100644 index 0000000..5633a37 --- /dev/null +++ b/docs/Anthropic/EventSource.html @@ -0,0 +1,677 @@ + + + + + + + + + + + + + + + + + Anthropic::EventSource - anthropic main-dev + + + + + + + + + + +
+

+ + class Anthropic::EventSource + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(response : HTTP::Client::Response, last_id : Nil | String = nil) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def last_id : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def on_error(&on_error : NamedTuple(status_code: Int32, message: String) -> ) : self + + # +
+ +
+
+ +
+
+ +
+
+ + def on_message(&on_message : EventMessage, self -> ) : self + + # +
+ +
+
+ +
+
+ +
+
+ + def response : HTTP::Client::Response + + # +
+ +
+
+ +
+
+ +
+
+ + def run : Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def stop : Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage.html b/docs/Anthropic/GeneratedMessage.html new file mode 100644 index 0000000..f7c43cd --- /dev/null +++ b/docs/Anthropic/GeneratedMessage.html @@ -0,0 +1,937 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::GeneratedMessage + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def content : Array(MessageContent) + + # +
+ +
+ +

This is an array of content blocks, each of which has a #type that determines +its shape. Currently, the only #type in responses is "text".

+

Example:

+
[{ "type": "text", "text": "Hi, I'm Claude." }]
+

If the request input messages ended with an assistant turn, then the +response #content will continue directly from that last turn. You can use this +to constrain the model's output.

+

For example, if the input messages were:

+
[
+  {
+    "role": "user",
+    "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
+  },
+  { "role": "assistant", "content": "The best answer is (" }
+]
+

Then the response #content might be:

+
[{ "type": "text", "text": "B)" }]
+
+ +
+
+ +
+
+ +
+
+ + def id : String + + # +
+ +
+ +

Unique object identifier.

+

The format and length of IDs may change over time.

+
+ +
+
+ +
+
+ +
+
+ + def message_thread : Array(Message) + + # +
+ +
+ +

Messages that were passed to the

+
+ +
+
+ +
+
+ +
+
+ + def model : String + + # +
+ +
+ +

The model that handled the request.

+
+ +
+
+ +
+
+ +
+
+ + def role : Message::Role + + # +
+ +
+ +

Conversational role of the generated message. This will always be :assistant.

+
+ +
+
+ +
+
+ +
+
+ + def stop_reason : StopReason | Nil + + # +
+ +
+ +

The reason that we stopped. This may be one the following values:

+
    +
  • :end_turn: the model reached a natural stopping point
  • +
  • :max_tokens: we exceeded the requested max_tokens or the model's maximum
  • +
  • :stop_sequence: one of your provided custom stop_sequences was generated
  • +
+

In non-streaming mode this value is always non-null. In streaming mode, it is +nil in the MessageStart event and non-nil otherwise.

+
+ +
+
+ +
+
+ +
+
+ + def stop_sequence : String | Nil + + # +
+ +
+ +

Which custom stop sequence was generated, if any. This value will be a non- +nil string if one of your custom stop sequences was generated.

+
+ +
+
+ +
+
+ +
+
+ + def to_message + + # +
+ +
+
+ +
+
+ +
+
+ + def to_s(io) : Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def type : String + + # +
+ +
+ +

Object type — for Messages, this is always "message".

+
+ +
+
+ +
+
+ +
+
+ + def usage : Usage + + # +
+ +
+ +

Billing and rate-limit usage.

+

Anthropic's API bills and rate-limits by token counts, as tokens represent the +underlying cost to our systems.

+

Under the hood, the API transforms requests into a format suitable for the +model. The model's output then goes through a parsing stage before becoming an +API response. As a result, the token counts in #usage will not match one-to-one +with the exact visible content of an API request or response.

+

For example, output_tokens will be non-zero, even for an empty string response +from Claude.

+
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/Content.html b/docs/Anthropic/GeneratedMessage/Content.html new file mode 100644 index 0000000..a144d0e --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/Content.html @@ -0,0 +1,667 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::Content - anthropic main-dev + + + + + + + + + + +
+

+ + abstract struct Anthropic::GeneratedMessage::Content + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + +

+ + + + Direct Known Subclasses +

+ + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def type : Type + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/Content/Type.html b/docs/Anthropic/GeneratedMessage/Content/Type.html new file mode 100644 index 0000000..3cbd1ff --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/Content/Type.html @@ -0,0 +1,608 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::Content::Type - anthropic main-dev + + + + + + + + + + +
+

+ + enum Anthropic::GeneratedMessage::Content::Type + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + +

+ + + + Enum Members +

+ +
+ +
+ Text = 0 +
+ + +
+ ToolUse = 1 +
+ + +
+ + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def text? + + # +
+ +
+
+ +
+
+ +
+
+ + def tool_use? + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/StopReason.html b/docs/Anthropic/GeneratedMessage/StopReason.html new file mode 100644 index 0000000..c0e8423 --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/StopReason.html @@ -0,0 +1,656 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::StopReason - anthropic main-dev + + + + + + + + + + +
+

+ + enum Anthropic::GeneratedMessage::StopReason + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + +

+ + + + Enum Members +

+ +
+ +
+ EndTurn = 0 +
+ + +
+ MaxTokens = 1 +
+ + +
+ StopSequence = 2 +
+ + +
+ ToolUse = 3 +
+ + +
+ + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def end_turn? + + # +
+ +
+
+ +
+
+ +
+
+ + def max_tokens? + + # +
+ +
+
+ +
+
+ +
+
+ + def stop_sequence? + + # +
+ +
+
+ +
+
+ +
+
+ + def tool_use? + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/Text.html b/docs/Anthropic/GeneratedMessage/Text.html new file mode 100644 index 0000000..6aa739b --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/Text.html @@ -0,0 +1,671 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::Text - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::GeneratedMessage::Text + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + +

Instance methods inherited from struct Anthropic::GeneratedMessage::Content

+ + + + type : Type + type + + + + + + +

Constructor methods inherited from struct Anthropic::GeneratedMessage::Content

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def text : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def to_s(io) : Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/ToolUse.html b/docs/Anthropic/GeneratedMessage/ToolUse.html new file mode 100644 index 0000000..90a3791 --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/ToolUse.html @@ -0,0 +1,690 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::ToolUse - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::GeneratedMessage::ToolUse + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + +

Instance methods inherited from struct Anthropic::GeneratedMessage::Content

+ + + + type : Type + type + + + + + + +

Constructor methods inherited from struct Anthropic::GeneratedMessage::Content

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def id : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def input : JSON::Any + + # +
+ +
+
+ +
+
+ +
+
+ + def name : String | Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html b/docs/Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html new file mode 100644 index 0000000..a8b6b0e --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html @@ -0,0 +1,513 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::ToolUse::PossibleSchema - anthropic main-dev + + + + + + + + + + +
+

+ + module Anthropic::GeneratedMessage::ToolUse::PossibleSchema + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + + + + +

+ + + + Class Method Summary +

+ + + + + + + + +
+ +
+ + + + +

+ + + + Class Method Detail +

+ +
+
+ + def self.from_json(json : JSON::PullParser) : JSON::Any + + # +
+ +
+
+ +
+
+ + + + + + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/ToolUse/Schema.html b/docs/Anthropic/GeneratedMessage/ToolUse/Schema.html new file mode 100644 index 0000000..77d3b31 --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/ToolUse/Schema.html @@ -0,0 +1,636 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::ToolUse::Schema - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::GeneratedMessage::ToolUse::Schema + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def properties : JSON::Any + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/GeneratedMessage/Usage.html b/docs/Anthropic/GeneratedMessage/Usage.html new file mode 100644 index 0000000..eea69fd --- /dev/null +++ b/docs/Anthropic/GeneratedMessage/Usage.html @@ -0,0 +1,670 @@ + + + + + + + + + + + + + + + + + Anthropic::GeneratedMessage::Usage - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::GeneratedMessage::Usage + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + generated_message.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def input_tokens : Int64 + + # +
+ +
+
+ +
+
+ +
+
+ + def output_tokens : Int64 + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Image.html b/docs/Anthropic/Image.html new file mode 100644 index 0000000..48dcc2d --- /dev/null +++ b/docs/Anthropic/Image.html @@ -0,0 +1,753 @@ + + + + + + + + + + + + + + + + + Anthropic::Image - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Image + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + +

+ + + + Class Method Summary +

+ + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + +

Constructor methods inherited from struct Anthropic::TextOrImageContent

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::MessageContent

+ + + + type : String + type + + + + + + +

Constructor methods inherited from struct Anthropic::MessageContent

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(*, type : Source::Type, media_type : Source::MediaType, data : String) + + # +
+ +
+
+ +
+
+ + + + +

+ + + + Class Method Detail +

+ +
+
+ + def self.base64(media_type : Source::MediaType, data : String) + + # +
+ +
+
+ +
+
+ + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def source : Source + + # +
+ +
+
+ +
+
+ +
+
+ + def type : String + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Image/Source.html b/docs/Anthropic/Image/Source.html new file mode 100644 index 0000000..34c6705 --- /dev/null +++ b/docs/Anthropic/Image/Source.html @@ -0,0 +1,746 @@ + + + + + + + + + + + + + + + + + Anthropic::Image::Source - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Image::Source + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(type : Type, media_type : MediaType, data : String) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def clone + + # +
+ +
+
+ +
+
+ +
+
+ + def copy_with(type _type = @type, media_type _media_type = @media_type, data _data = @data) + + # +
+ +
+
+ +
+
+ +
+
+ + def data : String + + # +
+ +
+
+ +
+
+ +
+
+ + def media_type : MediaType + + # +
+ +
+
+ +
+
+ +
+
+ + def type : Type + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Image/Source/MediaType.html b/docs/Anthropic/Image/Source/MediaType.html new file mode 100644 index 0000000..f9b92df --- /dev/null +++ b/docs/Anthropic/Image/Source/MediaType.html @@ -0,0 +1,696 @@ + + + + + + + + + + + + + + + + + Anthropic::Image::Source::MediaType - anthropic main-dev + + + + + + + + + + +
+

+ + enum Anthropic::Image::Source::MediaType + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + +

+ + + + Enum Members +

+ +
+ +
+ JPEG = 0 +
+ + +
+ PNG = 1 +
+ + +
+ GIF = 2 +
+ + +
+ WEBP = 3 +
+ + +
+ + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def gif? + + # +
+ +
+
+ +
+
+ +
+
+ + def jpeg? + + # +
+ +
+
+ +
+
+ +
+
+ + def png? + + # +
+ +
+
+ +
+
+ +
+
+ + def to_s + + # +
+ +
+ +
+ Description copied from struct Enum +
+ +

Returns a String representation of this enum member. +In the case of regular enums, this is just the name of the member. +In the case of flag enums, it's the names joined by vertical bars, or "None", +if the value is zero.

+

If an enum's value doesn't match a member's value, the raw value +is returned as a string.

+
Color::Red.to_s                     # => "Red"
+IOMode::None.to_s                   # => "None"
+(IOMode::Read | IOMode::Write).to_s # => "Read | Write"
+
+Color.new(10).to_s # => "10"
+
+ +
+
+ +
+
+ +
+
+ + def webp? + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Image/Source/Type.html b/docs/Anthropic/Image/Source/Type.html new file mode 100644 index 0000000..a16d424 --- /dev/null +++ b/docs/Anthropic/Image/Source/Type.html @@ -0,0 +1,584 @@ + + + + + + + + + + + + + + + + + Anthropic::Image::Source::Type - anthropic main-dev + + + + + + + + + + +
+

+ + enum Anthropic::Image::Source::Type + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + +

+ + + + Enum Members +

+ +
+ +
+ Base64 = 0 +
+ + +
+ + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def base64? + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Message.html b/docs/Anthropic/Message.html new file mode 100644 index 0000000..fbf2bcd --- /dev/null +++ b/docs/Anthropic/Message.html @@ -0,0 +1,689 @@ + + + + + + + + + + + + + + + + + Anthropic::Message - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Message + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + message.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(content : Array(Anthropic::MessageContent) | String, role : Anthropic::Message::Role = :user) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def content : String | Array(MessageContent) + + # +
+ +
+
+ +
+
+ +
+
+ + def role : Role + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Message/Role.html b/docs/Anthropic/Message/Role.html new file mode 100644 index 0000000..4d2609a --- /dev/null +++ b/docs/Anthropic/Message/Role.html @@ -0,0 +1,608 @@ + + + + + + + + + + + + + + + + + Anthropic::Message::Role - anthropic main-dev + + + + + + + + + + +
+

+ + enum Anthropic::Message::Role + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + message.cr + +
+ + + + + +

+ + + + Enum Members +

+ +
+ +
+ User = 0 +
+ + +
+ Assistant = 1 +
+ + +
+ + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def assistant? + + # +
+ +
+
+ +
+
+ +
+
+ + def user? + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/MessageContent.html b/docs/Anthropic/MessageContent.html new file mode 100644 index 0000000..b2d9c0d --- /dev/null +++ b/docs/Anthropic/MessageContent.html @@ -0,0 +1,669 @@ + + + + + + + + + + + + + + + + + Anthropic::MessageContent - anthropic main-dev + + + + + + + + + + +
+

+ + abstract struct Anthropic::MessageContent + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + +

+ + + + Direct Known Subclasses +

+ + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ abstract + def type : String + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/MessageDelta.html b/docs/Anthropic/MessageDelta.html new file mode 100644 index 0000000..2c50271 --- /dev/null +++ b/docs/Anthropic/MessageDelta.html @@ -0,0 +1,710 @@ + + + + + + + + + + + + + + + + + Anthropic::MessageDelta - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::MessageDelta + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def delta : Delta + + # +
+ +
+
+ +
+
+ +
+
+ + def usage : Usage + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/MessageDelta/Delta.html b/docs/Anthropic/MessageDelta/Delta.html new file mode 100644 index 0000000..90acaff --- /dev/null +++ b/docs/Anthropic/MessageDelta/Delta.html @@ -0,0 +1,670 @@ + + + + + + + + + + + + + + + + + Anthropic::MessageDelta::Delta - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::MessageDelta::Delta + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def stop_reason : GeneratedMessage::StopReason | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def stop_sequence : String | Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/MessageDelta/Usage.html b/docs/Anthropic/MessageDelta/Usage.html new file mode 100644 index 0000000..1c6a2a8 --- /dev/null +++ b/docs/Anthropic/MessageDelta/Usage.html @@ -0,0 +1,651 @@ + + + + + + + + + + + + + + + + + Anthropic::MessageDelta::Usage - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::MessageDelta::Usage + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def output_tokens : Int64 + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/MessageStart.html b/docs/Anthropic/MessageStart.html new file mode 100644 index 0000000..bb85e86 --- /dev/null +++ b/docs/Anthropic/MessageStart.html @@ -0,0 +1,691 @@ + + + + + + + + + + + + + + + + + Anthropic::MessageStart - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::MessageStart + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def message : GeneratedMessage + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/MessageStop.html b/docs/Anthropic/MessageStop.html new file mode 100644 index 0000000..2394331 --- /dev/null +++ b/docs/Anthropic/MessageStop.html @@ -0,0 +1,650 @@ + + + + + + + + + + + + + + + + + Anthropic::MessageStop - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::MessageStop + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/MessageStream.html b/docs/Anthropic/MessageStream.html new file mode 100644 index 0000000..8e6dad9 --- /dev/null +++ b/docs/Anthropic/MessageStream.html @@ -0,0 +1,650 @@ + + + + + + + + + + + + + + + + + Anthropic::MessageStream - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::MessageStream + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Messages.html b/docs/Anthropic/Messages.html new file mode 100644 index 0000000..f0019cd --- /dev/null +++ b/docs/Anthropic/Messages.html @@ -0,0 +1,613 @@ + + + + + + + + + + + + + + + + + Anthropic::Messages - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Messages + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + messages.cr + +
+ + + + + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + +

Instance methods inherited from struct Anthropic::API

+ + + + client : Client + client + + + + + + +

Constructor methods inherited from struct Anthropic::API

+ + + + new(client : Anthropic::Client) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def create(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, tools : Array | Nil = nil, run_tools : Bool = true) : GeneratedMessage + + # +
+ +
+
+ +
+
+ +
+
+ + def create(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, &block : Event -> T) forall T + + # +
+ +
+ +

Send your prompt to the API and yield Events as they are fed back in.

+

EXPERIMENTAL

+
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Messages/Body.html b/docs/Anthropic/Messages/Body.html new file mode 100644 index 0000000..3b192f3 --- /dev/null +++ b/docs/Anthropic/Messages/Body.html @@ -0,0 +1,610 @@ + + + + + + + + + + + + + + + + + Anthropic::Messages::Body - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Messages::Body + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + messages.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Messages/Query.html b/docs/Anthropic/Messages/Query.html new file mode 100644 index 0000000..2fe1acc --- /dev/null +++ b/docs/Anthropic/Messages/Query.html @@ -0,0 +1,610 @@ + + + + + + + + + + + + + + + + + Anthropic::Messages::Query - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Messages::Query + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + messages.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Messages/Request.html b/docs/Anthropic/Messages/Request.html new file mode 100644 index 0000000..ed08331 --- /dev/null +++ b/docs/Anthropic/Messages/Request.html @@ -0,0 +1,917 @@ + + + + + + + + + + + + + + + + + Anthropic::Messages::Request - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Messages::Request + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + messages.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : Nil | String = nil, metadata : Nil | Hash(String, String) = nil, stop_sequences : Nil | Array(String) = nil, stream : Bool | Nil = nil, temperature : Float64 | Nil = nil, tools : Nil | String = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, extra_headers : HTTP::Headers | Nil = nil, extra_query : Anthropic::Messages::Query | Nil = nil, extra_body : Anthropic::Messages::Body | Nil = nil) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def extra_body : Body | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def extra_headers : HTTP::Headers | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def extra_query : Query | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def max_tokens : Int32 + + # +
+ +
+
+ +
+
+ +
+
+ + def messages : Array(Message) + + # +
+ +
+
+ +
+
+ +
+
+ + def metadata : Hash(String, String) | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def model : String + + # +
+ +
+
+ +
+
+ +
+
+ + def stop_sequences : Array(String) | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def stream? : Bool | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def system : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def temperature : Float64 | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def tools : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def top_k : Int64 | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def top_p : Float64 | Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Model.html b/docs/Anthropic/Model.html new file mode 100644 index 0000000..163d8c6 --- /dev/null +++ b/docs/Anthropic/Model.html @@ -0,0 +1,632 @@ + + + + + + + + + + + + + + + + + Anthropic::Model - anthropic main-dev + + + + + + + + + + +
+

+ + enum Anthropic::Model + +

+ + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + model.cr + +
+ + + + + +

+ + + + Enum Members +

+ +
+ +
+ Haiku = 0 +
+ + +
+ Sonnet = 1 +
+ + +
+ Opus = 2 +
+ + +
+ + + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def haiku? + + # +
+ +
+
+ +
+
+ +
+
+ + def opus? + + # +
+ +
+
+ +
+
+ +
+
+ + def sonnet? + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Ping.html b/docs/Anthropic/Ping.html new file mode 100644 index 0000000..1cf4a56 --- /dev/null +++ b/docs/Anthropic/Ping.html @@ -0,0 +1,650 @@ + + + + + + + + + + + + + + + + + Anthropic::Ping - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Ping + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::Event

+ + + + initialize + initialize + + + + + + +

Constructor methods inherited from struct Anthropic::Event

+ + + + new + new + + + + + + + + + +

Macros inherited from struct Anthropic::Event

+ + + + define(type) + define + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Resource.html b/docs/Anthropic/Resource.html new file mode 100644 index 0000000..5246af2 --- /dev/null +++ b/docs/Anthropic/Resource.html @@ -0,0 +1,532 @@ + + + + + + + + + + + + + + + + + Anthropic::Resource - anthropic main-dev + + + + + + + + + + +
+

+ + module Anthropic::Resource + +

+ + + + + + + + + + + + + + + +

+ + + + Direct including types +

+ + + + + +

+ + + + Defined in: +

+ + + resource.cr + +
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Text.html b/docs/Anthropic/Text.html new file mode 100644 index 0000000..4278da3 --- /dev/null +++ b/docs/Anthropic/Text.html @@ -0,0 +1,731 @@ + + + + + + + + + + + + + + + + + Anthropic::Text - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Text + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + +

Constructor methods inherited from struct Anthropic::TextOrImageContent

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + +

Instance methods inherited from struct Anthropic::MessageContent

+ + + + type : String + type + + + + + + +

Constructor methods inherited from struct Anthropic::MessageContent

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(text : String) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def text : String + + # +
+ +
+
+ +
+
+ +
+
+ + def to_s(io) : Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def type : String + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/TextDelta.html b/docs/Anthropic/TextDelta.html new file mode 100644 index 0000000..7b17ab5 --- /dev/null +++ b/docs/Anthropic/TextDelta.html @@ -0,0 +1,651 @@ + + + + + + + + + + + + + + + + + Anthropic::TextDelta - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::TextDelta + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + event_source.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def text : String | Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/TextOrImageContent.html b/docs/Anthropic/TextOrImageContent.html new file mode 100644 index 0000000..78981fd --- /dev/null +++ b/docs/Anthropic/TextOrImageContent.html @@ -0,0 +1,627 @@ + + + + + + + + + + + + + + + + + Anthropic::TextOrImageContent - anthropic main-dev + + + + + + + + + + +
+

+ + abstract struct Anthropic::TextOrImageContent + +

+ + + + + + + + + + + + + + + +

+ + + + Direct Known Subclasses +

+ + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + + + +
+ + + +

Instance methods inherited from struct Anthropic::MessageContent

+ + + + type : String + type + + + + + + +

Constructor methods inherited from struct Anthropic::MessageContent

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + + +
+ + + diff --git a/docs/Anthropic/Tool.html b/docs/Anthropic/Tool.html new file mode 100644 index 0000000..3fb6d16 --- /dev/null +++ b/docs/Anthropic/Tool.html @@ -0,0 +1,727 @@ + + + + + + + + + + + + + + + + + Anthropic::Tool(T) - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::Tool(T) + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + tool.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(name : String, description : Nil | String, input_type : T) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def description : String | Nil + + # +
+ +
+
+ +
+
+ +
+
+ + def input_type : T + + # +
+ +
+
+ +
+
+ +
+
+ + def name : String + + # +
+ +
+
+ +
+
+ +
+
+ + def to_json(json : JSON::Builder) : Nil + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/Tool/Handler.html b/docs/Anthropic/Tool/Handler.html new file mode 100644 index 0000000..93b2567 --- /dev/null +++ b/docs/Anthropic/Tool/Handler.html @@ -0,0 +1,696 @@ + + + + + + + + + + + + + + + + + Anthropic::Tool::Handler - anthropic main-dev + + + + + + + + + + +
+

+ + abstract struct Anthropic::Tool::Handler + +

+ + + + + + + + + + + +

+ + + + Included Modules +

+ + + + +

+ + + + Extended Modules +

+ + + + + + + + + +

+ + + + Defined in: +

+ + + tool.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + +

+ + + + Class Method Summary +

+ + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ + + + +

+ + + + Class Method Detail +

+ +
+
+ + def self.description + + # +
+ +
+
+ +
+
+ +
+
+ + def self.parse(json : String) + + # +
+ +
+
+ +
+
+ + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ abstract + def call + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/ToolResult.html b/docs/Anthropic/ToolResult.html new file mode 100644 index 0000000..308a8b1 --- /dev/null +++ b/docs/Anthropic/ToolResult.html @@ -0,0 +1,747 @@ + + + + + + + + + + + + + + + + + Anthropic::ToolResult - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::ToolResult + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + +

Instance methods inherited from struct Anthropic::MessageContent

+ + + + type : String + type + + + + + + +

Constructor methods inherited from struct Anthropic::MessageContent

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(*, tool_use_id : String, error : Bool = false, content : Array(Text) | Array(Image)) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(*, tool_use_id : String, error : Bool = false, content : Array(Anthropic::TextOrImageContent)) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def content : Array(Text | Image) + + # +
+ +
+
+ +
+
+ +
+
+ + def error? : Bool + + # +
+ +
+
+ +
+
+ +
+
+ + def tool_use_id : String + + # +
+ +
+
+ +
+
+ +
+
+ + def type : String + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/Anthropic/ToolUse.html b/docs/Anthropic/ToolUse.html new file mode 100644 index 0000000..a1647d3 --- /dev/null +++ b/docs/Anthropic/ToolUse.html @@ -0,0 +1,728 @@ + + + + + + + + + + + + + + + + + Anthropic::ToolUse - anthropic main-dev + + + + + + + + + + +
+

+ + struct Anthropic::ToolUse + +

+ + + + + + + + + + + + + + + + + + + + +

+ + + + Defined in: +

+ + + message_content.cr + +
+ + + + + + +

+ + + + Constructors +

+ + + + + + + + +

+ + + + Instance Method Summary +

+ + + + +
+ + + +

Instance methods inherited from struct Anthropic::MessageContent

+ + + + type : String + type + + + + + + +

Constructor methods inherited from struct Anthropic::MessageContent

+ + + + new(pull : JSON::PullParser) + new + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(pull : JSON::PullParser) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(*, id : String, name : String, input : Hash(String, Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil)) + + # +
+ +
+
+ +
+
+ + + + + + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def id : String + + # +
+ +
+
+ +
+
+ +
+
+ + def input : Hash(String, JSON::Any::Type) + + # +
+ +
+
+ +
+
+ +
+
+ + def name : String + + # +
+ +
+
+ +
+
+ +
+
+ + def type : String + + # +
+ +
+
+ +
+
+ + + +
+ + + diff --git a/docs/css/style.css b/docs/css/style.css new file mode 100644 index 0000000..3d0a8a5 --- /dev/null +++ b/docs/css/style.css @@ -0,0 +1,980 @@ +:root { + color-scheme: light dark; +} + +html, body { + background: #FFFFFF; + position: relative; + margin: 0; + padding: 0; + width: 100%; + height: 100%; + overflow: hidden; +} + +body { + font-family: "Avenir", "Tahoma", "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + color: #333; + line-height: 1.5; +} + +a { + color: #263F6C; +} + +a:visited { + color: #112750; +} + +h1, h2, h3, h4, h5, h6 { + margin: 35px 0 25px; + color: #444444; +} + +h1.type-name { + color: #47266E; + margin: 20px 0 30px; + background-color: #F8F8F8; + padding: 10px 12px; + border: 1px solid #EBEBEB; + border-radius: 2px; +} + +h2 { + border-bottom: 1px solid #E6E6E6; + padding-bottom: 5px; +} + +body { + display: flex; +} + +.sidebar, .main-content { + overflow: auto; +} + +.sidebar { + width: 30em; + color: #F8F4FD; + background-color: #2E1052; + padding: 0 0 30px; + box-shadow: inset -3px 0 4px rgba(0,0,0,.35); + line-height: 1.2; + z-index: 0; +} + +.sidebar .search-box { + padding: 13px 9px; +} + +.sidebar input { + display: block; + box-sizing: border-box; + margin: 0; + padding: 5px; + font: inherit; + font-family: inherit; + line-height: 1.2; + width: 100%; + border: 0; + outline: 0; + border-radius: 2px; + box-shadow: 0px 3px 5px rgba(0,0,0,.25); + transition: box-shadow .12s; +} + +.sidebar input:focus { + box-shadow: 0px 5px 6px rgba(0,0,0,.5); +} + +.sidebar input::-webkit-input-placeholder { /* Chrome/Opera/Safari */ + color: #757575; + font-size: 14px; + text-indent: 2px; +} + +.sidebar input::-moz-placeholder { /* Firefox 19+ */ + color: #757575; + font-size: 14px; + text-indent: 2px; +} + +.sidebar input:-ms-input-placeholder { /* IE 10+ */ + color: #757575; + font-size: 14px; + text-indent: 2px; +} + +.sidebar input:-moz-placeholder { /* Firefox 18- */ + color: #757575; + font-size: 14px; + text-indent: 2px; +} + +.project-summary { + padding: 9px 15px 30px 30px; +} + +.project-name { + font-size: 1.4rem; + margin: 0; + color: #f4f4f4; + font-weight: 600; +} + +.project-version { + margin-top: 5px; + display: inline-block; + position: relative; +} + +.project-version > form::after { + position: absolute; + right: 0; + top: 0; + content: "\25BC"; + font-size: .6em; + line-height: 1.2rem; + z-index: -1; +} + +.project-versions-nav { + cursor: pointer; + margin: 0; + padding: 0 .9em 0 0; + border: none; + -moz-appearance: none; + -webkit-appearance: none; + appearance: none; + background-color: transparent; + color: inherit; + font-family: inherit; + font-size: inherit; + line-height: inherit; +} +.project-versions-nav:focus { + outline: none; +} + +.project-versions-nav > option { + color: initial; +} + +.sidebar ul { + margin: 0; + padding: 0; + list-style: none outside; +} + +.sidebar li { + display: block; + position: relative; +} + +.types-list li.hide { + display: none; +} + +.sidebar a { + text-decoration: none; + color: inherit; + transition: color .14s; +} +.types-list a { + display: block; + padding: 5px 15px 5px 30px; +} + +.types-list { + display: block; +} + +.sidebar a:focus { + outline: 1px solid #D1B7F1; +} + +.types-list a { + padding: 5px 15px 5px 30px; +} + +.sidebar .current > a, +.sidebar a:hover { + color: #866BA6; +} + +.types-list li ul { + overflow: hidden; + height: 0; + max-height: 0; + transition: 1s ease-in-out; +} + +.types-list li.parent { + padding-left: 30px; +} + +.types-list li.parent::before { + box-sizing: border-box; + content: "â–¼"; + display: block; + width: 30px; + height: 30px; + position: absolute; + top: 0; + left: 0; + text-align: center; + color: white; + font-size: 8px; + line-height: 30px; + transform: rotateZ(-90deg); + cursor: pointer; + transition: .2s linear; +} + + +.types-list li.parent > a { + padding-left: 0; +} + +.types-list li.parent.open::before { + transform: rotateZ(0); +} + +.types-list li.open > ul { + height: auto; + max-height: 1000em; +} + +.main-content { + padding: 0 30px 30px 30px; + width: 100%; +} + +.kind { + font-size: 60%; + color: #866BA6; +} + +.superclass-hierarchy { + margin: -15px 0 30px 0; + padding: 0; + list-style: none outside; + font-size: 80%; +} + +.superclass-hierarchy .superclass { + display: inline-block; + margin: 0 7px 0 0; + padding: 0; +} + +.superclass-hierarchy .superclass + .superclass::before { + content: "<"; + margin-right: 7px; +} + +.other-types-list li { + display: inline-block; +} + +.other-types-list, +.list-summary { + margin: 0 0 30px 0; + padding: 0; + list-style: none outside; +} + +.entry-const { + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; +} + +.entry-const code { + white-space: pre-wrap; +} + +.entry-summary { + padding-bottom: 4px; +} + +.superclass-hierarchy .superclass a, +.other-type a, +.entry-summary .signature { + padding: 4px 8px; + margin-bottom: 4px; + display: inline-block; + background-color: #f8f8f8; + color: #47266E; + border: 1px solid #f0f0f0; + text-decoration: none; + border-radius: 3px; + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; + transition: background .15s, border-color .15s; +} + +.superclass-hierarchy .superclass a:hover, +.other-type a:hover, +.entry-summary .signature:hover { + background: #D5CAE3; + border-color: #624288; +} + +.entry-summary .summary { + padding-left: 32px; +} + +.entry-summary .summary p { + margin: 12px 0 16px; +} + +.entry-summary a { + text-decoration: none; +} + +.entry-detail { + padding: 30px 0; +} + +.entry-detail .signature { + position: relative; + padding: 5px 15px; + margin-bottom: 10px; + display: block; + border-radius: 5px; + background-color: #f8f8f8; + color: #47266E; + border: 1px solid #f0f0f0; + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; + transition: .2s ease-in-out; +} + +.entry-detail:target .signature { + background-color: #D5CAE3; + border: 1px solid #624288; +} + +.entry-detail .signature .method-permalink { + position: absolute; + top: 0; + left: -35px; + padding: 5px 15px; + text-decoration: none; + font-weight: bold; + color: #624288; + opacity: .4; + transition: opacity .2s; +} + +.entry-detail .signature .method-permalink:hover { + opacity: 1; +} + +.entry-detail:target .signature .method-permalink { + opacity: 1; +} + +.methods-inherited { + padding-right: 10%; + line-height: 1.5em; +} + +.methods-inherited h3 { + margin-bottom: 4px; +} + +.methods-inherited a { + display: inline-block; + text-decoration: none; + color: #47266E; +} + +.methods-inherited a:hover { + text-decoration: underline; + color: #6C518B; +} + +.methods-inherited .tooltip>span { + background: #D5CAE3; + padding: 4px 8px; + border-radius: 3px; + margin: -4px -8px; +} + +.methods-inherited .tooltip * { + color: #47266E; +} + +pre { + padding: 10px 20px; + margin-top: 4px; + border-radius: 3px; + line-height: 1.45; + overflow: auto; + color: #333; + background: #fdfdfd; + font-size: 14px; + border: 1px solid #eee; +} + +code { + font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace; +} + +:not(pre) > code { + background-color: rgba(40,35,30,0.05); + padding: 0.2em 0.4em; + font-size: 85%; + border-radius: 3px; +} + +span.flag { + padding: 2px 4px 1px; + border-radius: 3px; + margin-right: 3px; + font-size: 11px; + border: 1px solid transparent; +} + +span.flag.orange { + background-color: #EE8737; + color: #FCEBDD; + border-color: #EB7317; +} + +span.flag.yellow { + background-color: #E4B91C; + color: #FCF8E8; + border-color: #B69115; +} + +span.flag.green { + background-color: #469C14; + color: #E2F9D3; + border-color: #34700E; +} + +span.flag.red { + background-color: #BF1919; + color: #F9ECEC; + border-color: #822C2C; +} + +span.flag.purple { + background-color: #2E1052; + color: #ECE1F9; + border-color: #1F0B37; +} + +span.flag.lime { + background-color: #a3ff00; + color: #222222; + border-color: #00ff1e; +} + +.tooltip>span { + position: absolute; + opacity: 0; + display: none; + pointer-events: none; +} + +.tooltip:hover>span { + display: inline-block; + opacity: 1; +} + +.c { + color: #969896; +} + +.n { + color: #0086b3; +} + +.t { + color: #0086b3; +} + +.s { + color: #183691; +} + +.i { + color: #7f5030; +} + +.k { + color: #a71d5d; +} + +.o { + color: #a71d5d; +} + +.m { + color: #795da3; +} + +.hidden { + display: none; +} +.search-results { + font-size: 90%; + line-height: 1.3; +} + +.search-results mark { + color: inherit; + background: transparent; + font-weight: bold; +} +.search-result { + padding: 5px 8px 5px 5px; + cursor: pointer; + border-left: 5px solid transparent; + transform: translateX(-3px); + transition: all .2s, background-color 0s, border .02s; + min-height: 3.2em; +} +.search-result.current { + border-left-color: #ddd; + background-color: rgba(200,200,200,0.4); + transform: translateX(0); + transition: all .2s, background-color .5s, border 0s; +} +.search-result.current:hover, +.search-result.current:focus { + border-left-color: #866BA6; +} +.search-result:not(.current):nth-child(2n) { + background-color: rgba(255,255,255,.06); +} +.search-result__title { + font-size: 105%; + word-break: break-all; + line-height: 1.1; + padding: 3px 0; +} +.search-result__title strong { + font-weight: normal; +} +.search-results .search-result__title > a { + padding: 0; + display: block; +} +.search-result__title > a > .args { + color: #dddddd; + font-weight: 300; + transition: inherit; + font-size: 88%; + line-height: 1.2; + letter-spacing: -.02em; +} +.search-result__title > a > .args * { + color: inherit; +} + +.search-result a, +.search-result a:hover { + color: inherit; +} +.search-result:not(.current):hover .search-result__title > a, +.search-result:not(.current):focus .search-result__title > a, +.search-result__title > a:focus { + color: #866BA6; +} +.search-result:not(.current):hover .args, +.search-result:not(.current):focus .args { + color: #6a5a7d; +} + +.search-result__type { + color: #e8e8e8; + font-weight: 300; +} +.search-result__doc { + color: #bbbbbb; + font-size: 90%; +} +.search-result__doc p { + margin: 0; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; + line-height: 1.2em; + max-height: 2.4em; +} + +.js-modal-visible .modal-background { + display: flex; +} +.main-content { + position: relative; +} +.modal-background { + position: absolute; + display: none; + height: 100%; + width: 100%; + background: rgba(120,120,120,.4); + z-index: 100; + align-items: center; + justify-content: center; +} +.usage-modal { + max-width: 90%; + background: #fff; + border: 2px solid #ccc; + border-radius: 9px; + padding: 5px 15px 20px; + min-width: 50%; + color: #555; + position: relative; + transform: scale(.5); + transition: transform 200ms; +} +.js-modal-visible .usage-modal { + transform: scale(1); +} +.usage-modal > .close-button { + position: absolute; + right: 15px; + top: 8px; + color: #aaa; + font-size: 27px; + cursor: pointer; +} +.usage-modal > .close-button:hover { + text-shadow: 2px 2px 2px #ccc; + color: #999; +} +.modal-title { + margin: 0; + text-align: center; + font-weight: normal; + color: #666; + border-bottom: 2px solid #ddd; + padding: 10px; +} +.usage-list { + padding: 0; + margin: 13px; +} +.usage-list > li { + padding: 5px 2px; + overflow: auto; + padding-left: 100px; + min-width: 12em; +} +.usage-modal kbd { + background: #eee; + border: 1px solid #ccc; + border-bottom-width: 2px; + border-radius: 3px; + padding: 3px 8px; + font-family: monospace; + margin-right: 2px; + display: inline-block; +} +.usage-key { + float: left; + clear: left; + margin-left: -100px; + margin-right: 12px; +} +.doc-inherited { + font-weight: bold; +} + +.anchor { + float: left; + padding-right: 4px; + margin-left: -20px; +} + +.main-content .anchor .octicon-link { + width: 16px; + height: 16px; +} + +.main-content .anchor:focus { + outline: none +} + +.main-content h1:hover .anchor, +.main-content h2:hover .anchor, +.main-content h3:hover .anchor, +.main-content h4:hover .anchor, +.main-content h5:hover .anchor, +.main-content h6:hover .anchor { + text-decoration: none +} + +.main-content h1 .octicon-link, +.main-content h2 .octicon-link, +.main-content h3 .octicon-link, +.main-content h4 .octicon-link, +.main-content h5 .octicon-link, +.main-content h6 .octicon-link { + visibility: hidden +} + +.main-content h1:hover .anchor .octicon-link, +.main-content h2:hover .anchor .octicon-link, +.main-content h3:hover .anchor .octicon-link, +.main-content h4:hover .anchor .octicon-link, +.main-content h5:hover .anchor .octicon-link, +.main-content h6:hover .anchor .octicon-link { + visibility: visible +} + +img { + max-width: 100%; +} + +table { + font-size: 14px; + display: block; + max-width: -moz-fit-content; + max-width: fit-content; + overflow-x: auto; + white-space: nowrap; + background: #fdfdfd; + text-align: center; + border: 1px solid #eee; + border-collapse: collapse; + padding: 0px 5px 0px 5px; +} + +table th { + padding: 10px; + letter-spacing: 1px; + border-bottom: 1px solid #eee; +} + +table td { + padding: 10px; +} + +#sidebar-btn { + height: 32px; + width: 32px; +} + +#sidebar-btn-label { + height: 2em; + width: 2em; +} + +#sidebar-btn, #sidebar-btn-label { + display: none; + margin: .7rem; + appearance: none; + color: black; + cursor: pointer; +} + +@media only screen and (max-width: 635px) { + .sidebar, .main-content { + /* svg size + vertical margin - .search-box padding-top */ + padding-top: calc(2em + 2 * 0.7rem - 13px); + } + + #sidebar-btn, #sidebar-btn-label { + display: block; + position: absolute; + z-index: 50; + transition-duration: 200ms; + left: 0; + } + + #sidebar-btn:not(:checked) ~ #sidebar-btn-label > .close, + #sidebar-btn:checked ~ #sidebar-btn-label > .open, + #sidebar-btn:checked ~ .main-content { + display: none; + } + + #sidebar-btn:checked { + left: calc(100% - 32px - (2 * 0.7rem)); + } + + #sidebar-btn:checked ~ #sidebar-btn-label { + color: white; + /* 100% - svg size - horizontal margin */ + left: calc(100% - 2em - (2 * 0.7rem)); + } + + #sidebar-btn~.sidebar { + width: 0%; + } + + #sidebar-btn:checked~.sidebar { + visibility: visible; + width: 100%; + } + + .sidebar { + transition-duration: 200ms; + max-width: 100vw; + visibility: hidden; + } +} + +@media (prefers-color-scheme: dark) { + html, body { + background: #1b1b1b; + } + + body { + color: white; + } + + a { + color: #8cb4ff; + } + + .main-content a:visited { + color: #5f8de3; + } + + h1, h2, h3, h4, h5, h6 { + color: white; + } + + h1.type-name { + color: white; + background-color: #202020; + border: 1px solid #353535; + } + + .project-versions-nav > option { + background-color: #222; + } + + .superclass-hierarchy .superclass a, + .superclass-hierarchy .superclass a:visited, + .other-type a, + .other-type a:visited, + .entry-summary .signature, + .entry-summary a:visited { + background-color: #202020; + color: white; + border: 1px solid #353535; + } + + .superclass-hierarchy .superclass a:hover, + .other-type a:hover, + .entry-summary .signature:hover { + background: #443d4d; + border-color: #b092d4; + } + + .kind { + color: #b092d4; + } + + .n { + color: #00ade6; + } + + .t { + color: #00ade6; + } + + .k { + color: #ff66ae; + } + + .o { + color: #ff66ae; + } + + .s { + color: #7799ff; + } + + .i { + color: #b38668; + } + + .m { + color: #b9a5d6; + } + + .c { + color: #a1a1a1; + } + + .methods-inherited a, .methods-inherited a:visited { + color: #B290D9; + } + + .methods-inherited a:hover { + color: #D4B7F4; + } + + .methods-inherited .tooltip>span { + background: #443d4d; + } + + .methods-inherited .tooltip * { + color: white; + } + + .entry-detail:target .signature { + background-color: #443d4d; + border: 1px solid #b092d4; + } + + .entry-detail .signature { + background-color: #202020; + color: white; + border: 1px solid #353535; + } + + .entry-detail .signature .method-permalink { + color: #b092d4; + } + + :not(pre)>code { + background-color: #202020; + } + + span.flag.purple { + background-color: #443d4d; + color: #ECE1F9; + border-color: #b092d4; + } + + .sidebar input::-webkit-input-placeholder { /* Chrome/Opera/Safari */ + color: white; + } + + .sidebar input::-moz-placeholder { /* Firefox 19+ */ + color: white; + } + + .sidebar input:-ms-input-placeholder { /* IE 10+ */ + color: white; + } + + .sidebar input:-moz-placeholder { /* Firefox 18- */ + color: white; + } + + pre, + table { + color: white; + background: #202020; + border: 1px solid #353535; + } + + table th { + border-bottom: 1px solid #353535; + } + + #sidebar-btn, #sidebar-btn-label { + color: white; + } +} diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..ac21793 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,687 @@ + + + + + + + + + + + + + + + + + anthropic main-dev + + + + + + + + + + +
+

+anthropic

+

Client for the Anthropic API. Supports tool use and running those tools automatically.

+

+ +Installation

+
    +
  1. +

    Add the dependency to your shard.yml:

    +
    dependencies:
    +  anthropic:
    +    github: jgaskins/anthropic
    +
  2. +
  3. +

    Run shards install

    +
  4. +
+

+ +Usage

+
require "anthropic"
+

The main entrypoint is via the Anthropic::Client. You can instantiate it explicitly with an API key:

+
claude = Anthropic::Client.new("sk-and-api-03-asdfasdfasdf")
+

Or you can omit the API key to automatically read it from the ANTHROPIC_API_KEY environment variable:

+
claude = Anthropic::Client.new
+

Next, use the Anthropic::Messages#create method to send your prompt:

+
response = claude.messages.create(
+  # Pass a string representing the model name, or retrieve the full model
+  # name via the shorthand with Anthropic.model_name.
+  model: Anthropic.model_name(:sonnet),
+
+  # Define a system prompt if you want to give the AI a persona to use or some
+  # instructions on how to respond to the prompt.
+  system: "You are an expert in the Crystal programming language",
+
+  # You can pass the full list of messages, including messages it gave you
+  # back.
+  messages: [
+    Anthropic::Message.new("What makes Crystal the best programming language?")
+  ],
+
+  # The maximum number of tokens the AI will try to respond with. Keep this low
+  # if you're feeding untrusted prompts.
+  max_tokens: 4096,
+
+  # A floating-point value between 0.0 and 1.0 representing how creative the
+  # response should be. Lower values (closer to 0.0) will be more deterministic
+  # and should be used for analytical prompts. Higher values (closer to 1.0)
+  # will be more stochastic.
+  temperature: 0.5,
+
+  # You can optionally pass an `Array` of tools to give the client a way to run
+  # custom code in your app. See below for additional information on how to
+  # define those. The more tools you pass in with a request, the more tokens the
+  # request will use, so you should keep this to a reasonable size.
+  #
+  # By default, no tools are included.
+  tools: [
+    GitHubUserLookup,
+    GoogleDriveSearch.new(google_oauth_token),
+  ],
+
+  # Uncomment the following line to avoid automatically running the tool
+  # selected by the model.
+  # run_tools: false,
+
+  # Limit the token selection to the "top k" tokens. If you need this
+  # explanation, chances are you should use `temperature` instead. That's not a
+  # dig — I've never used it myself.
+  # top_k: 10,
+
+  # P value for nucleus sampling. If you're dialing in your prompts with the
+  # `temperature` argument, you should ignore this one. I've never used this
+  # one, either.
+  # top_p: 0.1234,
+)
+

You can also pass images to the model:

+
puts claude
+  .messages
+  .create(
+    # You should generally use the Haiku model when dealing with images since
+    # they tend to consume quite a few tokens.
+    model: Anthropic.model_name(:haiku),
+    messages: [
+      Anthropic::Message.new(
+        content: Array(Anthropic::MessageContent){
+          # Images are base64-encoded and sent to the model
+          Anthropic::Image.base64(:jpeg, File.read("/path/to/image.jpeg")),
+          Anthropic::Text.new("Describe this image"),
+        },
+      ),
+    ],
+    max_tokens: 4096,
+    # Using a more deterministic response about the image
+    temperature: 0.1,
+  )
+

+ +Defining tools

+

Tools are objects that the Anthropic models can use to invoke your code. You +can define them easily with a struct that inherits from +Anthropic::Tool::Handler.

+
struct GitHubUserLookup < Anthropic::Tool::Handler
+  # Define any properties required for this tool as getters. Claude will
+  # provide them if it can based on the user's question.
+
+  # The username/login for the GitHub user, used to fetch the user from the
+  # GitHub API.
+  getter username : String
+
+  # This is the description that lets the model know when and how to use your
+  # code. It's basically the documentation the model will use. The more
+  # descriptive this is, the more confidence the model will have in invoking
+  # it, but it does consume tokens.
+  def self.description
+    <<-EOF
+      Retrieves the GitHub user with the given username. The username may also
+      be referred to as a "login". The username can only contain letters,
+      numbers, underscores, and dashes.
+
+      The tool will return the current data about the GitHub user with that
+      username. It should be used when the user asks about that particular
+      GitHub user. It will not provide information about GitHub repositories
+      or any issues, pull requests, commits, or other content on GitHub created
+      by that GitHub user.
+      EOF
+  end
+
+  # This is the method the client will use to invoke this tool. The return value
+  # of this method will be serialized as JSON and sent over the wire as the
+  # tool-use result
+  def call
+    User.from_json HTTP::Client.get(URI.parse("https://api.github.com/users/#{username}")).body
+  end
+
+  # The definition for the value we want to send back to the model. Every
+  # property specified here will consume tokens, so only define getters that
+  # will provide useful context to the model.
+  struct User
+    include JSON::Serializable
+
+    getter login : String
+    getter name : String
+    getter company : String?
+    getter location : String
+    getter bio : String?
+    getter public_repos : Int64
+    getter public_gists : Int64
+    getter followers : Int64
+    getter following : Int64
+  end
+end
+

You can also define tools without inheriting from Anthropic::Tool::Handler. That type simply implements the following API on the tool object (instance or type) being passed in:

+ +

Here is an example of a tool that searches a user's Google Drive (via the jgaskins/google shard) using the provided query. Claude will generate the query and pass it to the tool,

+
require "google"
+require "google/drive"
+
+record GoogleDriveSearch, token : String do
+  GOOGLE = Google::Client.new(
+    client_id: ENV["GOOGLE_CLIENT_ID"],
+    client_secret: ENV["GOOGLE_CLIENT_SECRET"],
+    redirect_uri: URI.parse("https://example.com/oauth2/google"),
+  )
+
+  def description
+    "Search Google for a user's documents with the given search query. You must use the Google Drive API query string format."
+  end
+
+  def name
+    "GoogleDriveSearch"
+  end
+
+  def json_schema
+    # The `json_schema` class method is provided on all `JSON::Serializable`
+    # types by the `spider-gazelle/json-schema` shard.
+    Query.json_schema
+  end
+
+  def parse(json : String)
+    query = Query.from_json json
+    query.search = self
+    query
+  end
+
+  def call(query : String)
+    files = GOOGLE
+      .drive
+      .files
+      .list(
+        token: token,
+        q: "(#{query}) and mimeType contains 'application/vnd.google-apps'",
+        limit: 10,
+      )
+      .to_a
+
+    array = Array(FileInfo).new(files.size)
+    # Requires this PR to be released, or the equivalent monkeypatch:
+    #   https://github.com/crystal-lang/crystal/pull/14837
+    WaitGroup.wait do |wg|
+      mutex = Mutex.new
+      files.each do |file|
+        wg.spawn do
+          file_info = FileInfo.new(
+            id: file.id,
+            name: file.name,
+            content: GOOGLE.drive.files.export(file, "text/plain", token, &.gets_to_end),
+            link: file.web_view_link,
+          )
+
+          mutex.synchronize do
+            array << file_info
+          end
+        end
+      end
+    end
+
+    array
+  end
+
+  struct FileInfo
+    include JSON::Serializable
+
+    getter id : String
+    getter name : String
+    getter content : String
+    getter link : String
+
+    def initialize(@id, @name, @content, @link)
+    end
+  end
+
+  struct Query
+    include JSON::Serializable
+
+    getter query : String
+    @[JSON::Field(ignore: true)]
+    protected property! search : GoogleDriveSearch
+
+    def call
+      search.call(query)
+    end
+  end
+end
+

See the example code above to find out how to pass them to the model.

+

+ +Contributing

+
    +
  1. Fork it (https://github.com/jgaskins/anthropic/fork)
  2. +
  3. Create your feature branch (git checkout -b my-new-feature)
  4. +
  5. Commit your changes (git commit -am 'Add some feature')
  6. +
  7. Push to the branch (git push origin my-new-feature)
  8. +
  9. Create a new Pull Request
  10. +
+

+ +Contributors

+ +
+ + diff --git a/docs/index.json b/docs/index.json new file mode 100644 index 0000000..c3c204b --- /dev/null +++ b/docs/index.json @@ -0,0 +1 @@ +{"repository_name":"anthropic","body":"# anthropic\n\nClient for the Anthropic API. Supports tool use and running those tools automatically.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n anthropic:\n github: jgaskins/anthropic\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"anthropic\"\n```\n\nThe main entrypoint is via the `Anthropic::Client`. You can instantiate it explicitly with an API key:\n\n```crystal\nclaude = Anthropic::Client.new(\"sk-and-api-03-asdfasdfasdf\")\n```\n\nOr you can omit the API key to automatically read it from the `ANTHROPIC_API_KEY` environment variable:\n\n```crystal\nclaude = Anthropic::Client.new\n```\n\nNext, use the `Anthropic::Messages#create` method to send your prompt:\n\n```crystal\nresponse = claude.messages.create(\n # Pass a string representing the model name, or retrieve the full model\n # name via the shorthand with Anthropic.model_name.\n model: Anthropic.model_name(:sonnet),\n\n # Define a system prompt if you want to give the AI a persona to use or some\n # instructions on how to respond to the prompt.\n system: \"You are an expert in the Crystal programming language\",\n\n # You can pass the full list of messages, including messages it gave you\n # back.\n messages: [\n Anthropic::Message.new(\"What makes Crystal the best programming language?\")\n ],\n\n # The maximum number of tokens the AI will try to respond with. Keep this low\n # if you're feeding untrusted prompts.\n max_tokens: 4096,\n\n # A floating-point value between 0.0 and 1.0 representing how creative the\n # response should be. Lower values (closer to 0.0) will be more deterministic\n # and should be used for analytical prompts. Higher values (closer to 1.0)\n # will be more stochastic.\n temperature: 0.5,\n\n # You can optionally pass an `Array` of tools to give the client a way to run\n # custom code in your app. See below for additional information on how to\n # define those. The more tools you pass in with a request, the more tokens the\n # request will use, so you should keep this to a reasonable size.\n #\n # By default, no tools are included.\n tools: [\n GitHubUserLookup,\n GoogleDriveSearch.new(google_oauth_token),\n ],\n\n # Uncomment the following line to avoid automatically running the tool\n # selected by the model.\n # run_tools: false,\n\n # Limit the token selection to the \"top k\" tokens. If you need this\n # explanation, chances are you should use `temperature` instead. That's not a\n # dig — I've never used it myself.\n # top_k: 10,\n\n # P value for nucleus sampling. If you're dialing in your prompts with the\n # `temperature` argument, you should ignore this one. I've never used this\n # one, either.\n # top_p: 0.1234,\n)\n```\n\nYou can also pass images to the model:\n\n```crystal\nputs claude\n .messages\n .create(\n # You should generally use the Haiku model when dealing with images since\n # they tend to consume quite a few tokens.\n model: Anthropic.model_name(:haiku),\n messages: [\n Anthropic::Message.new(\n content: Array(Anthropic::MessageContent){\n # Images are base64-encoded and sent to the model\n Anthropic::Image.base64(:jpeg, File.read(\"/path/to/image.jpeg\")),\n Anthropic::Text.new(\"Describe this image\"),\n },\n ),\n ],\n max_tokens: 4096,\n # Using a more deterministic response about the image\n temperature: 0.1,\n )\n```\n\n### Defining tools\n\nTools are objects that the Anthropic models can use to invoke your code. You\ncan define them easily with a `struct` that inherits from\n`Anthropic::Tool::Handler`.\n\n```crystal\nstruct GitHubUserLookup < Anthropic::Tool::Handler\n # Define any properties required for this tool as getters. Claude will\n # provide them if it can based on the user's question.\n\n # The username/login for the GitHub user, used to fetch the user from the\n # GitHub API.\n getter username : String\n\n # This is the description that lets the model know when and how to use your\n # code. It's basically the documentation the model will use. The more\n # descriptive this is, the more confidence the model will have in invoking\n # it, but it does consume tokens.\n def self.description\n <<-EOF\n Retrieves the GitHub user with the given username. The username may also\n be referred to as a \"login\". The username can only contain letters,\n numbers, underscores, and dashes.\n\n The tool will return the current data about the GitHub user with that\n username. It should be used when the user asks about that particular\n GitHub user. It will not provide information about GitHub repositories\n or any issues, pull requests, commits, or other content on GitHub created\n by that GitHub user.\n EOF\n end\n\n # This is the method the client will use to invoke this tool. The return value\n # of this method will be serialized as JSON and sent over the wire as the\n # tool-use result\n def call\n User.from_json HTTP::Client.get(URI.parse(\"https://api.github.com/users/#{username}\")).body\n end\n\n # The definition for the value we want to send back to the model. Every\n # property specified here will consume tokens, so only define getters that\n # will provide useful context to the model.\n struct User\n include JSON::Serializable\n\n getter login : String\n getter name : String\n getter company : String?\n getter location : String\n getter bio : String?\n getter public_repos : Int64\n getter public_gists : Int64\n getter followers : Int64\n getter following : Int64\n end\nend\n```\n\nYou can also define tools without inheriting from `Anthropic::Tool::Handler`. That type simply implements the following API on the tool object (instance or type) being passed in:\n\n- `name : String`\n- `description : String`\n- `json_schema`, which returns a `to_json`-able object\n- `parse`, which returns a `call`-able object which returns a `to_json`-able object\n\nHere is an example of a tool that searches a user's Google Drive (via the [`jgaskins/google`](https://github.com/jgaskins/google) shard) using the provided query. Claude will generate the query and pass it to the tool, \n\n```crystal\nrequire \"google\"\nrequire \"google/drive\"\n\nrecord GoogleDriveSearch, token : String do\n GOOGLE = Google::Client.new(\n client_id: ENV[\"GOOGLE_CLIENT_ID\"],\n client_secret: ENV[\"GOOGLE_CLIENT_SECRET\"],\n redirect_uri: URI.parse(\"https://example.com/oauth2/google\"),\n )\n\n def description\n \"Search Google for a user's documents with the given search query. You must use the Google Drive API query string format.\"\n end\n\n def name\n \"GoogleDriveSearch\"\n end\n\n def json_schema\n # The `json_schema` class method is provided on all `JSON::Serializable`\n # types by the `spider-gazelle/json-schema` shard.\n Query.json_schema\n end\n\n def parse(json : String)\n query = Query.from_json json\n query.search = self\n query\n end\n\n def call(query : String)\n files = GOOGLE\n .drive\n .files\n .list(\n token: token,\n q: \"(#{query}) and mimeType contains 'application/vnd.google-apps'\",\n limit: 10,\n )\n .to_a\n\n array = Array(FileInfo).new(files.size)\n # Requires this PR to be released, or the equivalent monkeypatch:\n # https://github.com/crystal-lang/crystal/pull/14837\n WaitGroup.wait do |wg|\n mutex = Mutex.new\n files.each do |file|\n wg.spawn do\n file_info = FileInfo.new(\n id: file.id,\n name: file.name,\n content: GOOGLE.drive.files.export(file, \"text/plain\", token, &.gets_to_end),\n link: file.web_view_link,\n )\n\n mutex.synchronize do\n array << file_info\n end\n end\n end\n end\n\n array\n end\n\n struct FileInfo\n include JSON::Serializable\n\n getter id : String\n getter name : String\n getter content : String\n getter link : String\n\n def initialize(@id, @name, @content, @link)\n end\n end\n\n struct Query\n include JSON::Serializable\n\n getter query : String\n @[JSON::Field(ignore: true)]\n protected property! search : GoogleDriveSearch\n\n def call\n search.call(query)\n end\n end\nend\n```\n\nSee the example code above to find out how to pass them to the model.\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Jamie Gaskins](https://github.com/jgaskins) - creator and maintainer\n","program":{"html_id":"anthropic/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"anthropic","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"anthropic/Anthropic","path":"Anthropic.html","kind":"module","full_name":"Anthropic","name":"Anthropic","abstract":false,"locations":[{"filename":"src/api.cr","line_number":3,"url":null},{"filename":"src/error.cr","line_number":1,"url":null},{"filename":"src/event_source.cr","line_number":6,"url":null},{"filename":"src/message_content.cr","line_number":5,"url":null},{"filename":"src/messages.cr","line_number":5,"url":null},{"filename":"src/model.cr","line_number":1,"url":null},{"filename":"src/resource.cr","line_number":3,"url":null},{"filename":"src/tool.cr","line_number":3,"url":null},{"filename":"src/version.cr","line_number":1,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\""}],"class_methods":[{"html_id":"model_name(model:Model)-class-method","name":"model_name","abstract":false,"args":[{"name":"model","external_name":"model","restriction":"Model"}],"args_string":"(model : Model)","args_html":"(model : Model)","location":{"filename":"src/model.cr","line_number":9,"url":null},"def":{"name":"model_name","args":[{"name":"model","external_name":"model","restriction":"Model"}],"visibility":"Public","body":"MODELS[model]"}},{"html_id":"tool(input_type,description:String|Nil=input_type.description,*,name:String=input_type.name):Tool-class-method","name":"tool","abstract":false,"args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"args_string":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","args_html":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","location":{"filename":"src/tool.cr","line_number":16,"url":null},"def":{"name":"tool","args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"splat_index":2,"return_type":"Tool","visibility":"Public","body":"Tool.new(name: name, description: description, input_type: input_type)"}},{"html_id":"tools(array:Array(Tool))-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"args_string":"(array : Array(Tool))","args_html":"(array : Array(Tool))","location":{"filename":"src/tool.cr","line_number":8,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"visibility":"Public","body":"array"}},{"html_id":"tools(array:Enumerable)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"args_string":"(array : Enumerable)","args_html":"(array : Enumerable)","location":{"filename":"src/tool.cr","line_number":4,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"visibility":"Public","body":"array.map do |handler|\n tool(handler)\nend"}},{"html_id":"tools(array:Nil)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Nil"}],"args_string":"(array : Nil)","args_html":"(array : Nil)","location":{"filename":"src/tool.cr","line_number":12,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Nil"}],"visibility":"Public","body":"[] of Tool(Tool::Handler.class)"}}],"types":[{"html_id":"anthropic/Anthropic/Client","path":"Anthropic/Client.html","kind":"class","full_name":"Anthropic::Client","name":"Client","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/client.cr","line_number":27,"url":null},{"filename":"src/messages.cr","line_number":188,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"doc":"The `Anthropic::Client` is the entrypoint for using the Anthropic API in\nCrystal.\n\n```\nclaude = Anthropic::Client.new # get API key from the ENV\nputs claude.messages.create(\n model: Anthropic.model_name(:haiku),\n messages: [Anthropic::Message.new(\"Write a haiku about the Crystal programming language\")],\n max_tokens: 4096,\n)\n# Sparkling Crystal code,\n# Elegant and swift syntax,\n# Shines with precision.\n```\n\nThe client is concurrency-safe, so you don't need to wrap requests in a mutex\nor manage a connection pool yourself.","summary":"

The Anthropic::Client is the entrypoint for using the Anthropic API in Crystal.

","constructors":[{"html_id":"new(api_key:String=ENV[\"ANTHROPIC_API_KEY\"],base_uri:URI=URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\",\"https://api.anthropic.com\")),log:Log=Log.for(self.class))-class-method","name":"new","doc":"Instantiate a new client with the API key provided either directly or via\nthe `ANTHROPIC_API_KEY` environment variable. You can optionally provide a\nbase URI to connect to if you are using a different but compatible API\nprovider.","summary":"

Instantiate a new client with the API key provided either directly or via the ANTHROPIC_API_KEY environment variable.

","abstract":false,"args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"args_string":"(api_key : String = ENV[\"ANTHROPIC_API_KEY\"], base_uri : URI = URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\")), log : Log = Log.for(self.class))","args_html":"(api_key : String = ENV["ANTHROPIC_API_KEY"], base_uri : URI = URI.parse(ENV.fetch("ANTHROPIC_BASE_URL", "https://api.anthropic.com")), log : Log = Log.for(self.class))","location":{"filename":"src/client.cr","line_number":35,"url":null},"def":{"name":"new","args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"visibility":"Public","body":"_ = allocate\n_.initialize(api_key, base_uri, log)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"api_key:String-instance-method","name":"api_key","abstract":false,"location":{"filename":"src/client.cr","line_number":28,"url":null},"def":{"name":"api_key","return_type":"String","visibility":"Public","body":"@api_key"}},{"html_id":"base_uri:URI-instance-method","name":"base_uri","abstract":false,"location":{"filename":"src/client.cr","line_number":29,"url":null},"def":{"name":"base_uri","return_type":"URI","visibility":"Public","body":"@base_uri"}},{"html_id":"messages-instance-method","name":"messages","abstract":false,"location":{"filename":"src/messages.cr","line_number":189,"url":null},"def":{"name":"messages","visibility":"Public","body":"Messages.new(self)"}}]},{"html_id":"anthropic/Anthropic/ContentBlockDelta","path":"Anthropic/ContentBlockDelta.html","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":114,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"delta:TextDelta-instance-method","name":"delta","abstract":false,"location":{"filename":"src/event_source.cr","line_number":116,"url":null},"def":{"name":"delta","return_type":"TextDelta","visibility":"Public","body":"@delta"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":115,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}]},{"html_id":"anthropic/Anthropic/ContentBlockStart","path":"Anthropic/ContentBlockStart.html","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":118,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content_block:ContentBlock|Nil-instance-method","name":"content_block","abstract":false,"location":{"filename":"src/event_source.cr","line_number":120,"url":null},"def":{"name":"content_block","return_type":"ContentBlock | ::Nil","visibility":"Public","body":"@content_block"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":119,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}],"types":[{"html_id":"anthropic/Anthropic/ContentBlockStart/ContentBlock","path":"Anthropic/ContentBlockStart/ContentBlock.html","kind":"struct","full_name":"Anthropic::ContentBlockStart::ContentBlock","name":"ContentBlock","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":121,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":126,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any|Nil-instance-method","name":"input","abstract":false,"location":{"filename":"src/event_source.cr","line_number":128,"url":null},"def":{"name":"input","return_type":"JSON::Any | ::Nil","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/event_source.cr","line_number":127,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}},{"html_id":"type:GeneratedMessage::Content::Type|Nil-instance-method","name":"type","abstract":false,"location":{"filename":"src/event_source.cr","line_number":124,"url":null},"def":{"name":"type","return_type":"GeneratedMessage::Content::Type | ::Nil","visibility":"Public","body":"@type"}}]}]},{"html_id":"anthropic/Anthropic/ContentBlockStop","path":"Anthropic/ContentBlockStop.html","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":131,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Error","path":"Anthropic/Error.html","kind":"class","full_name":"Anthropic::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":2,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/Error/APIError","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError"},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError"},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError"},{"html_id":"anthropic/Anthropic/Error/NotFoundError","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError"},{"html_id":"anthropic/Anthropic/Error/OverloadedError","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError"},{"html_id":"anthropic/Anthropic/Error/PermissionError","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError"},{"html_id":"anthropic/Anthropic/Error/RateLimitError","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"from_response_body(body:String)-class-method","name":"from_response_body","abstract":false,"args":[{"name":"body","external_name":"body","restriction":"String"}],"args_string":"(body : String)","args_html":"(body : String)","location":{"filename":"src/error.cr","line_number":3,"url":null},"def":{"name":"from_response_body","args":[{"name":"body","external_name":"body","restriction":"String"}],"visibility":"Public","body":"response = Response.from_json(body)\nTYPE_MAP[response.error.type].new(response.error.message)\n"}}],"constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/error.cr","line_number":8,"url":null},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"types":[{"html_id":"anthropic/Anthropic/Error/APIError","path":"Anthropic/Error/APIError.html","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":50,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","path":"Anthropic/Error/AuthenticationError.html","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":38,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","path":"Anthropic/Error/InvalidRequestError.html","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":35,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/NotFoundError","path":"Anthropic/Error/NotFoundError.html","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":44,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/OverloadedError","path":"Anthropic/Error/OverloadedError.html","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":53,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/PermissionError","path":"Anthropic/Error/PermissionError.html","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":41,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/RateLimitError","path":"Anthropic/Error/RateLimitError.html","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":47,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/Response","path":"Anthropic/Error/Response.html","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":56,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"error:Error-instance-method","name":"error","abstract":false,"location":{"filename":"src/error.cr","line_number":60,"url":null},"def":{"name":"error","return_type":"Error","visibility":"Public","body":"@error"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":59,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Error/Response/Error","path":"Anthropic/Error/Response/Error.html","kind":"struct","full_name":"Anthropic::Error::Response::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error/Response","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"message:String-instance-method","name":"message","abstract":false,"location":{"filename":"src/error.cr","line_number":66,"url":null},"def":{"name":"message","return_type":"String","visibility":"Public","body":"@message"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":65,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]}]}]},{"html_id":"anthropic/Anthropic/Event","path":"Anthropic/Event.html","kind":"struct","full_name":"Anthropic::Event","name":"Event","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":99,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/ContentBlockDelta","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta"},{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},{"html_id":"anthropic/Anthropic/ContentBlockStop","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop"},{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},{"html_id":"anthropic/Anthropic/MessageStart","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart"},{"html_id":"anthropic/Anthropic/MessageStop","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop"},{"html_id":"anthropic/Anthropic/MessageStream","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream"},{"html_id":"anthropic/Anthropic/Ping","kind":"struct","full_name":"Anthropic::Ping","name":"Ping"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"new","visibility":"Public","body":"x = allocate\nif x.responds_to?(:finalize)\n ::GC.add_finalizer(x)\nend\nx\n"}}],"instance_methods":[{"html_id":"initialize-instance-method","name":"initialize","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"initialize","visibility":"Public","body":""}}],"macros":[{"html_id":"define(type)-macro","name":"define","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""}],"args_string":"(type)","args_html":"(type)","location":{"filename":"src/event_source.cr","line_number":103,"url":null},"def":{"name":"define","args":[{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":" struct \n{{ type }}\n < ::Anthropic::Event\n include Resource\n\n Event::TYPE_MAP[\n{{ type.stringify.underscore }}\n] = \n{{ type }}\n\n \n \n{{ yield }}\n\n \nend\n \n"}}]},{"html_id":"anthropic/Anthropic/EventMessage","path":"Anthropic/EventMessage.html","kind":"struct","full_name":"Anthropic::EventMessage","name":"EventMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":93,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(data:Array(String),event:String|Nil=nil,id:String|Nil=nil,retry:Int64|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"args_string":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","args_html":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"new","args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(data, event, id, retry)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@data.clone, @event.clone, @id.clone, @retry.clone)"}},{"html_id":"copy_with(data_data=@data,event_event=@event,id_id=@id,retry_retry=@retry)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"args_string":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","args_html":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"copy_with","args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"visibility":"Public","body":"self.class.new(_data, _event, _id, _retry)"}},{"html_id":"data:Array(String)-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"Array(String)","visibility":"Public","body":"@data"}},{"html_id":"event:String|Nil-instance-method","name":"event","abstract":false,"def":{"name":"event","return_type":"String | ::Nil","visibility":"Public","body":"@event"}},{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"retry:Int64|Nil-instance-method","name":"retry","abstract":false,"def":{"name":"retry","return_type":"Int64 | ::Nil","visibility":"Public","body":"@retry"}}]},{"html_id":"anthropic/Anthropic/EventSource","path":"Anthropic/EventSource.html","kind":"class","full_name":"Anthropic::EventSource","name":"EventSource","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":7,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(response:HTTP::Client::Response,last_id:Nil|String=nil)-class-method","name":"new","abstract":false,"args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"args_string":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","args_html":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","location":{"filename":"src/event_source.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(response, last_id)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"last_id:String|Nil-instance-method","name":"last_id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":9,"url":null},"def":{"name":"last_id","return_type":"String | ::Nil","visibility":"Public","body":"@last_id"}},{"html_id":"on_error(&on_error:NamedTuple(status_code:Int32,message:String)->):self-instance-method","name":"on_error","abstract":false,"location":{"filename":"src/event_source.cr","line_number":18,"url":null},"def":{"name":"on_error","yields":1,"block_arity":1,"block_arg":{"name":"on_error","external_name":"on_error","restriction":"(NamedTuple(status_code: Int32, message: String) ->)"},"return_type":"self","visibility":"Public","body":"@on_error = on_error\nself\n"}},{"html_id":"on_message(&on_message:EventMessage,self->):self-instance-method","name":"on_message","abstract":false,"location":{"filename":"src/event_source.cr","line_number":14,"url":null},"def":{"name":"on_message","yields":2,"block_arity":2,"block_arg":{"name":"on_message","external_name":"on_message","restriction":"(EventMessage, self ->)"},"return_type":"self","visibility":"Public","body":"@on_message = on_message\nself\n"}},{"html_id":"response:HTTP::Client::Response-instance-method","name":"response","abstract":false,"location":{"filename":"src/event_source.cr","line_number":8,"url":null},"def":{"name":"response","return_type":"HTTP::Client::Response","visibility":"Public","body":"@response"}},{"html_id":"run:Nil-instance-method","name":"run","abstract":false,"location":{"filename":"src/event_source.cr","line_number":26,"url":null},"def":{"name":"run","return_type":"Nil","visibility":"Public","body":"lines = [] of String\nio = response.body_io\nlast_message = nil\nloop do\n if @abort\n break\n end\n if line = io.gets\n else\n break\n end\n if line.empty? && (!lines.empty?)\n last_message = parse_event_message(lines)\n last_message.id.try do |id|\n @last_id = id\n end\n @on_message.try(&.call(last_message, self))\n lines.clear\n else\n lines << line\n end\nend\nif last_message\n if last_message.id.try(&.empty?) && @abort\n last_message.retry.try do |retry_after|\n sleep(retry_after / 1000)\n end\n end\nend\n"}},{"html_id":"stop:Nil-instance-method","name":"stop","abstract":false,"location":{"filename":"src/event_source.cr","line_number":22,"url":null},"def":{"name":"stop","return_type":"Nil","visibility":"Public","body":"@abort = true"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage","path":"Anthropic/GeneratedMessage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content:Array(MessageContent)-instance-method","name":"content","doc":"This is an array of content blocks, each of which has a `type` that determines\nits shape. Currently, the only `type` in responses is `\"text\"`.\n\nExample:\n\n```json\n[{ \"type\": \"text\", \"text\": \"Hi, I'm Claude.\" }]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the\nresponse `content` will continue directly from that last turn. You can use this\nto constrain the model's output.\n\nFor example, if the input `messages` were:\n\n```json\n[\n {\n \"role\": \"user\",\n \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n },\n { \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{ \"type\": \"text\", \"text\": \"B)\" }]\n```","summary":"

This is an array of content blocks, each of which has a #type that determines its shape.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":43,"url":null},"def":{"name":"content","return_type":"Array(MessageContent)","visibility":"Public","body":"if (value = @content).nil?\n @content = ([] of MessageContent)\nelse\n value\nend"}},{"html_id":"id:String-instance-method","name":"id","doc":"Unique object identifier.\n\nThe format and length of IDs may change over time.","summary":"

Unique object identifier.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":12,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"message_thread:Array(Message)-instance-method","name":"message_thread","doc":"Messages that were passed to the","summary":"

Messages that were passed to the

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":59,"url":null},"def":{"name":"message_thread","return_type":"Array(Message)","visibility":"Public","body":"if (value = @message_thread).nil?\n @message_thread = ([to_message])\nelse\n value\nend"}},{"html_id":"model:String-instance-method","name":"model","doc":"The model that handled the request.","summary":"

The model that handled the request.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":52,"url":null},"def":{"name":"model","return_type":"String","visibility":"Public","body":"@model"}},{"html_id":"role:Message::Role-instance-method","name":"role","doc":"Conversational role of the generated message. This will always be `:assistant`.","summary":"

Conversational role of the generated message.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":49,"url":null},"def":{"name":"role","return_type":"Message::Role","visibility":"Public","body":"@role"}},{"html_id":"stop_reason:StopReason|Nil-instance-method","name":"stop_reason","doc":"The reason that we stopped. This may be one the following values:\n\n- `:end_turn`: the model reached a natural stopping point\n- `:max_tokens`: we exceeded the requested `max_tokens` or the model's maximum\n- `:stop_sequence`: one of your provided custom `stop_sequences` was generated\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is\n`nil` in the `MessageStart` event and non-`nil` otherwise.","summary":"

The reason that we stopped.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":85,"url":null},"def":{"name":"stop_reason","return_type":"StopReason | ::Nil","visibility":"Public","body":"@stop_reason"}},{"html_id":"stop_sequence:String|Nil-instance-method","name":"stop_sequence","doc":"Which custom stop sequence was generated, if any. This value will be a non-\n`nil` string if one of your custom stop sequences was generated.","summary":"

Which custom stop sequence was generated, if any.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":56,"url":null},"def":{"name":"stop_sequence","return_type":"String | ::Nil","visibility":"Public","body":"@stop_sequence"}},{"html_id":"to_message-instance-method","name":"to_message","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":87,"url":null},"def":{"name":"to_message","visibility":"Public","body":"Message.new(role: role, content: content)"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":94,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"content.each do |item|\n io.puts(item)\nend"}},{"html_id":"type:String-instance-method","name":"type","doc":"Object type — for `Message`s, this is always `\"message\"`.","summary":"

Object type — for Messages, this is always "message".

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":46,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}},{"html_id":"usage:Usage-instance-method","name":"usage","doc":"Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the\nunderlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the\nmodel. The model's output then goes through a parsing stage before becoming an\nAPI response. As a result, the token counts in `usage` will not match one-to-one\nwith the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response\nfrom Claude.","summary":"

Billing and rate-limit usage.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":75,"url":null},"def":{"name":"usage","return_type":"Usage","visibility":"Public","body":"@usage"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","path":"Anthropic/GeneratedMessage/Content.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":100,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"subclasses":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text"},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":105,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"location = pull.location\ndiscriminator_value = nil\njson = String.build do |io|\n JSON.build(io) do |builder|\n builder.start_object\n pull.read_object do |key|\n if key == \"type\"\n value_kind = pull.kind\n case value_kind\n when .string?\n discriminator_value = pull.string_value\n when .int?\n discriminator_value = pull.int_value\n when .bool?\n discriminator_value = pull.bool_value\n else\n raise(::JSON::SerializableError.new(\"JSON discriminator field 'type' has an invalid value type of #{value_kind.to_s}\", to_s, nil, *location, nil))\n end\n builder.field(key, discriminator_value)\n pull.read_next\n else\n builder.field(key) do\n pull.read_raw(builder)\n end\n end\n end\n builder.end_object\n end\nend\nif discriminator_value.nil?\n raise(::JSON::SerializableError.new(\"Missing JSON discriminator field 'type'\", to_s, nil, *location, nil))\nend\ncase discriminator_value\nwhen \"text\"\n Text.from_json(json)\nwhen \"tool_use\"\n ToolUse.from_json(json)\nelse\n raise(::JSON::SerializableError.new(\"Unknown 'type' discriminator value: #{discriminator_value.inspect}\", to_s, nil, *location, nil))\nend\n"}}],"instance_methods":[{"html_id":"type:Type-instance-method","name":"type","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":103,"url":null},"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content/Type","path":"Anthropic/GeneratedMessage/Content/Type.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::Content::Type","name":"Type","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":110,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Text","name":"Text","value":"0"},{"id":"ToolUse","name":"ToolUse","value":"1"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"instance_methods":[{"html_id":"text?-instance-method","name":"text?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":111,"url":null},"def":{"name":"text?","visibility":"Public","body":"self == Text"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":112,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/StopReason","path":"Anthropic/GeneratedMessage/StopReason.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::StopReason","name":"StopReason","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":159,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"EndTurn","name":"EndTurn","value":"0"},{"id":"MaxTokens","name":"MaxTokens","value":"1"},{"id":"StopSequence","name":"StopSequence","value":"2"},{"id":"ToolUse","name":"ToolUse","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"instance_methods":[{"html_id":"end_turn?-instance-method","name":"end_turn?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":160,"url":null},"def":{"name":"end_turn?","visibility":"Public","body":"self == EndTurn"}},{"html_id":"max_tokens?-instance-method","name":"max_tokens?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":161,"url":null},"def":{"name":"max_tokens?","visibility":"Public","body":"self == MaxTokens"}},{"html_id":"stop_sequence?-instance-method","name":"stop_sequence?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":162,"url":null},"def":{"name":"stop_sequence?","visibility":"Public","body":"self == StopSequence"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":163,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","path":"Anthropic/GeneratedMessage/Text.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":116,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":116,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"text:String|Nil-instance-method","name":"text","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":117,"url":null},"def":{"name":"text","return_type":"String | ::Nil","visibility":"Public","body":"@text"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":119,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"if text = @text\n io.puts(text)\nend"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","path":"Anthropic/GeneratedMessage/ToolUse.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":126,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":126,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":127,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any-instance-method","name":"input","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":130,"url":null},"def":{"name":"input","return_type":"JSON::Any","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":128,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/PossibleSchema","path":"Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html","kind":"module","full_name":"Anthropic::GeneratedMessage::ToolUse::PossibleSchema","name":"PossibleSchema","abstract":false,"locations":[{"filename":"src/generated_message.cr","line_number":132,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"class_methods":[{"html_id":"from_json(json:JSON::PullParser):JSON::Any-class-method","name":"from_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"args_string":"(json : JSON::PullParser) : JSON::Any","args_html":"(json : JSON::PullParser) : JSON::Any","location":{"filename":"src/generated_message.cr","line_number":133,"url":null},"def":{"name":"from_json","args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"return_type":"JSON::Any","visibility":"Public","body":"hash = Hash(String, JSON::Any).new(json)\nresult = hash.fetch(\"properties\") do\n JSON::Any.new(nil)\nend\nif result.as_h?\n result\nelse\n JSON::Any.new(hash)\nend\n"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/Schema","path":"Anthropic/GeneratedMessage/ToolUse/Schema.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse::Schema","name":"Schema","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":145,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":146,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"properties:JSON::Any-instance-method","name":"properties","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":148,"url":null},"def":{"name":"properties","return_type":"JSON::Any","visibility":"Public","body":"@properties"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Usage","path":"Anthropic/GeneratedMessage/Usage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Usage","name":"Usage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":152,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"input_tokens:Int64-instance-method","name":"input_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":155,"url":null},"def":{"name":"input_tokens","return_type":"Int64","visibility":"Public","body":"@input_tokens"}},{"html_id":"output_tokens:Int64-instance-method","name":"output_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":156,"url":null},"def":{"name":"output_tokens","return_type":"Int64","visibility":"Public","body":"@output_tokens"}}]}]},{"html_id":"anthropic/Anthropic/Image","path":"Anthropic/Image.html","kind":"struct","full_name":"Anthropic::Image","name":"Image","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":39,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"base64(media_type:Source::MediaType,data:String)-class-method","name":"base64","abstract":false,"args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(media_type : Source::MediaType, data : String)","args_html":"(media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":43,"url":null},"def":{"name":"base64","args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"new(type: :base64, media_type: media_type, data: Base64.strict_encode(data))"}}],"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":39,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,type:Source::Type,media_type:Source::MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","args_html":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(type: type, media_type: media_type, data: data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"source:Source-instance-method","name":"source","abstract":false,"location":{"filename":"src/message_content.cr","line_number":41,"url":null},"def":{"name":"source","return_type":"Source","visibility":"Public","body":"@source"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":40,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source","path":"Anthropic/Image/Source.html","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":55,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Image","kind":"struct","full_name":"Anthropic::Image","name":"Image"},"constructors":[{"html_id":"new(type:Type,media_type:MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(type : Type, media_type : MediaType, data : String)","args_html":"(type : Type, media_type : MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, media_type, data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@type.clone, @media_type.clone, @data.clone)"}},{"html_id":"copy_with(type_type=@type,media_type_media_type=@media_type,data_data=@data)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"args_string":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","args_html":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"copy_with","args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"visibility":"Public","body":"self.class.new(_type, _media_type, _data)"}},{"html_id":"data:String-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"String","visibility":"Public","body":"@data"}},{"html_id":"media_type:MediaType-instance-method","name":"media_type","abstract":false,"def":{"name":"media_type","return_type":"MediaType","visibility":"Public","body":"@media_type"}},{"html_id":"type:Type-instance-method","name":"type","abstract":false,"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source/MediaType","path":"Anthropic/Image/Source/MediaType.html","kind":"enum","full_name":"Anthropic::Image::Source::MediaType","name":"MediaType","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"JPEG","name":"JPEG","value":"0"},{"id":"PNG","name":"PNG","value":"1"},{"id":"GIF","name":"GIF","value":"2"},{"id":"WEBP","name":"WEBP","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},"instance_methods":[{"html_id":"gif?-instance-method","name":"gif?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":65,"url":null},"def":{"name":"gif?","visibility":"Public","body":"self == GIF"}},{"html_id":"jpeg?-instance-method","name":"jpeg?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":63,"url":null},"def":{"name":"jpeg?","visibility":"Public","body":"self == JPEG"}},{"html_id":"png?-instance-method","name":"png?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":64,"url":null},"def":{"name":"png?","visibility":"Public","body":"self == PNG"}},{"html_id":"to_s-instance-method","name":"to_s","doc":"Returns a `String` representation of this enum member.\nIn the case of regular enums, this is just the name of the member.\nIn the case of flag enums, it's the names joined by vertical bars, or \"None\",\nif the value is zero.\n\nIf an enum's value doesn't match a member's value, the raw value\nis returned as a string.\n\n```\nColor::Red.to_s # => \"Red\"\nIOMode::None.to_s # => \"None\"\n(IOMode::Read | IOMode::Write).to_s # => \"Read | Write\"\n\nColor.new(10).to_s # => \"10\"\n```","summary":"

Returns a String representation of this enum member.

","abstract":false,"location":{"filename":"src/message_content.cr","line_number":68,"url":null},"def":{"name":"to_s","visibility":"Public","body":"\"image/#{super().downcase}\""}},{"html_id":"webp?-instance-method","name":"webp?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":66,"url":null},"def":{"name":"webp?","visibility":"Public","body":"self == WEBP"}}]},{"html_id":"anthropic/Anthropic/Image/Source/Type","path":"Anthropic/Image/Source/Type.html","kind":"enum","full_name":"Anthropic::Image::Source::Type","name":"Type","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":57,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Base64","name":"Base64","value":"0"}],"namespace":{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},"instance_methods":[{"html_id":"base64?-instance-method","name":"base64?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":59,"url":null},"def":{"name":"base64?","visibility":"Public","body":"self == Base64"}}]}]}]},{"html_id":"anthropic/Anthropic/Message","path":"Anthropic/Message.html","kind":"struct","full_name":"Anthropic::Message","name":"Message","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message.cr","line_number":4,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(content:Array(Anthropic::MessageContent)|String,role:Anthropic::Message::Role=:user)-class-method","name":"new","abstract":false,"args":[{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::MessageContent) | ::String"},{"name":"role","default_value":":user","external_name":"role","restriction":"::Anthropic::Message::Role"}],"args_string":"(content : Array(Anthropic::MessageContent) | String, role : Anthropic::Message::Role = :user)","args_html":"(content : Array(Anthropic::MessageContent) | String, role : Anthropic::Message::Role = :user)","location":{"filename":"src/message.cr","line_number":10,"url":null},"def":{"name":"new","args":[{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::MessageContent) | ::String"},{"name":"role","default_value":":user","external_name":"role","restriction":"::Anthropic::Message::Role"}],"visibility":"Public","body":"_ = allocate\n_.initialize(content, role)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"content:String|Array(MessageContent)-instance-method","name":"content","abstract":false,"location":{"filename":"src/message.cr","line_number":8,"url":null},"def":{"name":"content","return_type":"String | Array(MessageContent)","visibility":"Public","body":"@content"}},{"html_id":"role:Role-instance-method","name":"role","abstract":false,"location":{"filename":"src/message.cr","line_number":7,"url":null},"def":{"name":"role","return_type":"Role","visibility":"Public","body":"@role"}}],"types":[{"html_id":"anthropic/Anthropic/Message/Role","path":"Anthropic/Message/Role.html","kind":"enum","full_name":"Anthropic::Message::Role","name":"Role","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message.cr","line_number":13,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"User","name":"User","value":"0"},{"id":"Assistant","name":"Assistant","value":"1"}],"namespace":{"html_id":"anthropic/Anthropic/Message","kind":"struct","full_name":"Anthropic::Message","name":"Message"},"instance_methods":[{"html_id":"assistant?-instance-method","name":"assistant?","abstract":false,"location":{"filename":"src/message.cr","line_number":15,"url":null},"def":{"name":"assistant?","visibility":"Public","body":"self == Assistant"}},{"html_id":"user?-instance-method","name":"user?","abstract":false,"location":{"filename":"src/message.cr","line_number":14,"url":null},"def":{"name":"user?","visibility":"Public","body":"self == User"}}]}]},{"html_id":"anthropic/Anthropic/MessageContent","path":"Anthropic/MessageContent.html","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"subclasses":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/ToolResult","kind":"struct","full_name":"Anthropic::ToolResult","name":"ToolResult"},{"html_id":"anthropic/Anthropic/ToolUse","kind":"struct","full_name":"Anthropic::ToolUse","name":"ToolUse"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"location = pull.location\ndiscriminator_value = nil\njson = String.build do |io|\n JSON.build(io) do |builder|\n builder.start_object\n pull.read_object do |key|\n if key == \"type\"\n value_kind = pull.kind\n case value_kind\n when .string?\n discriminator_value = pull.string_value\n when .int?\n discriminator_value = pull.int_value\n when .bool?\n discriminator_value = pull.bool_value\n else\n raise(::JSON::SerializableError.new(\"JSON discriminator field 'type' has an invalid value type of #{value_kind.to_s}\", to_s, nil, *location, nil))\n end\n builder.field(key, discriminator_value)\n pull.read_next\n else\n builder.field(key) do\n pull.read_raw(builder)\n end\n end\n end\n builder.end_object\n end\nend\nif discriminator_value.nil?\n raise(::JSON::SerializableError.new(\"Missing JSON discriminator field 'type'\", to_s, nil, *location, nil))\nend\ncase discriminator_value\nwhen \"text\"\n Text.from_json(json)\nwhen \"image\"\n Image.from_json(json)\nwhen \"tool_use\"\n ToolUse.from_json(json)\nwhen \"tool_result\"\n ToolResult.from_json(json)\nelse\n raise(::JSON::SerializableError.new(\"Unknown 'type' discriminator value: #{discriminator_value.inspect}\", to_s, nil, *location, nil))\nend\n"}}],"instance_methods":[{"html_id":"type:String-instance-method","name":"type","abstract":true,"location":{"filename":"src/message_content.cr","line_number":9,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":""}}]},{"html_id":"anthropic/Anthropic/MessageDelta","path":"Anthropic/MessageDelta.html","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":132,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"delta:Delta-instance-method","name":"delta","abstract":false,"location":{"filename":"src/event_source.cr","line_number":133,"url":null},"def":{"name":"delta","return_type":"Delta","visibility":"Public","body":"@delta"}},{"html_id":"usage:Usage-instance-method","name":"usage","abstract":false,"location":{"filename":"src/event_source.cr","line_number":134,"url":null},"def":{"name":"usage","return_type":"Usage","visibility":"Public","body":"@usage"}}],"types":[{"html_id":"anthropic/Anthropic/MessageDelta/Delta","path":"Anthropic/MessageDelta/Delta.html","kind":"struct","full_name":"Anthropic::MessageDelta::Delta","name":"Delta","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":135,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"stop_reason:GeneratedMessage::StopReason|Nil-instance-method","name":"stop_reason","abstract":false,"location":{"filename":"src/event_source.cr","line_number":138,"url":null},"def":{"name":"stop_reason","return_type":"GeneratedMessage::StopReason | ::Nil","visibility":"Public","body":"@stop_reason"}},{"html_id":"stop_sequence:String|Nil-instance-method","name":"stop_sequence","abstract":false,"location":{"filename":"src/event_source.cr","line_number":140,"url":null},"def":{"name":"stop_sequence","return_type":"String | ::Nil","visibility":"Public","body":"@stop_sequence"}}]},{"html_id":"anthropic/Anthropic/MessageDelta/Usage","path":"Anthropic/MessageDelta/Usage.html","kind":"struct","full_name":"Anthropic::MessageDelta::Usage","name":"Usage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":143,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"output_tokens:Int64-instance-method","name":"output_tokens","abstract":false,"location":{"filename":"src/event_source.cr","line_number":145,"url":null},"def":{"name":"output_tokens","return_type":"Int64","visibility":"Public","body":"@output_tokens"}}]}]},{"html_id":"anthropic/Anthropic/Messages","path":"Anthropic/Messages.html","kind":"struct","full_name":"Anthropic::Messages","name":"Messages","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/API","kind":"struct","full_name":"Anthropic::API","name":"API"},"ancestors":[{"html_id":"anthropic/Anthropic/API","kind":"struct","full_name":"Anthropic::API","name":"API"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"instance_methods":[{"html_id":"create(*,model:String,max_tokens:Int32,messages:Array(Anthropic::Message),system:String|Nil=nil,temperature:Float64|Nil=nil,top_k:Int64|Nil=nil,top_p:Float64|Nil=nil,tools:Array|Nil=nil,run_tools:Bool=true):GeneratedMessage-instance-method","name":"create","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"Array | ::Nil"},{"name":"run_tools","default_value":"true","external_name":"run_tools","restriction":"Bool"}],"args_string":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, tools : Array | Nil = nil, run_tools : Bool = true) : GeneratedMessage","args_html":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, tools : Array | Nil = nil, run_tools : Bool = true) : GeneratedMessage","location":{"filename":"src/messages.cr","line_number":7,"url":null},"def":{"name":"create","args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"Array | ::Nil"},{"name":"run_tools","default_value":"true","external_name":"run_tools","restriction":"Bool"}],"splat_index":0,"return_type":"GeneratedMessage","visibility":"Public","body":"tools = Anthropic.tools(tools)\nrequest = Request.new(model: model, max_tokens: max_tokens, system: system, messages: messages, temperature: temperature, top_k: top_k, top_p: top_p, tools: tools.to_json)\nheaders = HTTP::Headers.new\nif tools.try(&.any?)\n headers.add(\"anthropic-beta\", \"tools-2024-05-16\")\nend\nif (model.includes?(\"3-5-sonnet\")) && max_tokens > 4096\n headers.add(\"anthropic-beta\", \"max-tokens-3-5-sonnet-2024-07-15\")\nend\nresponse = client.post(\"/v1/messages?beta=tools\", headers: headers, body: request, as: GeneratedMessage)\nresponse.message_thread = messages.dup << response.to_message\nif run_tools && response.stop_reason.try(&.tool_use?)\n tool_uses = response.content.compact_map() do |__arg2|\n __arg2.as?(ToolUse)\n end\n tools_used = tool_uses.compact_map do |tool_use|\n tools.find do |t|\n t.name == tool_use.name\n end\n end\n tool_handlers = tools_used.map_with_index do |tool, index|\n tool.input_type.parse(tool_uses[index].input.to_json)\n end\n if tool_handlers.any?\n result_texts = tool_handlers.map do |tool_handler|\n (Text.new(tool_handler.call.to_json)).as(Text)\n end\n create(model: model, max_tokens: max_tokens, messages: messages + [response.to_message, Message.new(content: result_texts.map_with_index do |result_text, index|\n ToolResult.new(tool_use_id: tool_uses[index].id.not_nil!, content: [result_text]).as(MessageContent)\n end)], system: system, temperature: temperature, top_k: top_k, top_p: top_p, tools: tools, run_tools: run_tools)\n else\n response\n end\nelse\n response\nend\n"}},{"html_id":"create(*,model:String,max_tokens:Int32,messages:Array(Anthropic::Message),system:String|Nil=nil,temperature:Float64|Nil=nil,top_k:Int64|Nil=nil,top_p:Float64|Nil=nil,&block:Event->T)forallT-instance-method","name":"create","doc":"Send your prompt to the API and yield `Event`s as they are fed back in.","summary":"

Send your prompt to the API and yield Events as they are fed back in.

\n

EXPERIMENTAL

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"}],"args_string":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, &block : Event -> T) forall T","args_html":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, &block : Event -> T) forall T","location":{"filename":"src/messages.cr","line_number":94,"url":null},"def":{"name":"create","args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"}],"splat_index":0,"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Event -> T)"},"visibility":"Public","body":"client.http do |http|\n headers = HTTP::Headers {\"anthropic-beta\" => \"tools-2024-04-04\", \"Accept\" => \"text/event-stream\"}\n body = Request.new(model: model, max_tokens: max_tokens, system: system, messages: messages, temperature: temperature, top_k: top_k, top_p: top_p, tools: tools, stream: true).to_json\n http.post(\"/v1/messages?beta=tools\", headers: headers, body: body) do |response|\n (EventSource.new(response)).on_message do |message, es|\n message.data.each do |data|\n block.call(Event::TYPE_MAP[message.event].from_json(data))\n end\n end.run\n response\n end\nend"}}],"types":[{"html_id":"anthropic/Anthropic/Messages/Body","path":"Anthropic/Messages/Body.html","kind":"struct","full_name":"Anthropic::Messages::Body","name":"Body","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":183,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Messages","kind":"struct","full_name":"Anthropic::Messages","name":"Messages"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Messages/Query","path":"Anthropic/Messages/Query.html","kind":"struct","full_name":"Anthropic::Messages::Query","name":"Query","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":179,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Messages","kind":"struct","full_name":"Anthropic::Messages","name":"Messages"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Messages/Request","path":"Anthropic/Messages/Request.html","kind":"struct","full_name":"Anthropic::Messages::Request","name":"Request","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":136,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Messages","kind":"struct","full_name":"Anthropic::Messages","name":"Messages"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,model:String,max_tokens:Int32,messages:Array(Anthropic::Message),system:Nil|String=nil,metadata:Nil|Hash(String,String)=nil,stop_sequences:Nil|Array(String)=nil,stream:Bool|Nil=nil,temperature:Float64|Nil=nil,tools:Nil|String=nil,top_k:Int64|Nil=nil,top_p:Float64|Nil=nil,extra_headers:HTTP::Headers|Nil=nil,extra_query:Anthropic::Messages::Query|Nil=nil,extra_body:Anthropic::Messages::Body|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"::String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"::Int32"},{"name":"messages","external_name":"messages","restriction":"::Array(::Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"::Nil | ::String"},{"name":"metadata","default_value":"nil","external_name":"metadata","restriction":"::Nil | ::Hash(::String, ::String)"},{"name":"stop_sequences","default_value":"nil","external_name":"stop_sequences","restriction":"::Nil | ::Array(::String)"},{"name":"stream","default_value":"nil","external_name":"stream","restriction":"::Bool | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"::Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"::Nil | ::String"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"::Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"::Float64 | ::Nil"},{"name":"extra_headers","default_value":"nil","external_name":"extra_headers","restriction":"::HTTP::Headers | ::Nil"},{"name":"extra_query","default_value":"nil","external_name":"extra_query","restriction":"::Anthropic::Messages::Query | ::Nil"},{"name":"extra_body","default_value":"nil","external_name":"extra_body","restriction":"::Anthropic::Messages::Body | ::Nil"}],"args_string":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : Nil | String = nil, metadata : Nil | Hash(String, String) = nil, stop_sequences : Nil | Array(String) = nil, stream : Bool | Nil = nil, temperature : Float64 | Nil = nil, tools : Nil | String = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, extra_headers : HTTP::Headers | Nil = nil, extra_query : Anthropic::Messages::Query | Nil = nil, extra_body : Anthropic::Messages::Body | Nil = nil)","args_html":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : Nil | String = nil, metadata : Nil | Hash(String, String) = nil, stop_sequences : Nil | Array(String) = nil, stream : Bool | Nil = nil, temperature : Float64 | Nil = nil, tools : Nil | String = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, extra_headers : HTTP::Headers | Nil = nil, extra_query : Anthropic::Messages::Query | Nil = nil, extra_body : Anthropic::Messages::Body | Nil = nil)","location":{"filename":"src/messages.cr","line_number":158,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"::String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"::Int32"},{"name":"messages","external_name":"messages","restriction":"::Array(::Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"::Nil | ::String"},{"name":"metadata","default_value":"nil","external_name":"metadata","restriction":"::Nil | ::Hash(::String, ::String)"},{"name":"stop_sequences","default_value":"nil","external_name":"stop_sequences","restriction":"::Nil | ::Array(::String)"},{"name":"stream","default_value":"nil","external_name":"stream","restriction":"::Bool | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"::Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"::Nil | ::String"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"::Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"::Float64 | ::Nil"},{"name":"extra_headers","default_value":"nil","external_name":"extra_headers","restriction":"::HTTP::Headers | ::Nil"},{"name":"extra_query","default_value":"nil","external_name":"extra_query","restriction":"::Anthropic::Messages::Query | ::Nil"},{"name":"extra_body","default_value":"nil","external_name":"extra_body","restriction":"::Anthropic::Messages::Body | ::Nil"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(model: model, max_tokens: max_tokens, messages: messages, system: system, metadata: metadata, stop_sequences: stop_sequences, stream: stream, temperature: temperature, tools: tools, top_k: top_k, top_p: top_p, extra_headers: extra_headers, extra_query: extra_query, extra_body: extra_body)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"extra_body:Body|Nil-instance-method","name":"extra_body","abstract":false,"location":{"filename":"src/messages.cr","line_number":153,"url":null},"def":{"name":"extra_body","return_type":"Body | ::Nil","visibility":"Public","body":"@extra_body"}},{"html_id":"extra_headers:HTTP::Headers|Nil-instance-method","name":"extra_headers","abstract":false,"location":{"filename":"src/messages.cr","line_number":151,"url":null},"def":{"name":"extra_headers","return_type":"HTTP::Headers | ::Nil","visibility":"Public","body":"@extra_headers"}},{"html_id":"extra_query:Query|Nil-instance-method","name":"extra_query","abstract":false,"location":{"filename":"src/messages.cr","line_number":152,"url":null},"def":{"name":"extra_query","return_type":"Query | ::Nil","visibility":"Public","body":"@extra_query"}},{"html_id":"max_tokens:Int32-instance-method","name":"max_tokens","abstract":false,"location":{"filename":"src/messages.cr","line_number":141,"url":null},"def":{"name":"max_tokens","return_type":"Int32","visibility":"Public","body":"@max_tokens"}},{"html_id":"messages:Array(Message)-instance-method","name":"messages","abstract":false,"location":{"filename":"src/messages.cr","line_number":140,"url":null},"def":{"name":"messages","return_type":"Array(Message)","visibility":"Public","body":"@messages"}},{"html_id":"metadata:Hash(String,String)|Nil-instance-method","name":"metadata","abstract":false,"location":{"filename":"src/messages.cr","line_number":143,"url":null},"def":{"name":"metadata","return_type":"Hash(String, String) | ::Nil","visibility":"Public","body":"@metadata"}},{"html_id":"model:String-instance-method","name":"model","abstract":false,"location":{"filename":"src/messages.cr","line_number":139,"url":null},"def":{"name":"model","return_type":"String","visibility":"Public","body":"@model"}},{"html_id":"stop_sequences:Array(String)|Nil-instance-method","name":"stop_sequences","abstract":false,"location":{"filename":"src/messages.cr","line_number":144,"url":null},"def":{"name":"stop_sequences","return_type":"Array(String) | ::Nil","visibility":"Public","body":"@stop_sequences"}},{"html_id":"stream?:Bool|Nil-instance-method","name":"stream?","abstract":false,"location":{"filename":"src/messages.cr","line_number":145,"url":null},"def":{"name":"stream?","return_type":"Bool | ::Nil","visibility":"Public","body":"@stream"}},{"html_id":"system:String|Nil-instance-method","name":"system","abstract":false,"location":{"filename":"src/messages.cr","line_number":142,"url":null},"def":{"name":"system","return_type":"String | ::Nil","visibility":"Public","body":"@system"}},{"html_id":"temperature:Float64|Nil-instance-method","name":"temperature","abstract":false,"location":{"filename":"src/messages.cr","line_number":146,"url":null},"def":{"name":"temperature","return_type":"Float64 | ::Nil","visibility":"Public","body":"@temperature"}},{"html_id":"tools:String|Nil-instance-method","name":"tools","abstract":false,"location":{"filename":"src/messages.cr","line_number":148,"url":null},"def":{"name":"tools","return_type":"String | ::Nil","visibility":"Public","body":"@tools"}},{"html_id":"top_k:Int64|Nil-instance-method","name":"top_k","abstract":false,"location":{"filename":"src/messages.cr","line_number":149,"url":null},"def":{"name":"top_k","return_type":"Int64 | ::Nil","visibility":"Public","body":"@top_k"}},{"html_id":"top_p:Float64|Nil-instance-method","name":"top_p","abstract":false,"location":{"filename":"src/messages.cr","line_number":150,"url":null},"def":{"name":"top_p","return_type":"Float64 | ::Nil","visibility":"Public","body":"@top_p"}}]}]},{"html_id":"anthropic/Anthropic/MessageStart","path":"Anthropic/MessageStart.html","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":149,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"message:GeneratedMessage-instance-method","name":"message","abstract":false,"location":{"filename":"src/event_source.cr","line_number":150,"url":null},"def":{"name":"message","return_type":"GeneratedMessage","visibility":"Public","body":"@message"}}]},{"html_id":"anthropic/Anthropic/MessageStop","path":"Anthropic/MessageStop.html","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":152,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/MessageStream","path":"Anthropic/MessageStream.html","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":153,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Model","path":"Anthropic/Model.html","kind":"enum","full_name":"Anthropic::Model","name":"Model","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/model.cr","line_number":13,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Haiku","name":"Haiku","value":"0"},{"id":"Sonnet","name":"Sonnet","value":"1"},{"id":"Opus","name":"Opus","value":"2"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"instance_methods":[{"html_id":"haiku?-instance-method","name":"haiku?","abstract":false,"location":{"filename":"src/model.cr","line_number":14,"url":null},"def":{"name":"haiku?","visibility":"Public","body":"self == Haiku"}},{"html_id":"opus?-instance-method","name":"opus?","abstract":false,"location":{"filename":"src/model.cr","line_number":16,"url":null},"def":{"name":"opus?","visibility":"Public","body":"self == Opus"}},{"html_id":"sonnet?-instance-method","name":"sonnet?","abstract":false,"location":{"filename":"src/model.cr","line_number":15,"url":null},"def":{"name":"sonnet?","visibility":"Public","body":"self == Sonnet"}}]},{"html_id":"anthropic/Anthropic/Ping","path":"Anthropic/Ping.html","kind":"struct","full_name":"Anthropic::Ping","name":"Ping","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":154,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Resource","path":"Anthropic/Resource.html","kind":"module","full_name":"Anthropic::Resource","name":"Resource","abstract":false,"locations":[{"filename":"src/resource.cr","line_number":4,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"anthropic/Anthropic/ContentBlockDelta","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta"},{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},{"html_id":"anthropic/Anthropic/ContentBlockStart/ContentBlock","kind":"struct","full_name":"Anthropic::ContentBlockStart::ContentBlock","name":"ContentBlock"},{"html_id":"anthropic/Anthropic/ContentBlockStop","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop"},{"html_id":"anthropic/Anthropic/Error/Response","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response"},{"html_id":"anthropic/Anthropic/Error/Response/Error","kind":"struct","full_name":"Anthropic::Error::Response::Error","name":"Error"},{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/Anthropic/GeneratedMessage/Usage","kind":"struct","full_name":"Anthropic::GeneratedMessage::Usage","name":"Usage"},{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},{"html_id":"anthropic/Anthropic/Message","kind":"struct","full_name":"Anthropic::Message","name":"Message"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},{"html_id":"anthropic/Anthropic/MessageDelta/Delta","kind":"struct","full_name":"Anthropic::MessageDelta::Delta","name":"Delta"},{"html_id":"anthropic/Anthropic/MessageDelta/Usage","kind":"struct","full_name":"Anthropic::MessageDelta::Usage","name":"Usage"},{"html_id":"anthropic/Anthropic/Messages/Body","kind":"struct","full_name":"Anthropic::Messages::Body","name":"Body"},{"html_id":"anthropic/Anthropic/Messages/Query","kind":"struct","full_name":"Anthropic::Messages::Query","name":"Query"},{"html_id":"anthropic/Anthropic/Messages/Request","kind":"struct","full_name":"Anthropic::Messages::Request","name":"Request"},{"html_id":"anthropic/Anthropic/MessageStart","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart"},{"html_id":"anthropic/Anthropic/MessageStop","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop"},{"html_id":"anthropic/Anthropic/MessageStream","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream"},{"html_id":"anthropic/Anthropic/Ping","kind":"struct","full_name":"Anthropic::Ping","name":"Ping"},{"html_id":"anthropic/Anthropic/TextDelta","kind":"struct","full_name":"Anthropic::TextDelta","name":"TextDelta"},{"html_id":"anthropic/Anthropic/Tool","kind":"struct","full_name":"Anthropic::Tool(T)","name":"Tool"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"}},{"html_id":"anthropic/Anthropic/Text","path":"Anthropic/Text.html","kind":"struct","full_name":"Anthropic::Text","name":"Text","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":25,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":25,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(text:String)-class-method","name":"new","abstract":false,"args":[{"name":"text","external_name":"text","restriction":"::String"}],"args_string":"(text : String)","args_html":"(text : String)","location":{"filename":"src/message_content.cr","line_number":29,"url":null},"def":{"name":"new","args":[{"name":"text","external_name":"text","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(text)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"text:String-instance-method","name":"text","abstract":false,"location":{"filename":"src/message_content.cr","line_number":27,"url":null},"def":{"name":"text","return_type":"String","visibility":"Public","body":"@text"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/message_content.cr","line_number":32,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"if text = @text\n io.puts(text)\nend"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":26,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"anthropic/Anthropic/TextDelta","path":"Anthropic/TextDelta.html","kind":"struct","full_name":"Anthropic::TextDelta","name":"TextDelta","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":156,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"text:String|Nil-instance-method","name":"text","abstract":false,"location":{"filename":"src/event_source.cr","line_number":162,"url":null},"def":{"name":"text","return_type":"String | ::Nil","visibility":"Public","body":"@text"}}]},{"html_id":"anthropic/Anthropic/TextOrImageContent","path":"Anthropic/TextOrImageContent.html","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent","abstract":true,"superclass":{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":19,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/Image","kind":"struct","full_name":"Anthropic::Image","name":"Image"},{"html_id":"anthropic/Anthropic/Text","kind":"struct","full_name":"Anthropic::Text","name":"Text"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":20,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"raise(\"oops\")"}}]},{"html_id":"anthropic/Anthropic/Tool","path":"Anthropic/Tool.html","kind":"struct","full_name":"Anthropic::Tool(T)","name":"Tool","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/tool.cr","line_number":24,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(name:String,description:Nil|String,input_type:T)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"description","external_name":"description","restriction":"::Nil | ::String"},{"name":"input_type","external_name":"input_type","restriction":"T"}],"args_string":"(name : String, description : Nil | String, input_type : T)","args_html":"(name : String, description : Nil | String, input_type : T)","location":{"filename":"src/tool.cr","line_number":31,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"description","external_name":"description","restriction":"::Nil | ::String"},{"name":"input_type","external_name":"input_type","restriction":"T"}],"visibility":"Public","body":"_ = Tool(T).allocate\n_.initialize(name, description, input_type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"description:String|Nil-instance-method","name":"description","abstract":false,"location":{"filename":"src/tool.cr","line_number":28,"url":null},"def":{"name":"description","return_type":"String | ::Nil","visibility":"Public","body":"@description"}},{"html_id":"input_type:T-instance-method","name":"input_type","abstract":false,"location":{"filename":"src/tool.cr","line_number":29,"url":null},"def":{"name":"input_type","return_type":"T","visibility":"Public","body":"@input_type"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/tool.cr","line_number":27,"url":null},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"to_json(json:JSON::Builder):Nil-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"args_string":"(json : JSON::Builder) : Nil","args_html":"(json : JSON::Builder) : Nil","location":{"filename":"src/tool.cr","line_number":34,"url":null},"def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"return_type":"Nil","visibility":"Public","body":"json.object do\n json.field(\"name\", name)\n if description\n json.field(\"description\", description)\n end\n json.field(\"input_schema\") do\n input_type.json_schema.to_json(json)\n end\nend"}}],"types":[{"html_id":"anthropic/Anthropic/Tool/Handler","path":"Anthropic/Tool/Handler.html","kind":"struct","full_name":"Anthropic::Tool::Handler","name":"Handler","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/tool.cr","line_number":46,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Tool","kind":"struct","full_name":"Anthropic::Tool(T)","name":"Tool"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/tool.cr","line_number":49,"url":null},"def":{"name":"description","visibility":"Public","body":""}},{"html_id":"parse(json:String)-class-method","name":"parse","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"String"}],"args_string":"(json : String)","args_html":"(json : String)","location":{"filename":"src/tool.cr","line_number":52,"url":null},"def":{"name":"parse","args":[{"name":"json","external_name":"json","restriction":"String"}],"visibility":"Public","body":"raise(NotImplementedError.new(\"Can't parse #{self} from #{json}\"))"}}],"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/tool.cr","line_number":47,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"call-instance-method","name":"call","abstract":true,"location":{"filename":"src/tool.cr","line_number":62,"url":null},"def":{"name":"call","visibility":"Public","body":""}}]}]},{"html_id":"anthropic/Anthropic/ToolResult","path":"Anthropic/ToolResult.html","kind":"struct","full_name":"Anthropic::ToolResult","name":"ToolResult","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":85,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":85,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,tool_use_id:String,error:Bool=false,content:Array(Text)|Array(Image))-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"String"},{"name":"error","default_value":"false","external_name":"error","restriction":"Bool"},{"name":"content","external_name":"content","restriction":"Array(Text) | Array(Image)"}],"args_string":"(*, tool_use_id : String, error : Bool = false, content : Array(Text) | Array(Image))","args_html":"(*, tool_use_id : String, error : Bool = false, content : Array(Text) | Array(Image))","location":{"filename":"src/message_content.cr","line_number":92,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"String"},{"name":"error","default_value":"false","external_name":"error","restriction":"Bool"},{"name":"content","external_name":"content","restriction":"Array(Text) | Array(Image)"}],"splat_index":0,"visibility":"Public","body":"new(tool_use_id: tool_use_id, error: error, content: content.map do |__arg0|\n __arg0.as(Text | Image)\nend)"}},{"html_id":"new(*,tool_use_id:String,error:Bool=false,content:Array(Anthropic::TextOrImageContent))-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"::String"},{"name":"error","default_value":"false","external_name":"error","restriction":"::Bool"},{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::TextOrImageContent)"}],"args_string":"(*, tool_use_id : String, error : Bool = false, content : Array(Anthropic::TextOrImageContent))","args_html":"(*, tool_use_id : String, error : Bool = false, content : Array(Anthropic::TextOrImageContent))","location":{"filename":"src/message_content.cr","line_number":100,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"::String"},{"name":"error","default_value":"false","external_name":"error","restriction":"::Bool"},{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::TextOrImageContent)"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(tool_use_id: tool_use_id, error: error, content: content)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"content:Array(Text|Image)-instance-method","name":"content","abstract":false,"location":{"filename":"src/message_content.cr","line_number":90,"url":null},"def":{"name":"content","return_type":"Array(Text | Image)","visibility":"Public","body":"@content"}},{"html_id":"error?:Bool-instance-method","name":"error?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":89,"url":null},"def":{"name":"error?","return_type":"Bool","visibility":"Public","body":"@error"}},{"html_id":"tool_use_id:String-instance-method","name":"tool_use_id","abstract":false,"location":{"filename":"src/message_content.cr","line_number":87,"url":null},"def":{"name":"tool_use_id","return_type":"String","visibility":"Public","body":"@tool_use_id"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":86,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"anthropic/Anthropic/ToolUse","path":"Anthropic/ToolUse.html","kind":"struct","full_name":"Anthropic::ToolUse","name":"ToolUse","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":75,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":75,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,id:String,name:String,input:Hash(String,Array(JSON::Any)|Bool|Float64|Hash(String,JSON::Any)|Int64|String|Nil))-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"id","external_name":"id","restriction":"::String"},{"name":"name","external_name":"name","restriction":"::String"},{"name":"input","external_name":"input","restriction":"::Hash(::String, ::Array(::JSON::Any) | ::Bool | ::Float64 | ::Hash(::String, ::JSON::Any) | ::Int64 | ::String | ::Nil)"}],"args_string":"(*, id : String, name : String, input : Hash(String, Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil))","args_html":"(*, id : String, name : String, input : Hash(String, Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil))","location":{"filename":"src/message_content.cr","line_number":81,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"id","external_name":"id","restriction":"::String"},{"name":"name","external_name":"name","restriction":"::String"},{"name":"input","external_name":"input","restriction":"::Hash(::String, ::Array(::JSON::Any) | ::Bool | ::Float64 | ::Hash(::String, ::JSON::Any) | ::Int64 | ::String | ::Nil)"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(id: id, name: name, input: input)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/message_content.cr","line_number":77,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"input:Hash(String,JSON::Any::Type)-instance-method","name":"input","abstract":false,"location":{"filename":"src/message_content.cr","line_number":79,"url":null},"def":{"name":"input","return_type":"Hash(String, JSON::Any::Type)","visibility":"Public","body":"@input"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/message_content.cr","line_number":78,"url":null},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":76,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]}]}]}} \ No newline at end of file diff --git a/docs/js/doc.js b/docs/js/doc.js new file mode 100644 index 0000000..eaedd5c --- /dev/null +++ b/docs/js/doc.js @@ -0,0 +1,1099 @@ +window.CrystalDocs = (window.CrystalDocs || {}); + +CrystalDocs.base_path = (CrystalDocs.base_path || ""); + +CrystalDocs.searchIndex = (CrystalDocs.searchIndex || false); +CrystalDocs.MAX_RESULTS_DISPLAY = 140; + +CrystalDocs.runQuery = function(query) { + function searchType(type, query, results) { + var matches = []; + var matchedFields = []; + var name = type.full_name; + var i = name.lastIndexOf("::"); + if (i > 0) { + name = name.substring(i + 2); + } + var nameMatches = query.matches(name); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + + var namespaceMatches = query.matchesNamespace(type.full_name); + if(namespaceMatches){ + matches = matches.concat(namespaceMatches); + matchedFields.push("name"); + } + + var docMatches = query.matches(type.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + if (matches.length > 0) { + results.push({ + id: type.html_id, + result_type: "type", + kind: type.kind, + name: name, + full_name: type.full_name, + href: type.path, + summary: type.summary, + matched_fields: matchedFields, + matched_terms: matches + }); + } + + if (type.instance_methods) { + type.instance_methods.forEach(function(method) { + searchMethod(method, type, "instance_method", query, results); + }) + } + if (type.class_methods) { + type.class_methods.forEach(function(method) { + searchMethod(method, type, "class_method", query, results); + }) + } + if (type.constructors) { + type.constructors.forEach(function(constructor) { + searchMethod(constructor, type, "constructor", query, results); + }) + } + if (type.macros) { + type.macros.forEach(function(macro) { + searchMethod(macro, type, "macro", query, results); + }) + } + if (type.constants) { + type.constants.forEach(function(constant){ + searchConstant(constant, type, query, results); + }); + } + if (type.types) { + type.types.forEach(function(subtype){ + searchType(subtype, query, results); + }); + } + }; + + function searchMethod(method, type, kind, query, results) { + var matches = []; + var matchedFields = []; + var nameMatches = query.matchesMethod(method.name, kind, type); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + + if (method.args) { + method.args.forEach(function(arg){ + var argMatches = query.matches(arg.external_name); + if (argMatches) { + matches = matches.concat(argMatches); + matchedFields.push("args"); + } + }); + } + + var docMatches = query.matches(type.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + + if (matches.length > 0) { + var typeMatches = query.matches(type.full_name); + if (typeMatches) { + matchedFields.push("type"); + matches = matches.concat(typeMatches); + } + results.push({ + id: method.html_id, + type: type.full_name, + result_type: kind, + name: method.name, + full_name: type.full_name + "#" + method.name, + args_string: method.args_string, + summary: method.summary, + href: type.path + "#" + method.html_id, + matched_fields: matchedFields, + matched_terms: matches + }); + } + } + + function searchConstant(constant, type, query, results) { + var matches = []; + var matchedFields = []; + var nameMatches = query.matches(constant.name); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + var docMatches = query.matches(constant.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + if (matches.length > 0) { + var typeMatches = query.matches(type.full_name); + if (typeMatches) { + matchedFields.push("type"); + matches = matches.concat(typeMatches); + } + results.push({ + id: constant.id, + type: type.full_name, + result_type: "constant", + name: constant.name, + full_name: type.full_name + "#" + constant.name, + value: constant.value, + summary: constant.summary, + href: type.path + "#" + constant.id, + matched_fields: matchedFields, + matched_terms: matches + }); + } + } + + var results = []; + searchType(CrystalDocs.searchIndex.program, query, results); + return results; +}; + +CrystalDocs.rankResults = function(results, query) { + function uniqueArray(ar) { + var j = {}; + + ar.forEach(function(v) { + j[v + "::" + typeof v] = v; + }); + + return Object.keys(j).map(function(v) { + return j[v]; + }); + } + + results = results.sort(function(a, b) { + var matchedTermsDiff = uniqueArray(b.matched_terms).length - uniqueArray(a.matched_terms).length; + var aHasDocs = b.matched_fields.includes("doc"); + var bHasDocs = b.matched_fields.includes("doc"); + + var aOnlyDocs = aHasDocs && a.matched_fields.length == 1; + var bOnlyDocs = bHasDocs && b.matched_fields.length == 1; + + if (a.result_type == "type" && b.result_type != "type" && !aOnlyDocs) { + if(CrystalDocs.DEBUG) { console.log("a is type b not"); } + return -1; + } else if (b.result_type == "type" && a.result_type != "type" && !bOnlyDocs) { + if(CrystalDocs.DEBUG) { console.log("b is type, a not"); } + return 1; + } + if (a.matched_fields.includes("name")) { + if (b.matched_fields.includes("name")) { + var a_name = (CrystalDocs.prefixForType(a.result_type) || "") + ((a.result_type == "type") ? a.full_name : a.name); + var b_name = (CrystalDocs.prefixForType(b.result_type) || "") + ((b.result_type == "type") ? b.full_name : b.name); + a_name = a_name.toLowerCase(); + b_name = b_name.toLowerCase(); + for(var i = 0; i < query.normalizedTerms.length; i++) { + var term = query.terms[i].replace(/^::?|::?$/, ""); + var a_orig_index = a_name.indexOf(term); + var b_orig_index = b_name.indexOf(term); + if(CrystalDocs.DEBUG) { console.log("term: " + term + " a: " + a_name + " b: " + b_name); } + if(CrystalDocs.DEBUG) { console.log(a_orig_index, b_orig_index, a_orig_index - b_orig_index); } + if (a_orig_index >= 0) { + if (b_orig_index >= 0) { + if(CrystalDocs.DEBUG) { console.log("both have exact match", a_orig_index > b_orig_index ? -1 : 1); } + if(a_orig_index != b_orig_index) { + if(CrystalDocs.DEBUG) { console.log("both have exact match at different positions", a_orig_index > b_orig_index ? 1 : -1); } + return a_orig_index > b_orig_index ? 1 : -1; + } + } else { + if(CrystalDocs.DEBUG) { console.log("a has exact match, b not"); } + return -1; + } + } else if (b_orig_index >= 0) { + if(CrystalDocs.DEBUG) { console.log("b has exact match, a not"); } + return 1; + } + } + } else { + if(CrystalDocs.DEBUG) { console.log("a has match in name, b not"); } + return -1; + } + } else if ( + !a.matched_fields.includes("name") && + b.matched_fields.includes("name") + ) { + return 1; + } + + if (matchedTermsDiff != 0 || (aHasDocs != bHasDocs)) { + if(CrystalDocs.DEBUG) { console.log("matchedTermsDiff: " + matchedTermsDiff, aHasDocs, bHasDocs); } + return matchedTermsDiff; + } + + var matchedFieldsDiff = b.matched_fields.length - a.matched_fields.length; + if (matchedFieldsDiff != 0) { + if(CrystalDocs.DEBUG) { console.log("matched to different number of fields: " + matchedFieldsDiff); } + return matchedFieldsDiff > 0 ? 1 : -1; + } + + var nameCompare = a.name.localeCompare(b.name); + if(nameCompare != 0){ + if(CrystalDocs.DEBUG) { console.log("nameCompare resulted in: " + a.name + "<=>" + b.name + ": " + nameCompare); } + return nameCompare > 0 ? 1 : -1; + } + + if(a.matched_fields.includes("args") && b.matched_fields.includes("args")) { + for(var i = 0; i < query.terms.length; i++) { + var term = query.terms[i]; + var aIndex = a.args_string.indexOf(term); + var bIndex = b.args_string.indexOf(term); + if(CrystalDocs.DEBUG) { console.log("index of " + term + " in args_string: " + aIndex + " - " + bIndex); } + if(aIndex >= 0){ + if(bIndex >= 0){ + if(aIndex != bIndex){ + return aIndex > bIndex ? 1 : -1; + } + }else{ + return -1; + } + }else if(bIndex >= 0) { + return 1; + } + } + } + + return 0; + }); + + if (results.length > 1) { + // if we have more than two search terms, only include results with the most matches + var bestMatchedTerms = uniqueArray(results[0].matched_terms).length; + + results = results.filter(function(result) { + return uniqueArray(result.matched_terms).length + 1 >= bestMatchedTerms; + }); + } + return results; +}; + +CrystalDocs.prefixForType = function(type) { + switch (type) { + case "instance_method": + return "#"; + + case "class_method": + case "macro": + case "constructor": + return "."; + + default: + return false; + } +}; + +CrystalDocs.displaySearchResults = function(results, query) { + function sanitize(html){ + return html.replace(/<(?!\/?code)[^>]+>/g, ""); + } + + // limit results + if (results.length > CrystalDocs.MAX_RESULTS_DISPLAY) { + results = results.slice(0, CrystalDocs.MAX_RESULTS_DISPLAY); + } + + var $frag = document.createDocumentFragment(); + var $resultsElem = document.querySelector(".search-list"); + $resultsElem.innerHTML = ""; + + results.forEach(function(result, i) { + var url = CrystalDocs.base_path + result.href; + var type = false; + + var title = query.highlight(result.result_type == "type" ? result.full_name : result.name); + + var prefix = CrystalDocs.prefixForType(result.result_type); + if (prefix) { + title = "" + prefix + "" + title; + } + + title = "" + title + ""; + + if (result.args_string) { + title += + "" + query.highlight(result.args_string) + ""; + } + + $elem = document.createElement("li"); + $elem.className = "search-result search-result--" + result.result_type; + $elem.dataset.href = url; + $elem.setAttribute("title", result.full_name + " docs page"); + + var $title = document.createElement("div"); + $title.setAttribute("class", "search-result__title"); + var $titleLink = document.createElement("a"); + $titleLink.setAttribute("href", url); + + $titleLink.innerHTML = title; + $title.appendChild($titleLink); + $elem.appendChild($title); + $elem.addEventListener("click", function() { + $titleLink.click(); + }); + + if (result.result_type !== "type") { + var $type = document.createElement("div"); + $type.setAttribute("class", "search-result__type"); + $type.innerHTML = query.highlight(result.type); + $elem.appendChild($type); + } + + if(result.summary){ + var $doc = document.createElement("div"); + $doc.setAttribute("class", "search-result__doc"); + $doc.innerHTML = query.highlight(sanitize(result.summary)); + $elem.appendChild($doc); + } + + $elem.appendChild(document.createComment(JSON.stringify(result))); + $frag.appendChild($elem); + }); + + $resultsElem.appendChild($frag); + + CrystalDocs.toggleResultsList(true); +}; + +CrystalDocs.toggleResultsList = function(visible) { + if (visible) { + document.querySelector(".types-list").classList.add("hidden"); + document.querySelector(".search-results").classList.remove("hidden"); + } else { + document.querySelector(".types-list").classList.remove("hidden"); + document.querySelector(".search-results").classList.add("hidden"); + } +}; + +CrystalDocs.Query = function(string) { + this.original = string; + this.terms = string.split(/\s+/).filter(function(word) { + return CrystalDocs.Query.stripModifiers(word).length > 0; + }); + + var normalized = this.terms.map(CrystalDocs.Query.normalizeTerm); + this.normalizedTerms = normalized; + + function runMatcher(field, matcher) { + if (!field) { + return false; + } + var normalizedValue = CrystalDocs.Query.normalizeTerm(field); + + var matches = []; + normalized.forEach(function(term) { + if (matcher(normalizedValue, term)) { + matches.push(term); + } + }); + return matches.length > 0 ? matches : false; + } + + this.matches = function(field) { + return runMatcher(field, function(normalized, term) { + if (term[0] == "#" || term[0] == ".") { + return false; + } + return normalized.indexOf(term) >= 0; + }); + }; + + function namespaceMatcher(normalized, term){ + var i = term.indexOf(":"); + if(i >= 0){ + term = term.replace(/^::?|::?$/, ""); + var index = normalized.indexOf(term); + if((index == 0) || (index > 0 && normalized[index-1] == ":")){ + return true; + } + } + return false; + } + this.matchesMethod = function(name, kind, type) { + return runMatcher(name, function(normalized, term) { + var i = term.indexOf("#"); + if(i >= 0){ + if (kind != "instance_method") { + return false; + } + }else{ + i = term.indexOf("."); + if(i >= 0){ + if (kind != "class_method" && kind != "macro" && kind != "constructor") { + return false; + } + }else{ + //neither # nor . + if(term.indexOf(":") && namespaceMatcher(normalized, term)){ + return true; + } + } + } + + var methodName = term; + if(i >= 0){ + var termType = term.substring(0, i); + methodName = term.substring(i+1); + + if(termType != "") { + if(CrystalDocs.Query.normalizeTerm(type.full_name).indexOf(termType) < 0){ + return false; + } + } + } + return normalized.indexOf(methodName) >= 0; + }); + }; + + this.matchesNamespace = function(namespace){ + return runMatcher(namespace, namespaceMatcher); + }; + + this.highlight = function(string) { + if (typeof string == "undefined") { + return ""; + } + function escapeRegExp(s) { + return s.replace(/[.*+?\^${}()|\[\]\\]/g, "\\$&").replace(/^[#\.:]+/, ""); + } + return string.replace( + new RegExp("(" + this.normalizedTerms.map(escapeRegExp).join("|") + ")", "gi"), + "$1" + ); + }; +}; +CrystalDocs.Query.normalizeTerm = function(term) { + return term.toLowerCase(); +}; +CrystalDocs.Query.stripModifiers = function(term) { + switch (term[0]) { + case "#": + case ".": + case ":": + return term.substr(1); + + default: + return term; + } +} + +CrystalDocs.search = function(string) { + if(!CrystalDocs.searchIndex) { + console.log("CrystalDocs search index not initialized, delaying search"); + + document.addEventListener("CrystalDocs:loaded", function listener(){ + document.removeEventListener("CrystalDocs:loaded", listener); + CrystalDocs.search(string); + }); + return; + } + + document.dispatchEvent(new Event("CrystalDocs:searchStarted")); + + var query = new CrystalDocs.Query(string); + var results = CrystalDocs.runQuery(query); + results = CrystalDocs.rankResults(results, query); + CrystalDocs.displaySearchResults(results, query); + + document.dispatchEvent(new Event("CrystalDocs:searchPerformed")); +}; + +CrystalDocs.initializeIndex = function(data) { + CrystalDocs.searchIndex = data; + + document.dispatchEvent(new Event("CrystalDocs:loaded")); +}; + +CrystalDocs.loadIndex = function() { + function loadJSON(file, callback) { + var xobj = new XMLHttpRequest(); + xobj.overrideMimeType("application/json"); + xobj.open("GET", file, true); + xobj.onreadystatechange = function() { + if (xobj.readyState == 4 && xobj.status == "200") { + callback(xobj.responseText); + } + }; + xobj.send(null); + } + + function loadScript(file) { + script = document.createElement("script"); + script.src = file; + document.body.appendChild(script); + } + + function parseJSON(json) { + CrystalDocs.initializeIndex(JSON.parse(json)); + } + + for(var i = 0; i < document.scripts.length; i++){ + var script = document.scripts[i]; + if (script.src && script.src.indexOf("js/doc.js") >= 0) { + if (script.src.indexOf("file://") == 0) { + // We need to support JSONP files for the search to work on local file system. + var jsonPath = script.src.replace("js/doc.js", "search-index.js"); + loadScript(jsonPath); + return; + } else { + var jsonPath = script.src.replace("js/doc.js", "index.json"); + loadJSON(jsonPath, parseJSON); + return; + } + } + } + console.error("Could not find location of js/doc.js"); +}; + +// Callback for jsonp +function crystal_doc_search_index_callback(data) { + CrystalDocs.initializeIndex(data); +} + +Navigator = function(sidebar, searchInput, list, leaveSearchScope){ + this.list = list; + var self = this; + + var performingSearch = false; + + document.addEventListener('CrystalDocs:searchStarted', function(){ + performingSearch = true; + }); + document.addEventListener('CrystalDocs:searchDebounceStarted', function(){ + performingSearch = true; + }); + document.addEventListener('CrystalDocs:searchPerformed', function(){ + performingSearch = false; + }); + document.addEventListener('CrystalDocs:searchDebounceStopped', function(event){ + performingSearch = false; + }); + + function delayWhileSearching(callback) { + if(performingSearch){ + document.addEventListener('CrystalDocs:searchPerformed', function listener(){ + document.removeEventListener('CrystalDocs:searchPerformed', listener); + + // add some delay to let search results display kick in + setTimeout(callback, 100); + }); + }else{ + callback(); + } + } + + function clearMoveTimeout() { + clearTimeout(self.moveTimeout); + self.moveTimeout = null; + } + + function startMoveTimeout(upwards){ + /*if(self.moveTimeout) { + clearMoveTimeout(); + } + + var go = function() { + if (!self.moveTimeout) return; + self.move(upwards); + self.moveTimeout = setTimeout(go, 600); + }; + self.moveTimeout = setTimeout(go, 800);*/ + } + + function scrollCenter(element) { + var rect = element.getBoundingClientRect(); + var middle = sidebar.clientHeight / 2; + sidebar.scrollTop += rect.top + rect.height / 2 - middle; + } + + var move = this.move = function(upwards){ + if(!this.current){ + this.highlightFirst(); + return true; + } + var next = upwards ? this.current.previousElementSibling : this.current.nextElementSibling; + if(next && next.classList) { + this.highlight(next); + scrollCenter(next); + return true; + } + return false; + }; + + this.moveRight = function(){ + }; + this.moveLeft = function(){ + }; + + this.highlight = function(elem) { + if(!elem){ + return; + } + this.removeHighlight(); + + this.current = elem; + this.current.classList.add("current"); + }; + + this.highlightFirst = function(){ + this.highlight(this.list.querySelector('li:first-child')); + }; + + this.removeHighlight = function() { + if(this.current){ + this.current.classList.remove("current"); + } + this.current = null; + } + + this.openSelectedResult = function() { + if(this.current) { + this.current.click(); + } + } + + this.focus = function() { + searchInput.focus(); + searchInput.select(); + this.highlightFirst(); + } + + function handleKeyUp(event) { + switch(event.key) { + case "ArrowUp": + case "ArrowDown": + case "i": + case "j": + case "k": + case "l": + case "c": + case "h": + case "t": + case "n": + event.stopPropagation(); + clearMoveTimeout(); + } + } + + function handleKeyDown(event) { + switch(event.key) { + case "Enter": + event.stopPropagation(); + event.preventDefault(); + leaveSearchScope(); + self.openSelectedResult(); + break; + case "Escape": + event.stopPropagation(); + event.preventDefault(); + leaveSearchScope(); + break; + case "j": + case "c": + case "ArrowUp": + if(event.ctrlKey || event.key == "ArrowUp") { + event.stopPropagation(); + self.move(true); + startMoveTimeout(true); + } + break; + case "k": + case "h": + case "ArrowDown": + if(event.ctrlKey || event.key == "ArrowDown") { + event.stopPropagation(); + self.move(false); + startMoveTimeout(false); + } + break; + case "k": + case "t": + case "ArrowLeft": + if(event.ctrlKey || event.key == "ArrowLeft") { + event.stopPropagation(); + self.moveLeft(); + } + break; + case "l": + case "n": + case "ArrowRight": + if(event.ctrlKey || event.key == "ArrowRight") { + event.stopPropagation(); + self.moveRight(); + } + break; + } + } + + function handleInputKeyUp(event) { + switch(event.key) { + case "ArrowUp": + case "ArrowDown": + event.stopPropagation(); + event.preventDefault(); + clearMoveTimeout(); + } + } + + function handleInputKeyDown(event) { + switch(event.key) { + case "Enter": + event.stopPropagation(); + event.preventDefault(); + delayWhileSearching(function(){ + self.openSelectedResult(); + leaveSearchScope(); + }); + break; + case "Escape": + event.stopPropagation(); + event.preventDefault(); + // remove focus from search input + leaveSearchScope(); + sidebar.focus(); + break; + case "ArrowUp": + event.stopPropagation(); + event.preventDefault(); + self.move(true); + startMoveTimeout(true); + break; + + case "ArrowDown": + event.stopPropagation(); + event.preventDefault(); + self.move(false); + startMoveTimeout(false); + break; + } + } + + sidebar.tabIndex = 100; // set tabIndex to enable keylistener + sidebar.addEventListener('keyup', function(event) { + handleKeyUp(event); + }); + sidebar.addEventListener('keydown', function(event) { + handleKeyDown(event); + }); + searchInput.addEventListener('keydown', function(event) { + handleInputKeyDown(event); + }); + searchInput.addEventListener('keyup', function(event) { + handleInputKeyUp(event); + }); + this.move(); +}; + +CrystalDocs.initializeVersions = function () { + function loadJSON(file, callback) { + var xobj = new XMLHttpRequest(); + xobj.overrideMimeType("application/json"); + xobj.open("GET", file, true); + xobj.onreadystatechange = function() { + if (xobj.readyState == 4 && xobj.status == "200") { + callback(xobj.responseText); + } + }; + xobj.send(null); + } + + function parseJSON(json) { + CrystalDocs.loadConfig(JSON.parse(json)); + } + + $elem = document.querySelector("html > head > meta[name=\"crystal_docs.json_config_url\"]") + if ($elem == undefined) { + return + } + jsonURL = $elem.getAttribute("content") + if (jsonURL && jsonURL != "") { + loadJSON(jsonURL, parseJSON); + } +} + +CrystalDocs.loadConfig = function (config) { + var projectVersions = config["versions"] + var currentVersion = document.querySelector("html > head > meta[name=\"crystal_docs.project_version\"]").getAttribute("content") + + var currentVersionInList = projectVersions.find(function (element) { + return element.name == currentVersion + }) + + if (!currentVersionInList) { + projectVersions.unshift({ name: currentVersion, url: '#' }) + } + + $version = document.querySelector(".project-summary > .project-version") + $version.innerHTML = "" + + $select = document.createElement("select") + $select.classList.add("project-versions-nav") + $select.addEventListener("change", function () { + window.location.href = this.value + }) + projectVersions.forEach(function (version) { + $item = document.createElement("option") + $item.setAttribute("value", version.url) + $item.append(document.createTextNode(version.name)) + + if (version.name == currentVersion) { + $item.setAttribute("selected", true) + $item.setAttribute("disabled", true) + } + $select.append($item) + }); + $form = document.createElement("form") + $form.setAttribute("autocomplete", "off") + $form.append($select) + $version.append($form) +} + +document.addEventListener("DOMContentLoaded", function () { + CrystalDocs.initializeVersions() +}) + +var UsageModal = function(title, content) { + var $body = document.body; + var self = this; + var $modalBackground = document.createElement("div"); + $modalBackground.classList.add("modal-background"); + var $usageModal = document.createElement("div"); + $usageModal.classList.add("usage-modal"); + $modalBackground.appendChild($usageModal); + var $title = document.createElement("h3"); + $title.classList.add("modal-title"); + $title.innerHTML = title + $usageModal.appendChild($title); + var $closeButton = document.createElement("span"); + $closeButton.classList.add("close-button"); + $closeButton.setAttribute("title", "Close modal"); + $closeButton.innerText = '×'; + $usageModal.appendChild($closeButton); + $usageModal.insertAdjacentHTML("beforeend", content); + + $modalBackground.addEventListener('click', function(event) { + var element = event.target || event.srcElement; + + if(element == $modalBackground) { + self.hide(); + } + }); + $closeButton.addEventListener('click', function(event) { + self.hide(); + }); + + $body.insertAdjacentElement('beforeend', $modalBackground); + + this.show = function(){ + $body.classList.add("js-modal-visible"); + }; + this.hide = function(){ + $body.classList.remove("js-modal-visible"); + }; + this.isVisible = function(){ + return $body.classList.contains("js-modal-visible"); + } +} + + +document.addEventListener('DOMContentLoaded', function() { + var sessionStorage; + try { + sessionStorage = window.sessionStorage; + } catch (e) { } + if(!sessionStorage) { + sessionStorage = { + setItem: function() {}, + getItem: function() {}, + removeItem: function() {} + }; + } + + var repositoryName = document.querySelector('[name=repository-name]').getAttribute('content'); + var typesList = document.querySelector('.types-list'); + var searchInput = document.querySelector('.search-input'); + var parents = document.querySelectorAll('.types-list li.parent'); + + var scrollSidebarToOpenType = function(){ + var openTypes = typesList.querySelectorAll('.current'); + if (openTypes.length > 0) { + var lastOpenType = openTypes[openTypes.length - 1]; + lastOpenType.scrollIntoView(!(window.matchMedia('only screen and (max-width: 635px)')).matches); + } + } + + scrollSidebarToOpenType(); + + var setPersistentSearchQuery = function(value){ + sessionStorage.setItem(repositoryName + '::search-input:value', value); + } + + for(var i = 0; i < parents.length; i++) { + var _parent = parents[i]; + _parent.addEventListener('click', function(e) { + e.stopPropagation(); + + if(e.target.tagName.toLowerCase() == 'li') { + if(e.target.className.match(/open/)) { + sessionStorage.removeItem(e.target.getAttribute('data-id')); + e.target.className = e.target.className.replace(/ +open/g, ''); + } else { + sessionStorage.setItem(e.target.getAttribute('data-id'), '1'); + if(e.target.className.indexOf('open') == -1) { + e.target.className += ' open'; + } + } + } + }); + + if(sessionStorage.getItem(_parent.getAttribute('data-id')) == '1') { + _parent.className += ' open'; + } + } + + var leaveSearchScope = function(){ + CrystalDocs.toggleResultsList(false); + window.focus(); + } + + var navigator = new Navigator(document.querySelector('.types-list'), searchInput, document.querySelector(".search-results"), leaveSearchScope); + + CrystalDocs.loadIndex(); + var searchTimeout; + var lastSearchText = false; + var performSearch = function() { + document.dispatchEvent(new Event("CrystalDocs:searchDebounceStarted")); + + clearTimeout(searchTimeout); + searchTimeout = setTimeout(function() { + var text = searchInput.value; + + if(text == "") { + CrystalDocs.toggleResultsList(false); + }else if(text == lastSearchText){ + document.dispatchEvent(new Event("CrystalDocs:searchDebounceStopped")); + }else{ + CrystalDocs.search(text); + navigator.highlightFirst(); + searchInput.focus(); + } + lastSearchText = text; + setPersistentSearchQuery(text); + }, 200); + }; + + if(location.hash.length > 3 && location.hash.substring(0,3) == "#q="){ + // allows directly linking a search query which is then executed on the client + // this comes handy for establishing a custom browser search engine with https://crystal-lang.org/api/#q=%s as a search URL + // TODO: Add OpenSearch description + var searchQuery = location.hash.substring(3); + history.pushState({searchQuery: searchQuery}, "Search for " + searchQuery, location.href.replace(/#q=.*/, "")); + searchInput.value = decodeURIComponent(searchQuery); + document.addEventListener('CrystalDocs:loaded', performSearch); + } + + if (searchInput.value.length == 0) { + var searchText = sessionStorage.getItem(repositoryName + '::search-input:value'); + if(searchText){ + searchInput.value = searchText; + } + } + searchInput.addEventListener('keyup', performSearch); + searchInput.addEventListener('input', performSearch); + + var usageModal = new UsageModal('Keyboard Shortcuts', '' + + '' + ); + + function handleShortkeys(event) { + var element = event.target || event.srcElement; + + if(element.tagName == "INPUT" || element.tagName == "TEXTAREA" || element.parentElement.tagName == "TEXTAREA"){ + return; + } + + switch(event.key) { + case "?": + usageModal.show(); + break; + + case "Escape": + usageModal.hide(); + break; + + case "s": + case "/": + if(usageModal.isVisible()) { + return; + } + event.stopPropagation(); + navigator.focus(); + performSearch(); + break; + } + } + + document.addEventListener('keyup', handleShortkeys); + + var scrollToEntryFromLocationHash = function() { + var hash = window.location.hash; + if (hash) { + var targetAnchor = decodeURI(hash.substr(1)); + var targetEl = document.getElementById(targetAnchor) + if (targetEl) { + targetEl.offsetParent.scrollTop = targetEl.offsetTop; + } + } + }; + window.addEventListener("hashchange", scrollToEntryFromLocationHash, false); + scrollToEntryFromLocationHash(); +}); diff --git a/docs/search-index.js b/docs/search-index.js new file mode 100644 index 0000000..62a7e8e --- /dev/null +++ b/docs/search-index.js @@ -0,0 +1 @@ +crystal_doc_search_index_callback({"repository_name":"anthropic","body":"# anthropic\n\nClient for the Anthropic API. Supports tool use and running those tools automatically.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n anthropic:\n github: jgaskins/anthropic\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"anthropic\"\n```\n\nThe main entrypoint is via the `Anthropic::Client`. You can instantiate it explicitly with an API key:\n\n```crystal\nclaude = Anthropic::Client.new(\"sk-and-api-03-asdfasdfasdf\")\n```\n\nOr you can omit the API key to automatically read it from the `ANTHROPIC_API_KEY` environment variable:\n\n```crystal\nclaude = Anthropic::Client.new\n```\n\nNext, use the `Anthropic::Messages#create` method to send your prompt:\n\n```crystal\nresponse = claude.messages.create(\n # Pass a string representing the model name, or retrieve the full model\n # name via the shorthand with Anthropic.model_name.\n model: Anthropic.model_name(:sonnet),\n\n # Define a system prompt if you want to give the AI a persona to use or some\n # instructions on how to respond to the prompt.\n system: \"You are an expert in the Crystal programming language\",\n\n # You can pass the full list of messages, including messages it gave you\n # back.\n messages: [\n Anthropic::Message.new(\"What makes Crystal the best programming language?\")\n ],\n\n # The maximum number of tokens the AI will try to respond with. Keep this low\n # if you're feeding untrusted prompts.\n max_tokens: 4096,\n\n # A floating-point value between 0.0 and 1.0 representing how creative the\n # response should be. Lower values (closer to 0.0) will be more deterministic\n # and should be used for analytical prompts. Higher values (closer to 1.0)\n # will be more stochastic.\n temperature: 0.5,\n\n # You can optionally pass an `Array` of tools to give the client a way to run\n # custom code in your app. See below for additional information on how to\n # define those. The more tools you pass in with a request, the more tokens the\n # request will use, so you should keep this to a reasonable size.\n #\n # By default, no tools are included.\n tools: [\n GitHubUserLookup,\n GoogleDriveSearch.new(google_oauth_token),\n ],\n\n # Uncomment the following line to avoid automatically running the tool\n # selected by the model.\n # run_tools: false,\n\n # Limit the token selection to the \"top k\" tokens. If you need this\n # explanation, chances are you should use `temperature` instead. That's not a\n # dig — I've never used it myself.\n # top_k: 10,\n\n # P value for nucleus sampling. If you're dialing in your prompts with the\n # `temperature` argument, you should ignore this one. I've never used this\n # one, either.\n # top_p: 0.1234,\n)\n```\n\nYou can also pass images to the model:\n\n```crystal\nputs claude\n .messages\n .create(\n # You should generally use the Haiku model when dealing with images since\n # they tend to consume quite a few tokens.\n model: Anthropic.model_name(:haiku),\n messages: [\n Anthropic::Message.new(\n content: Array(Anthropic::MessageContent){\n # Images are base64-encoded and sent to the model\n Anthropic::Image.base64(:jpeg, File.read(\"/path/to/image.jpeg\")),\n Anthropic::Text.new(\"Describe this image\"),\n },\n ),\n ],\n max_tokens: 4096,\n # Using a more deterministic response about the image\n temperature: 0.1,\n )\n```\n\n### Defining tools\n\nTools are objects that the Anthropic models can use to invoke your code. You\ncan define them easily with a `struct` that inherits from\n`Anthropic::Tool::Handler`.\n\n```crystal\nstruct GitHubUserLookup < Anthropic::Tool::Handler\n # Define any properties required for this tool as getters. Claude will\n # provide them if it can based on the user's question.\n\n # The username/login for the GitHub user, used to fetch the user from the\n # GitHub API.\n getter username : String\n\n # This is the description that lets the model know when and how to use your\n # code. It's basically the documentation the model will use. The more\n # descriptive this is, the more confidence the model will have in invoking\n # it, but it does consume tokens.\n def self.description\n <<-EOF\n Retrieves the GitHub user with the given username. The username may also\n be referred to as a \"login\". The username can only contain letters,\n numbers, underscores, and dashes.\n\n The tool will return the current data about the GitHub user with that\n username. It should be used when the user asks about that particular\n GitHub user. It will not provide information about GitHub repositories\n or any issues, pull requests, commits, or other content on GitHub created\n by that GitHub user.\n EOF\n end\n\n # This is the method the client will use to invoke this tool. The return value\n # of this method will be serialized as JSON and sent over the wire as the\n # tool-use result\n def call\n User.from_json HTTP::Client.get(URI.parse(\"https://api.github.com/users/#{username}\")).body\n end\n\n # The definition for the value we want to send back to the model. Every\n # property specified here will consume tokens, so only define getters that\n # will provide useful context to the model.\n struct User\n include JSON::Serializable\n\n getter login : String\n getter name : String\n getter company : String?\n getter location : String\n getter bio : String?\n getter public_repos : Int64\n getter public_gists : Int64\n getter followers : Int64\n getter following : Int64\n end\nend\n```\n\nYou can also define tools without inheriting from `Anthropic::Tool::Handler`. That type simply implements the following API on the tool object (instance or type) being passed in:\n\n- `name : String`\n- `description : String`\n- `json_schema`, which returns a `to_json`-able object\n- `parse`, which returns a `call`-able object which returns a `to_json`-able object\n\nHere is an example of a tool that searches a user's Google Drive (via the [`jgaskins/google`](https://github.com/jgaskins/google) shard) using the provided query. Claude will generate the query and pass it to the tool, \n\n```crystal\nrequire \"google\"\nrequire \"google/drive\"\n\nrecord GoogleDriveSearch, token : String do\n GOOGLE = Google::Client.new(\n client_id: ENV[\"GOOGLE_CLIENT_ID\"],\n client_secret: ENV[\"GOOGLE_CLIENT_SECRET\"],\n redirect_uri: URI.parse(\"https://example.com/oauth2/google\"),\n )\n\n def description\n \"Search Google for a user's documents with the given search query. You must use the Google Drive API query string format.\"\n end\n\n def name\n \"GoogleDriveSearch\"\n end\n\n def json_schema\n # The `json_schema` class method is provided on all `JSON::Serializable`\n # types by the `spider-gazelle/json-schema` shard.\n Query.json_schema\n end\n\n def parse(json : String)\n query = Query.from_json json\n query.search = self\n query\n end\n\n def call(query : String)\n files = GOOGLE\n .drive\n .files\n .list(\n token: token,\n q: \"(#{query}) and mimeType contains 'application/vnd.google-apps'\",\n limit: 10,\n )\n .to_a\n\n array = Array(FileInfo).new(files.size)\n # Requires this PR to be released, or the equivalent monkeypatch:\n # https://github.com/crystal-lang/crystal/pull/14837\n WaitGroup.wait do |wg|\n mutex = Mutex.new\n files.each do |file|\n wg.spawn do\n file_info = FileInfo.new(\n id: file.id,\n name: file.name,\n content: GOOGLE.drive.files.export(file, \"text/plain\", token, &.gets_to_end),\n link: file.web_view_link,\n )\n\n mutex.synchronize do\n array << file_info\n end\n end\n end\n end\n\n array\n end\n\n struct FileInfo\n include JSON::Serializable\n\n getter id : String\n getter name : String\n getter content : String\n getter link : String\n\n def initialize(@id, @name, @content, @link)\n end\n end\n\n struct Query\n include JSON::Serializable\n\n getter query : String\n @[JSON::Field(ignore: true)]\n protected property! search : GoogleDriveSearch\n\n def call\n search.call(query)\n end\n end\nend\n```\n\nSee the example code above to find out how to pass them to the model.\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Jamie Gaskins](https://github.com/jgaskins) - creator and maintainer\n","program":{"html_id":"anthropic/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"anthropic","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"anthropic/Anthropic","path":"Anthropic.html","kind":"module","full_name":"Anthropic","name":"Anthropic","abstract":false,"locations":[{"filename":"src/api.cr","line_number":3,"url":null},{"filename":"src/error.cr","line_number":1,"url":null},{"filename":"src/event_source.cr","line_number":6,"url":null},{"filename":"src/message_content.cr","line_number":5,"url":null},{"filename":"src/messages.cr","line_number":5,"url":null},{"filename":"src/model.cr","line_number":1,"url":null},{"filename":"src/resource.cr","line_number":3,"url":null},{"filename":"src/tool.cr","line_number":3,"url":null},{"filename":"src/version.cr","line_number":1,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\""}],"class_methods":[{"html_id":"model_name(model:Model)-class-method","name":"model_name","abstract":false,"args":[{"name":"model","external_name":"model","restriction":"Model"}],"args_string":"(model : Model)","args_html":"(model : Model)","location":{"filename":"src/model.cr","line_number":9,"url":null},"def":{"name":"model_name","args":[{"name":"model","external_name":"model","restriction":"Model"}],"visibility":"Public","body":"MODELS[model]"}},{"html_id":"tool(input_type,description:String|Nil=input_type.description,*,name:String=input_type.name):Tool-class-method","name":"tool","abstract":false,"args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"args_string":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","args_html":"(input_type, description : String | Nil = input_type.description, *, name : String = input_type.name) : Tool","location":{"filename":"src/tool.cr","line_number":16,"url":null},"def":{"name":"tool","args":[{"name":"input_type","external_name":"input_type","restriction":""},{"name":"description","default_value":"input_type.description","external_name":"description","restriction":"String | ::Nil"},{"name":"","external_name":"","restriction":""},{"name":"name","default_value":"input_type.name","external_name":"name","restriction":"String"}],"splat_index":2,"return_type":"Tool","visibility":"Public","body":"Tool.new(name: name, description: description, input_type: input_type)"}},{"html_id":"tools(array:Array(Tool))-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"args_string":"(array : Array(Tool))","args_html":"(array : Array(Tool))","location":{"filename":"src/tool.cr","line_number":8,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Array(Tool)"}],"visibility":"Public","body":"array"}},{"html_id":"tools(array:Enumerable)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"args_string":"(array : Enumerable)","args_html":"(array : Enumerable)","location":{"filename":"src/tool.cr","line_number":4,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Enumerable"}],"visibility":"Public","body":"array.map do |handler|\n tool(handler)\nend"}},{"html_id":"tools(array:Nil)-class-method","name":"tools","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Nil"}],"args_string":"(array : Nil)","args_html":"(array : Nil)","location":{"filename":"src/tool.cr","line_number":12,"url":null},"def":{"name":"tools","args":[{"name":"array","external_name":"array","restriction":"Nil"}],"visibility":"Public","body":"[] of Tool(Tool::Handler.class)"}}],"types":[{"html_id":"anthropic/Anthropic/Client","path":"Anthropic/Client.html","kind":"class","full_name":"Anthropic::Client","name":"Client","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/client.cr","line_number":27,"url":null},{"filename":"src/messages.cr","line_number":188,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"doc":"The `Anthropic::Client` is the entrypoint for using the Anthropic API in\nCrystal.\n\n```\nclaude = Anthropic::Client.new # get API key from the ENV\nputs claude.messages.create(\n model: Anthropic.model_name(:haiku),\n messages: [Anthropic::Message.new(\"Write a haiku about the Crystal programming language\")],\n max_tokens: 4096,\n)\n# Sparkling Crystal code,\n# Elegant and swift syntax,\n# Shines with precision.\n```\n\nThe client is concurrency-safe, so you don't need to wrap requests in a mutex\nor manage a connection pool yourself.","summary":"

The Anthropic::Client is the entrypoint for using the Anthropic API in Crystal.

","constructors":[{"html_id":"new(api_key:String=ENV[\"ANTHROPIC_API_KEY\"],base_uri:URI=URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\",\"https://api.anthropic.com\")),log:Log=Log.for(self.class))-class-method","name":"new","doc":"Instantiate a new client with the API key provided either directly or via\nthe `ANTHROPIC_API_KEY` environment variable. You can optionally provide a\nbase URI to connect to if you are using a different but compatible API\nprovider.","summary":"

Instantiate a new client with the API key provided either directly or via the ANTHROPIC_API_KEY environment variable.

","abstract":false,"args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"args_string":"(api_key : String = ENV[\"ANTHROPIC_API_KEY\"], base_uri : URI = URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\")), log : Log = Log.for(self.class))","args_html":"(api_key : String = ENV["ANTHROPIC_API_KEY"], base_uri : URI = URI.parse(ENV.fetch("ANTHROPIC_BASE_URL", "https://api.anthropic.com")), log : Log = Log.for(self.class))","location":{"filename":"src/client.cr","line_number":35,"url":null},"def":{"name":"new","args":[{"name":"api_key","default_value":"ENV[\"ANTHROPIC_API_KEY\"]","external_name":"api_key","restriction":"::String"},{"name":"base_uri","default_value":"URI.parse(ENV.fetch(\"ANTHROPIC_BASE_URL\", \"https://api.anthropic.com\"))","external_name":"base_uri","restriction":"::URI"},{"name":"log","default_value":"Log.for(self.class)","external_name":"log","restriction":"::Log"}],"visibility":"Public","body":"_ = allocate\n_.initialize(api_key, base_uri, log)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"api_key:String-instance-method","name":"api_key","abstract":false,"location":{"filename":"src/client.cr","line_number":28,"url":null},"def":{"name":"api_key","return_type":"String","visibility":"Public","body":"@api_key"}},{"html_id":"base_uri:URI-instance-method","name":"base_uri","abstract":false,"location":{"filename":"src/client.cr","line_number":29,"url":null},"def":{"name":"base_uri","return_type":"URI","visibility":"Public","body":"@base_uri"}},{"html_id":"messages-instance-method","name":"messages","abstract":false,"location":{"filename":"src/messages.cr","line_number":189,"url":null},"def":{"name":"messages","visibility":"Public","body":"Messages.new(self)"}}]},{"html_id":"anthropic/Anthropic/ContentBlockDelta","path":"Anthropic/ContentBlockDelta.html","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":114,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"delta:TextDelta-instance-method","name":"delta","abstract":false,"location":{"filename":"src/event_source.cr","line_number":116,"url":null},"def":{"name":"delta","return_type":"TextDelta","visibility":"Public","body":"@delta"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":115,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}]},{"html_id":"anthropic/Anthropic/ContentBlockStart","path":"Anthropic/ContentBlockStart.html","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":118,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content_block:ContentBlock|Nil-instance-method","name":"content_block","abstract":false,"location":{"filename":"src/event_source.cr","line_number":120,"url":null},"def":{"name":"content_block","return_type":"ContentBlock | ::Nil","visibility":"Public","body":"@content_block"}},{"html_id":"index:Int64-instance-method","name":"index","abstract":false,"location":{"filename":"src/event_source.cr","line_number":119,"url":null},"def":{"name":"index","return_type":"Int64","visibility":"Public","body":"@index"}}],"types":[{"html_id":"anthropic/Anthropic/ContentBlockStart/ContentBlock","path":"Anthropic/ContentBlockStart/ContentBlock.html","kind":"struct","full_name":"Anthropic::ContentBlockStart::ContentBlock","name":"ContentBlock","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":121,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":126,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any|Nil-instance-method","name":"input","abstract":false,"location":{"filename":"src/event_source.cr","line_number":128,"url":null},"def":{"name":"input","return_type":"JSON::Any | ::Nil","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/event_source.cr","line_number":127,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}},{"html_id":"type:GeneratedMessage::Content::Type|Nil-instance-method","name":"type","abstract":false,"location":{"filename":"src/event_source.cr","line_number":124,"url":null},"def":{"name":"type","return_type":"GeneratedMessage::Content::Type | ::Nil","visibility":"Public","body":"@type"}}]}]},{"html_id":"anthropic/Anthropic/ContentBlockStop","path":"Anthropic/ContentBlockStop.html","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":131,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Error","path":"Anthropic/Error.html","kind":"class","full_name":"Anthropic::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":2,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/Error/APIError","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError"},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError"},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError"},{"html_id":"anthropic/Anthropic/Error/NotFoundError","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError"},{"html_id":"anthropic/Anthropic/Error/OverloadedError","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError"},{"html_id":"anthropic/Anthropic/Error/PermissionError","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError"},{"html_id":"anthropic/Anthropic/Error/RateLimitError","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"from_response_body(body:String)-class-method","name":"from_response_body","abstract":false,"args":[{"name":"body","external_name":"body","restriction":"String"}],"args_string":"(body : String)","args_html":"(body : String)","location":{"filename":"src/error.cr","line_number":3,"url":null},"def":{"name":"from_response_body","args":[{"name":"body","external_name":"body","restriction":"String"}],"visibility":"Public","body":"response = Response.from_json(body)\nTYPE_MAP[response.error.type].new(response.error.message)\n"}}],"constructors":[{"html_id":"new(message:String)-class-method","name":"new","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"}],"args_string":"(message : String)","args_html":"(message : String)","location":{"filename":"src/error.cr","line_number":8,"url":null},"def":{"name":"new","args":[{"name":"message","external_name":"message","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(message)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"types":[{"html_id":"anthropic/Anthropic/Error/APIError","path":"Anthropic/Error/APIError.html","kind":"class","full_name":"Anthropic::Error::APIError","name":"APIError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":50,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/AuthenticationError","path":"Anthropic/Error/AuthenticationError.html","kind":"class","full_name":"Anthropic::Error::AuthenticationError","name":"AuthenticationError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":38,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/InvalidRequestError","path":"Anthropic/Error/InvalidRequestError.html","kind":"class","full_name":"Anthropic::Error::InvalidRequestError","name":"InvalidRequestError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":35,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/NotFoundError","path":"Anthropic/Error/NotFoundError.html","kind":"class","full_name":"Anthropic::Error::NotFoundError","name":"NotFoundError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":44,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/OverloadedError","path":"Anthropic/Error/OverloadedError.html","kind":"class","full_name":"Anthropic::Error::OverloadedError","name":"OverloadedError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":53,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/PermissionError","path":"Anthropic/Error/PermissionError.html","kind":"class","full_name":"Anthropic::Error::PermissionError","name":"PermissionError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":41,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/RateLimitError","path":"Anthropic/Error/RateLimitError.html","kind":"class","full_name":"Anthropic::Error::RateLimitError","name":"RateLimitError","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"ancestors":[{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},{"html_id":"anthropic/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":47,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"}},{"html_id":"anthropic/Anthropic/Error/Response","path":"Anthropic/Error/Response.html","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":56,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error","kind":"class","full_name":"Anthropic::Error","name":"Error"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"error:Error-instance-method","name":"error","abstract":false,"location":{"filename":"src/error.cr","line_number":60,"url":null},"def":{"name":"error","return_type":"Error","visibility":"Public","body":"@error"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":59,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Error/Response/Error","path":"Anthropic/Error/Response/Error.html","kind":"struct","full_name":"Anthropic::Error::Response::Error","name":"Error","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/error.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Error/Response","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"message:String-instance-method","name":"message","abstract":false,"location":{"filename":"src/error.cr","line_number":66,"url":null},"def":{"name":"message","return_type":"String","visibility":"Public","body":"@message"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/error.cr","line_number":65,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]}]}]},{"html_id":"anthropic/Anthropic/Event","path":"Anthropic/Event.html","kind":"struct","full_name":"Anthropic::Event","name":"Event","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":99,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/ContentBlockDelta","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta"},{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},{"html_id":"anthropic/Anthropic/ContentBlockStop","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop"},{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},{"html_id":"anthropic/Anthropic/MessageStart","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart"},{"html_id":"anthropic/Anthropic/MessageStop","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop"},{"html_id":"anthropic/Anthropic/MessageStream","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream"},{"html_id":"anthropic/Anthropic/Ping","kind":"struct","full_name":"Anthropic::Ping","name":"Ping"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"new","visibility":"Public","body":"x = allocate\nif x.responds_to?(:finalize)\n ::GC.add_finalizer(x)\nend\nx\n"}}],"instance_methods":[{"html_id":"initialize-instance-method","name":"initialize","abstract":false,"location":{"filename":"src/event_source.cr","line_number":99,"url":null},"def":{"name":"initialize","visibility":"Public","body":""}}],"macros":[{"html_id":"define(type)-macro","name":"define","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""}],"args_string":"(type)","args_html":"(type)","location":{"filename":"src/event_source.cr","line_number":103,"url":null},"def":{"name":"define","args":[{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":" struct \n{{ type }}\n < ::Anthropic::Event\n include Resource\n\n Event::TYPE_MAP[\n{{ type.stringify.underscore }}\n] = \n{{ type }}\n\n \n \n{{ yield }}\n\n \nend\n \n"}}]},{"html_id":"anthropic/Anthropic/EventMessage","path":"Anthropic/EventMessage.html","kind":"struct","full_name":"Anthropic::EventMessage","name":"EventMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":93,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(data:Array(String),event:String|Nil=nil,id:String|Nil=nil,retry:Int64|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"args_string":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","args_html":"(data : Array(String), event : String | Nil = nil, id : String | Nil = nil, retry : Int64 | Nil = nil)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"new","args":[{"name":"data","external_name":"data","restriction":"Array(String)"},{"name":"event","default_value":"nil","external_name":"event","restriction":"String | ::Nil"},{"name":"id","default_value":"nil","external_name":"id","restriction":"String | ::Nil"},{"name":"retry","default_value":"nil","external_name":"retry","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(data, event, id, retry)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@data.clone, @event.clone, @id.clone, @retry.clone)"}},{"html_id":"copy_with(data_data=@data,event_event=@event,id_id=@id,retry_retry=@retry)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"args_string":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","args_html":"(data _data = @data, event _event = @event, id _id = @id, retry _retry = @retry)","location":{"filename":"src/event_source.cr","line_number":93,"url":null},"def":{"name":"copy_with","args":[{"name":"_data","default_value":"@data","external_name":"data","restriction":""},{"name":"_event","default_value":"@event","external_name":"event","restriction":""},{"name":"_id","default_value":"@id","external_name":"id","restriction":""},{"name":"_retry","default_value":"@retry","external_name":"retry","restriction":""}],"visibility":"Public","body":"self.class.new(_data, _event, _id, _retry)"}},{"html_id":"data:Array(String)-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"Array(String)","visibility":"Public","body":"@data"}},{"html_id":"event:String|Nil-instance-method","name":"event","abstract":false,"def":{"name":"event","return_type":"String | ::Nil","visibility":"Public","body":"@event"}},{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"retry:Int64|Nil-instance-method","name":"retry","abstract":false,"def":{"name":"retry","return_type":"Int64 | ::Nil","visibility":"Public","body":"@retry"}}]},{"html_id":"anthropic/Anthropic/EventSource","path":"Anthropic/EventSource.html","kind":"class","full_name":"Anthropic::EventSource","name":"EventSource","abstract":false,"superclass":{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"anthropic/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":7,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(response:HTTP::Client::Response,last_id:Nil|String=nil)-class-method","name":"new","abstract":false,"args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"args_string":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","args_html":"(response : HTTP::Client::Response, last_id : Nil | String = nil)","location":{"filename":"src/event_source.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"response","external_name":"response","restriction":"::HTTP::Client::Response"},{"name":"last_id","default_value":"nil","external_name":"last_id","restriction":"::Nil | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(response, last_id)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"last_id:String|Nil-instance-method","name":"last_id","abstract":false,"location":{"filename":"src/event_source.cr","line_number":9,"url":null},"def":{"name":"last_id","return_type":"String | ::Nil","visibility":"Public","body":"@last_id"}},{"html_id":"on_error(&on_error:NamedTuple(status_code:Int32,message:String)->):self-instance-method","name":"on_error","abstract":false,"location":{"filename":"src/event_source.cr","line_number":18,"url":null},"def":{"name":"on_error","yields":1,"block_arity":1,"block_arg":{"name":"on_error","external_name":"on_error","restriction":"(NamedTuple(status_code: Int32, message: String) ->)"},"return_type":"self","visibility":"Public","body":"@on_error = on_error\nself\n"}},{"html_id":"on_message(&on_message:EventMessage,self->):self-instance-method","name":"on_message","abstract":false,"location":{"filename":"src/event_source.cr","line_number":14,"url":null},"def":{"name":"on_message","yields":2,"block_arity":2,"block_arg":{"name":"on_message","external_name":"on_message","restriction":"(EventMessage, self ->)"},"return_type":"self","visibility":"Public","body":"@on_message = on_message\nself\n"}},{"html_id":"response:HTTP::Client::Response-instance-method","name":"response","abstract":false,"location":{"filename":"src/event_source.cr","line_number":8,"url":null},"def":{"name":"response","return_type":"HTTP::Client::Response","visibility":"Public","body":"@response"}},{"html_id":"run:Nil-instance-method","name":"run","abstract":false,"location":{"filename":"src/event_source.cr","line_number":26,"url":null},"def":{"name":"run","return_type":"Nil","visibility":"Public","body":"lines = [] of String\nio = response.body_io\nlast_message = nil\nloop do\n if @abort\n break\n end\n if line = io.gets\n else\n break\n end\n if line.empty? && (!lines.empty?)\n last_message = parse_event_message(lines)\n last_message.id.try do |id|\n @last_id = id\n end\n @on_message.try(&.call(last_message, self))\n lines.clear\n else\n lines << line\n end\nend\nif last_message\n if last_message.id.try(&.empty?) && @abort\n last_message.retry.try do |retry_after|\n sleep(retry_after / 1000)\n end\n end\nend\n"}},{"html_id":"stop:Nil-instance-method","name":"stop","abstract":false,"location":{"filename":"src/event_source.cr","line_number":22,"url":null},"def":{"name":"stop","return_type":"Nil","visibility":"Public","body":"@abort = true"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage","path":"Anthropic/GeneratedMessage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"content:Array(MessageContent)-instance-method","name":"content","doc":"This is an array of content blocks, each of which has a `type` that determines\nits shape. Currently, the only `type` in responses is `\"text\"`.\n\nExample:\n\n```json\n[{ \"type\": \"text\", \"text\": \"Hi, I'm Claude.\" }]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the\nresponse `content` will continue directly from that last turn. You can use this\nto constrain the model's output.\n\nFor example, if the input `messages` were:\n\n```json\n[\n {\n \"role\": \"user\",\n \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"\n },\n { \"role\": \"assistant\", \"content\": \"The best answer is (\" }\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{ \"type\": \"text\", \"text\": \"B)\" }]\n```","summary":"

This is an array of content blocks, each of which has a #type that determines its shape.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":43,"url":null},"def":{"name":"content","return_type":"Array(MessageContent)","visibility":"Public","body":"if (value = @content).nil?\n @content = ([] of MessageContent)\nelse\n value\nend"}},{"html_id":"id:String-instance-method","name":"id","doc":"Unique object identifier.\n\nThe format and length of IDs may change over time.","summary":"

Unique object identifier.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":12,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"message_thread:Array(Message)-instance-method","name":"message_thread","doc":"Messages that were passed to the","summary":"

Messages that were passed to the

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":59,"url":null},"def":{"name":"message_thread","return_type":"Array(Message)","visibility":"Public","body":"if (value = @message_thread).nil?\n @message_thread = ([to_message])\nelse\n value\nend"}},{"html_id":"model:String-instance-method","name":"model","doc":"The model that handled the request.","summary":"

The model that handled the request.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":52,"url":null},"def":{"name":"model","return_type":"String","visibility":"Public","body":"@model"}},{"html_id":"role:Message::Role-instance-method","name":"role","doc":"Conversational role of the generated message. This will always be `:assistant`.","summary":"

Conversational role of the generated message.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":49,"url":null},"def":{"name":"role","return_type":"Message::Role","visibility":"Public","body":"@role"}},{"html_id":"stop_reason:StopReason|Nil-instance-method","name":"stop_reason","doc":"The reason that we stopped. This may be one the following values:\n\n- `:end_turn`: the model reached a natural stopping point\n- `:max_tokens`: we exceeded the requested `max_tokens` or the model's maximum\n- `:stop_sequence`: one of your provided custom `stop_sequences` was generated\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is\n`nil` in the `MessageStart` event and non-`nil` otherwise.","summary":"

The reason that we stopped.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":85,"url":null},"def":{"name":"stop_reason","return_type":"StopReason | ::Nil","visibility":"Public","body":"@stop_reason"}},{"html_id":"stop_sequence:String|Nil-instance-method","name":"stop_sequence","doc":"Which custom stop sequence was generated, if any. This value will be a non-\n`nil` string if one of your custom stop sequences was generated.","summary":"

Which custom stop sequence was generated, if any.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":56,"url":null},"def":{"name":"stop_sequence","return_type":"String | ::Nil","visibility":"Public","body":"@stop_sequence"}},{"html_id":"to_message-instance-method","name":"to_message","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":87,"url":null},"def":{"name":"to_message","visibility":"Public","body":"Message.new(role: role, content: content)"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":94,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"content.each do |item|\n io.puts(item)\nend"}},{"html_id":"type:String-instance-method","name":"type","doc":"Object type — for `Message`s, this is always `\"message\"`.","summary":"

Object type — for Messages, this is always "message".

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":46,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}},{"html_id":"usage:Usage-instance-method","name":"usage","doc":"Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the\nunderlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the\nmodel. The model's output then goes through a parsing stage before becoming an\nAPI response. As a result, the token counts in `usage` will not match one-to-one\nwith the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response\nfrom Claude.","summary":"

Billing and rate-limit usage.

","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":75,"url":null},"def":{"name":"usage","return_type":"Usage","visibility":"Public","body":"@usage"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","path":"Anthropic/GeneratedMessage/Content.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":100,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"subclasses":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text"},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":105,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"location = pull.location\ndiscriminator_value = nil\njson = String.build do |io|\n JSON.build(io) do |builder|\n builder.start_object\n pull.read_object do |key|\n if key == \"type\"\n value_kind = pull.kind\n case value_kind\n when .string?\n discriminator_value = pull.string_value\n when .int?\n discriminator_value = pull.int_value\n when .bool?\n discriminator_value = pull.bool_value\n else\n raise(::JSON::SerializableError.new(\"JSON discriminator field 'type' has an invalid value type of #{value_kind.to_s}\", to_s, nil, *location, nil))\n end\n builder.field(key, discriminator_value)\n pull.read_next\n else\n builder.field(key) do\n pull.read_raw(builder)\n end\n end\n end\n builder.end_object\n end\nend\nif discriminator_value.nil?\n raise(::JSON::SerializableError.new(\"Missing JSON discriminator field 'type'\", to_s, nil, *location, nil))\nend\ncase discriminator_value\nwhen \"text\"\n Text.from_json(json)\nwhen \"tool_use\"\n ToolUse.from_json(json)\nelse\n raise(::JSON::SerializableError.new(\"Unknown 'type' discriminator value: #{discriminator_value.inspect}\", to_s, nil, *location, nil))\nend\n"}}],"instance_methods":[{"html_id":"type:Type-instance-method","name":"type","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":103,"url":null},"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content/Type","path":"Anthropic/GeneratedMessage/Content/Type.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::Content::Type","name":"Type","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":110,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Text","name":"Text","value":"0"},{"id":"ToolUse","name":"ToolUse","value":"1"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"instance_methods":[{"html_id":"text?-instance-method","name":"text?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":111,"url":null},"def":{"name":"text?","visibility":"Public","body":"self == Text"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":112,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/StopReason","path":"Anthropic/GeneratedMessage/StopReason.html","kind":"enum","full_name":"Anthropic::GeneratedMessage::StopReason","name":"StopReason","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":159,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"EndTurn","name":"EndTurn","value":"0"},{"id":"MaxTokens","name":"MaxTokens","value":"1"},{"id":"StopSequence","name":"StopSequence","value":"2"},{"id":"ToolUse","name":"ToolUse","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"instance_methods":[{"html_id":"end_turn?-instance-method","name":"end_turn?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":160,"url":null},"def":{"name":"end_turn?","visibility":"Public","body":"self == EndTurn"}},{"html_id":"max_tokens?-instance-method","name":"max_tokens?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":161,"url":null},"def":{"name":"max_tokens?","visibility":"Public","body":"self == MaxTokens"}},{"html_id":"stop_sequence?-instance-method","name":"stop_sequence?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":162,"url":null},"def":{"name":"stop_sequence?","visibility":"Public","body":"self == StopSequence"}},{"html_id":"tool_use?-instance-method","name":"tool_use?","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":163,"url":null},"def":{"name":"tool_use?","visibility":"Public","body":"self == ToolUse"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Text","path":"Anthropic/GeneratedMessage/Text.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Text","name":"Text","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":116,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":116,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"text:String|Nil-instance-method","name":"text","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":117,"url":null},"def":{"name":"text","return_type":"String | ::Nil","visibility":"Public","body":"@text"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/generated_message.cr","line_number":119,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"if text = @text\n io.puts(text)\nend"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","path":"Anthropic/GeneratedMessage/ToolUse.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},"ancestors":[{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":126,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":126,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"id:String|Nil-instance-method","name":"id","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":127,"url":null},"def":{"name":"id","return_type":"String | ::Nil","visibility":"Public","body":"@id"}},{"html_id":"input:JSON::Any-instance-method","name":"input","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":130,"url":null},"def":{"name":"input","return_type":"JSON::Any","visibility":"Public","body":"@input"}},{"html_id":"name:String|Nil-instance-method","name":"name","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":128,"url":null},"def":{"name":"name","return_type":"String | ::Nil","visibility":"Public","body":"@name"}}],"types":[{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/PossibleSchema","path":"Anthropic/GeneratedMessage/ToolUse/PossibleSchema.html","kind":"module","full_name":"Anthropic::GeneratedMessage::ToolUse::PossibleSchema","name":"PossibleSchema","abstract":false,"locations":[{"filename":"src/generated_message.cr","line_number":132,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"class_methods":[{"html_id":"from_json(json:JSON::PullParser):JSON::Any-class-method","name":"from_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"args_string":"(json : JSON::PullParser) : JSON::Any","args_html":"(json : JSON::PullParser) : JSON::Any","location":{"filename":"src/generated_message.cr","line_number":133,"url":null},"def":{"name":"from_json","args":[{"name":"json","external_name":"json","restriction":"JSON::PullParser"}],"return_type":"JSON::Any","visibility":"Public","body":"hash = Hash(String, JSON::Any).new(json)\nresult = hash.fetch(\"properties\") do\n JSON::Any.new(nil)\nend\nif result.as_h?\n result\nelse\n JSON::Any.new(hash)\nend\n"}}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse/Schema","path":"Anthropic/GeneratedMessage/ToolUse/Schema.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse::Schema","name":"Schema","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":145,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage/ToolUse","kind":"struct","full_name":"Anthropic::GeneratedMessage::ToolUse","name":"ToolUse"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/generated_message.cr","line_number":146,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"properties:JSON::Any-instance-method","name":"properties","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":148,"url":null},"def":{"name":"properties","return_type":"JSON::Any","visibility":"Public","body":"@properties"}}]}]},{"html_id":"anthropic/Anthropic/GeneratedMessage/Usage","path":"Anthropic/GeneratedMessage/Usage.html","kind":"struct","full_name":"Anthropic::GeneratedMessage::Usage","name":"Usage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/generated_message.cr","line_number":152,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"input_tokens:Int64-instance-method","name":"input_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":155,"url":null},"def":{"name":"input_tokens","return_type":"Int64","visibility":"Public","body":"@input_tokens"}},{"html_id":"output_tokens:Int64-instance-method","name":"output_tokens","abstract":false,"location":{"filename":"src/generated_message.cr","line_number":156,"url":null},"def":{"name":"output_tokens","return_type":"Int64","visibility":"Public","body":"@output_tokens"}}]}]},{"html_id":"anthropic/Anthropic/Image","path":"Anthropic/Image.html","kind":"struct","full_name":"Anthropic::Image","name":"Image","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":39,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"class_methods":[{"html_id":"base64(media_type:Source::MediaType,data:String)-class-method","name":"base64","abstract":false,"args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(media_type : Source::MediaType, data : String)","args_html":"(media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":43,"url":null},"def":{"name":"base64","args":[{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"new(type: :base64, media_type: media_type, data: Base64.strict_encode(data))"}}],"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":39,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,type:Source::Type,media_type:Source::MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","args_html":"(*, type : Source::Type, media_type : Source::MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":51,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"type","external_name":"type","restriction":"Source::Type"},{"name":"media_type","external_name":"media_type","restriction":"Source::MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(type: type, media_type: media_type, data: data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"source:Source-instance-method","name":"source","abstract":false,"location":{"filename":"src/message_content.cr","line_number":41,"url":null},"def":{"name":"source","return_type":"Source","visibility":"Public","body":"@source"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":40,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source","path":"Anthropic/Image/Source.html","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":55,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Image","kind":"struct","full_name":"Anthropic::Image","name":"Image"},"constructors":[{"html_id":"new(type:Type,media_type:MediaType,data:String)-class-method","name":"new","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"args_string":"(type : Type, media_type : MediaType, data : String)","args_html":"(type : Type, media_type : MediaType, data : String)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"new","args":[{"name":"type","external_name":"type","restriction":"Type"},{"name":"media_type","external_name":"media_type","restriction":"MediaType"},{"name":"data","external_name":"data","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(type, media_type, data)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@type.clone, @media_type.clone, @data.clone)"}},{"html_id":"copy_with(type_type=@type,media_type_media_type=@media_type,data_data=@data)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"args_string":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","args_html":"(type _type = @type, media_type _media_type = @media_type, data _data = @data)","location":{"filename":"src/message_content.cr","line_number":55,"url":null},"def":{"name":"copy_with","args":[{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_media_type","default_value":"@media_type","external_name":"media_type","restriction":""},{"name":"_data","default_value":"@data","external_name":"data","restriction":""}],"visibility":"Public","body":"self.class.new(_type, _media_type, _data)"}},{"html_id":"data:String-instance-method","name":"data","abstract":false,"def":{"name":"data","return_type":"String","visibility":"Public","body":"@data"}},{"html_id":"media_type:MediaType-instance-method","name":"media_type","abstract":false,"def":{"name":"media_type","return_type":"MediaType","visibility":"Public","body":"@media_type"}},{"html_id":"type:Type-instance-method","name":"type","abstract":false,"def":{"name":"type","return_type":"Type","visibility":"Public","body":"@type"}}],"types":[{"html_id":"anthropic/Anthropic/Image/Source/MediaType","path":"Anthropic/Image/Source/MediaType.html","kind":"enum","full_name":"Anthropic::Image::Source::MediaType","name":"MediaType","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":62,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"JPEG","name":"JPEG","value":"0"},{"id":"PNG","name":"PNG","value":"1"},{"id":"GIF","name":"GIF","value":"2"},{"id":"WEBP","name":"WEBP","value":"3"}],"namespace":{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},"instance_methods":[{"html_id":"gif?-instance-method","name":"gif?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":65,"url":null},"def":{"name":"gif?","visibility":"Public","body":"self == GIF"}},{"html_id":"jpeg?-instance-method","name":"jpeg?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":63,"url":null},"def":{"name":"jpeg?","visibility":"Public","body":"self == JPEG"}},{"html_id":"png?-instance-method","name":"png?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":64,"url":null},"def":{"name":"png?","visibility":"Public","body":"self == PNG"}},{"html_id":"to_s-instance-method","name":"to_s","doc":"Returns a `String` representation of this enum member.\nIn the case of regular enums, this is just the name of the member.\nIn the case of flag enums, it's the names joined by vertical bars, or \"None\",\nif the value is zero.\n\nIf an enum's value doesn't match a member's value, the raw value\nis returned as a string.\n\n```\nColor::Red.to_s # => \"Red\"\nIOMode::None.to_s # => \"None\"\n(IOMode::Read | IOMode::Write).to_s # => \"Read | Write\"\n\nColor.new(10).to_s # => \"10\"\n```","summary":"

Returns a String representation of this enum member.

","abstract":false,"location":{"filename":"src/message_content.cr","line_number":68,"url":null},"def":{"name":"to_s","visibility":"Public","body":"\"image/#{super().downcase}\""}},{"html_id":"webp?-instance-method","name":"webp?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":66,"url":null},"def":{"name":"webp?","visibility":"Public","body":"self == WEBP"}}]},{"html_id":"anthropic/Anthropic/Image/Source/Type","path":"Anthropic/Image/Source/Type.html","kind":"enum","full_name":"Anthropic::Image::Source::Type","name":"Type","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":57,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Base64","name":"Base64","value":"0"}],"namespace":{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},"instance_methods":[{"html_id":"base64?-instance-method","name":"base64?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":59,"url":null},"def":{"name":"base64?","visibility":"Public","body":"self == Base64"}}]}]}]},{"html_id":"anthropic/Anthropic/Message","path":"Anthropic/Message.html","kind":"struct","full_name":"Anthropic::Message","name":"Message","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message.cr","line_number":4,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(content:Array(Anthropic::MessageContent)|String,role:Anthropic::Message::Role=:user)-class-method","name":"new","abstract":false,"args":[{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::MessageContent) | ::String"},{"name":"role","default_value":":user","external_name":"role","restriction":"::Anthropic::Message::Role"}],"args_string":"(content : Array(Anthropic::MessageContent) | String, role : Anthropic::Message::Role = :user)","args_html":"(content : Array(Anthropic::MessageContent) | String, role : Anthropic::Message::Role = :user)","location":{"filename":"src/message.cr","line_number":10,"url":null},"def":{"name":"new","args":[{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::MessageContent) | ::String"},{"name":"role","default_value":":user","external_name":"role","restriction":"::Anthropic::Message::Role"}],"visibility":"Public","body":"_ = allocate\n_.initialize(content, role)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"content:String|Array(MessageContent)-instance-method","name":"content","abstract":false,"location":{"filename":"src/message.cr","line_number":8,"url":null},"def":{"name":"content","return_type":"String | Array(MessageContent)","visibility":"Public","body":"@content"}},{"html_id":"role:Role-instance-method","name":"role","abstract":false,"location":{"filename":"src/message.cr","line_number":7,"url":null},"def":{"name":"role","return_type":"Role","visibility":"Public","body":"@role"}}],"types":[{"html_id":"anthropic/Anthropic/Message/Role","path":"Anthropic/Message/Role.html","kind":"enum","full_name":"Anthropic::Message::Role","name":"Role","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message.cr","line_number":13,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"User","name":"User","value":"0"},{"id":"Assistant","name":"Assistant","value":"1"}],"namespace":{"html_id":"anthropic/Anthropic/Message","kind":"struct","full_name":"Anthropic::Message","name":"Message"},"instance_methods":[{"html_id":"assistant?-instance-method","name":"assistant?","abstract":false,"location":{"filename":"src/message.cr","line_number":15,"url":null},"def":{"name":"assistant?","visibility":"Public","body":"self == Assistant"}},{"html_id":"user?-instance-method","name":"user?","abstract":false,"location":{"filename":"src/message.cr","line_number":14,"url":null},"def":{"name":"user?","visibility":"Public","body":"self == User"}}]}]},{"html_id":"anthropic/Anthropic/MessageContent","path":"Anthropic/MessageContent.html","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"subclasses":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/ToolResult","kind":"struct","full_name":"Anthropic::ToolResult","name":"ToolResult"},{"html_id":"anthropic/Anthropic/ToolUse","kind":"struct","full_name":"Anthropic::ToolUse","name":"ToolUse"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":11,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"location = pull.location\ndiscriminator_value = nil\njson = String.build do |io|\n JSON.build(io) do |builder|\n builder.start_object\n pull.read_object do |key|\n if key == \"type\"\n value_kind = pull.kind\n case value_kind\n when .string?\n discriminator_value = pull.string_value\n when .int?\n discriminator_value = pull.int_value\n when .bool?\n discriminator_value = pull.bool_value\n else\n raise(::JSON::SerializableError.new(\"JSON discriminator field 'type' has an invalid value type of #{value_kind.to_s}\", to_s, nil, *location, nil))\n end\n builder.field(key, discriminator_value)\n pull.read_next\n else\n builder.field(key) do\n pull.read_raw(builder)\n end\n end\n end\n builder.end_object\n end\nend\nif discriminator_value.nil?\n raise(::JSON::SerializableError.new(\"Missing JSON discriminator field 'type'\", to_s, nil, *location, nil))\nend\ncase discriminator_value\nwhen \"text\"\n Text.from_json(json)\nwhen \"image\"\n Image.from_json(json)\nwhen \"tool_use\"\n ToolUse.from_json(json)\nwhen \"tool_result\"\n ToolResult.from_json(json)\nelse\n raise(::JSON::SerializableError.new(\"Unknown 'type' discriminator value: #{discriminator_value.inspect}\", to_s, nil, *location, nil))\nend\n"}}],"instance_methods":[{"html_id":"type:String-instance-method","name":"type","abstract":true,"location":{"filename":"src/message_content.cr","line_number":9,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":""}}]},{"html_id":"anthropic/Anthropic/MessageDelta","path":"Anthropic/MessageDelta.html","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":132,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"delta:Delta-instance-method","name":"delta","abstract":false,"location":{"filename":"src/event_source.cr","line_number":133,"url":null},"def":{"name":"delta","return_type":"Delta","visibility":"Public","body":"@delta"}},{"html_id":"usage:Usage-instance-method","name":"usage","abstract":false,"location":{"filename":"src/event_source.cr","line_number":134,"url":null},"def":{"name":"usage","return_type":"Usage","visibility":"Public","body":"@usage"}}],"types":[{"html_id":"anthropic/Anthropic/MessageDelta/Delta","path":"Anthropic/MessageDelta/Delta.html","kind":"struct","full_name":"Anthropic::MessageDelta::Delta","name":"Delta","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":135,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"stop_reason:GeneratedMessage::StopReason|Nil-instance-method","name":"stop_reason","abstract":false,"location":{"filename":"src/event_source.cr","line_number":138,"url":null},"def":{"name":"stop_reason","return_type":"GeneratedMessage::StopReason | ::Nil","visibility":"Public","body":"@stop_reason"}},{"html_id":"stop_sequence:String|Nil-instance-method","name":"stop_sequence","abstract":false,"location":{"filename":"src/event_source.cr","line_number":140,"url":null},"def":{"name":"stop_sequence","return_type":"String | ::Nil","visibility":"Public","body":"@stop_sequence"}}]},{"html_id":"anthropic/Anthropic/MessageDelta/Usage","path":"Anthropic/MessageDelta/Usage.html","kind":"struct","full_name":"Anthropic::MessageDelta::Usage","name":"Usage","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":143,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"output_tokens:Int64-instance-method","name":"output_tokens","abstract":false,"location":{"filename":"src/event_source.cr","line_number":145,"url":null},"def":{"name":"output_tokens","return_type":"Int64","visibility":"Public","body":"@output_tokens"}}]}]},{"html_id":"anthropic/Anthropic/Messages","path":"Anthropic/Messages.html","kind":"struct","full_name":"Anthropic::Messages","name":"Messages","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/API","kind":"struct","full_name":"Anthropic::API","name":"API"},"ancestors":[{"html_id":"anthropic/Anthropic/API","kind":"struct","full_name":"Anthropic::API","name":"API"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":6,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"instance_methods":[{"html_id":"create(*,model:String,max_tokens:Int32,messages:Array(Anthropic::Message),system:String|Nil=nil,temperature:Float64|Nil=nil,top_k:Int64|Nil=nil,top_p:Float64|Nil=nil,tools:Array|Nil=nil,run_tools:Bool=true):GeneratedMessage-instance-method","name":"create","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"Array | ::Nil"},{"name":"run_tools","default_value":"true","external_name":"run_tools","restriction":"Bool"}],"args_string":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, tools : Array | Nil = nil, run_tools : Bool = true) : GeneratedMessage","args_html":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, tools : Array | Nil = nil, run_tools : Bool = true) : GeneratedMessage","location":{"filename":"src/messages.cr","line_number":7,"url":null},"def":{"name":"create","args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"Array | ::Nil"},{"name":"run_tools","default_value":"true","external_name":"run_tools","restriction":"Bool"}],"splat_index":0,"return_type":"GeneratedMessage","visibility":"Public","body":"tools = Anthropic.tools(tools)\nrequest = Request.new(model: model, max_tokens: max_tokens, system: system, messages: messages, temperature: temperature, top_k: top_k, top_p: top_p, tools: tools.to_json)\nheaders = HTTP::Headers.new\nif tools.try(&.any?)\n headers.add(\"anthropic-beta\", \"tools-2024-05-16\")\nend\nif (model.includes?(\"3-5-sonnet\")) && max_tokens > 4096\n headers.add(\"anthropic-beta\", \"max-tokens-3-5-sonnet-2024-07-15\")\nend\nresponse = client.post(\"/v1/messages?beta=tools\", headers: headers, body: request, as: GeneratedMessage)\nresponse.message_thread = messages.dup << response.to_message\nif run_tools && response.stop_reason.try(&.tool_use?)\n tool_uses = response.content.compact_map() do |__arg2|\n __arg2.as?(ToolUse)\n end\n tools_used = tool_uses.compact_map do |tool_use|\n tools.find do |t|\n t.name == tool_use.name\n end\n end\n tool_handlers = tools_used.map_with_index do |tool, index|\n tool.input_type.parse(tool_uses[index].input.to_json)\n end\n if tool_handlers.any?\n result_texts = tool_handlers.map do |tool_handler|\n (Text.new(tool_handler.call.to_json)).as(Text)\n end\n create(model: model, max_tokens: max_tokens, messages: messages + [response.to_message, Message.new(content: result_texts.map_with_index do |result_text, index|\n ToolResult.new(tool_use_id: tool_uses[index].id.not_nil!, content: [result_text]).as(MessageContent)\n end)], system: system, temperature: temperature, top_k: top_k, top_p: top_p, tools: tools, run_tools: run_tools)\n else\n response\n end\nelse\n response\nend\n"}},{"html_id":"create(*,model:String,max_tokens:Int32,messages:Array(Anthropic::Message),system:String|Nil=nil,temperature:Float64|Nil=nil,top_k:Int64|Nil=nil,top_p:Float64|Nil=nil,&block:Event->T)forallT-instance-method","name":"create","doc":"Send your prompt to the API and yield `Event`s as they are fed back in.","summary":"

Send your prompt to the API and yield Events as they are fed back in.

\n

EXPERIMENTAL

","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"}],"args_string":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, &block : Event -> T) forall T","args_html":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : String | Nil = nil, temperature : Float64 | Nil = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, &block : Event -> T) forall T","location":{"filename":"src/messages.cr","line_number":94,"url":null},"def":{"name":"create","args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"Int32"},{"name":"messages","external_name":"messages","restriction":"Array(Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"String | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"Float64 | ::Nil"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"Float64 | ::Nil"}],"splat_index":0,"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Event -> T)"},"visibility":"Public","body":"client.http do |http|\n headers = HTTP::Headers {\"anthropic-beta\" => \"tools-2024-04-04\", \"Accept\" => \"text/event-stream\"}\n body = Request.new(model: model, max_tokens: max_tokens, system: system, messages: messages, temperature: temperature, top_k: top_k, top_p: top_p, tools: tools, stream: true).to_json\n http.post(\"/v1/messages?beta=tools\", headers: headers, body: body) do |response|\n (EventSource.new(response)).on_message do |message, es|\n message.data.each do |data|\n block.call(Event::TYPE_MAP[message.event].from_json(data))\n end\n end.run\n response\n end\nend"}}],"types":[{"html_id":"anthropic/Anthropic/Messages/Body","path":"Anthropic/Messages/Body.html","kind":"struct","full_name":"Anthropic::Messages::Body","name":"Body","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":183,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Messages","kind":"struct","full_name":"Anthropic::Messages","name":"Messages"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Messages/Query","path":"Anthropic/Messages/Query.html","kind":"struct","full_name":"Anthropic::Messages::Query","name":"Query","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":179,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Messages","kind":"struct","full_name":"Anthropic::Messages","name":"Messages"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Messages/Request","path":"Anthropic/Messages/Request.html","kind":"struct","full_name":"Anthropic::Messages::Request","name":"Request","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/messages.cr","line_number":136,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Messages","kind":"struct","full_name":"Anthropic::Messages","name":"Messages"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,model:String,max_tokens:Int32,messages:Array(Anthropic::Message),system:Nil|String=nil,metadata:Nil|Hash(String,String)=nil,stop_sequences:Nil|Array(String)=nil,stream:Bool|Nil=nil,temperature:Float64|Nil=nil,tools:Nil|String=nil,top_k:Int64|Nil=nil,top_p:Float64|Nil=nil,extra_headers:HTTP::Headers|Nil=nil,extra_query:Anthropic::Messages::Query|Nil=nil,extra_body:Anthropic::Messages::Body|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"::String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"::Int32"},{"name":"messages","external_name":"messages","restriction":"::Array(::Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"::Nil | ::String"},{"name":"metadata","default_value":"nil","external_name":"metadata","restriction":"::Nil | ::Hash(::String, ::String)"},{"name":"stop_sequences","default_value":"nil","external_name":"stop_sequences","restriction":"::Nil | ::Array(::String)"},{"name":"stream","default_value":"nil","external_name":"stream","restriction":"::Bool | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"::Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"::Nil | ::String"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"::Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"::Float64 | ::Nil"},{"name":"extra_headers","default_value":"nil","external_name":"extra_headers","restriction":"::HTTP::Headers | ::Nil"},{"name":"extra_query","default_value":"nil","external_name":"extra_query","restriction":"::Anthropic::Messages::Query | ::Nil"},{"name":"extra_body","default_value":"nil","external_name":"extra_body","restriction":"::Anthropic::Messages::Body | ::Nil"}],"args_string":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : Nil | String = nil, metadata : Nil | Hash(String, String) = nil, stop_sequences : Nil | Array(String) = nil, stream : Bool | Nil = nil, temperature : Float64 | Nil = nil, tools : Nil | String = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, extra_headers : HTTP::Headers | Nil = nil, extra_query : Anthropic::Messages::Query | Nil = nil, extra_body : Anthropic::Messages::Body | Nil = nil)","args_html":"(*, model : String, max_tokens : Int32, messages : Array(Anthropic::Message), system : Nil | String = nil, metadata : Nil | Hash(String, String) = nil, stop_sequences : Nil | Array(String) = nil, stream : Bool | Nil = nil, temperature : Float64 | Nil = nil, tools : Nil | String = nil, top_k : Int64 | Nil = nil, top_p : Float64 | Nil = nil, extra_headers : HTTP::Headers | Nil = nil, extra_query : Anthropic::Messages::Query | Nil = nil, extra_body : Anthropic::Messages::Body | Nil = nil)","location":{"filename":"src/messages.cr","line_number":158,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"model","external_name":"model","restriction":"::String"},{"name":"max_tokens","external_name":"max_tokens","restriction":"::Int32"},{"name":"messages","external_name":"messages","restriction":"::Array(::Anthropic::Message)"},{"name":"system","default_value":"nil","external_name":"system","restriction":"::Nil | ::String"},{"name":"metadata","default_value":"nil","external_name":"metadata","restriction":"::Nil | ::Hash(::String, ::String)"},{"name":"stop_sequences","default_value":"nil","external_name":"stop_sequences","restriction":"::Nil | ::Array(::String)"},{"name":"stream","default_value":"nil","external_name":"stream","restriction":"::Bool | ::Nil"},{"name":"temperature","default_value":"nil","external_name":"temperature","restriction":"::Float64 | ::Nil"},{"name":"tools","default_value":"nil","external_name":"tools","restriction":"::Nil | ::String"},{"name":"top_k","default_value":"nil","external_name":"top_k","restriction":"::Int64 | ::Nil"},{"name":"top_p","default_value":"nil","external_name":"top_p","restriction":"::Float64 | ::Nil"},{"name":"extra_headers","default_value":"nil","external_name":"extra_headers","restriction":"::HTTP::Headers | ::Nil"},{"name":"extra_query","default_value":"nil","external_name":"extra_query","restriction":"::Anthropic::Messages::Query | ::Nil"},{"name":"extra_body","default_value":"nil","external_name":"extra_body","restriction":"::Anthropic::Messages::Body | ::Nil"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(model: model, max_tokens: max_tokens, messages: messages, system: system, metadata: metadata, stop_sequences: stop_sequences, stream: stream, temperature: temperature, tools: tools, top_k: top_k, top_p: top_p, extra_headers: extra_headers, extra_query: extra_query, extra_body: extra_body)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"extra_body:Body|Nil-instance-method","name":"extra_body","abstract":false,"location":{"filename":"src/messages.cr","line_number":153,"url":null},"def":{"name":"extra_body","return_type":"Body | ::Nil","visibility":"Public","body":"@extra_body"}},{"html_id":"extra_headers:HTTP::Headers|Nil-instance-method","name":"extra_headers","abstract":false,"location":{"filename":"src/messages.cr","line_number":151,"url":null},"def":{"name":"extra_headers","return_type":"HTTP::Headers | ::Nil","visibility":"Public","body":"@extra_headers"}},{"html_id":"extra_query:Query|Nil-instance-method","name":"extra_query","abstract":false,"location":{"filename":"src/messages.cr","line_number":152,"url":null},"def":{"name":"extra_query","return_type":"Query | ::Nil","visibility":"Public","body":"@extra_query"}},{"html_id":"max_tokens:Int32-instance-method","name":"max_tokens","abstract":false,"location":{"filename":"src/messages.cr","line_number":141,"url":null},"def":{"name":"max_tokens","return_type":"Int32","visibility":"Public","body":"@max_tokens"}},{"html_id":"messages:Array(Message)-instance-method","name":"messages","abstract":false,"location":{"filename":"src/messages.cr","line_number":140,"url":null},"def":{"name":"messages","return_type":"Array(Message)","visibility":"Public","body":"@messages"}},{"html_id":"metadata:Hash(String,String)|Nil-instance-method","name":"metadata","abstract":false,"location":{"filename":"src/messages.cr","line_number":143,"url":null},"def":{"name":"metadata","return_type":"Hash(String, String) | ::Nil","visibility":"Public","body":"@metadata"}},{"html_id":"model:String-instance-method","name":"model","abstract":false,"location":{"filename":"src/messages.cr","line_number":139,"url":null},"def":{"name":"model","return_type":"String","visibility":"Public","body":"@model"}},{"html_id":"stop_sequences:Array(String)|Nil-instance-method","name":"stop_sequences","abstract":false,"location":{"filename":"src/messages.cr","line_number":144,"url":null},"def":{"name":"stop_sequences","return_type":"Array(String) | ::Nil","visibility":"Public","body":"@stop_sequences"}},{"html_id":"stream?:Bool|Nil-instance-method","name":"stream?","abstract":false,"location":{"filename":"src/messages.cr","line_number":145,"url":null},"def":{"name":"stream?","return_type":"Bool | ::Nil","visibility":"Public","body":"@stream"}},{"html_id":"system:String|Nil-instance-method","name":"system","abstract":false,"location":{"filename":"src/messages.cr","line_number":142,"url":null},"def":{"name":"system","return_type":"String | ::Nil","visibility":"Public","body":"@system"}},{"html_id":"temperature:Float64|Nil-instance-method","name":"temperature","abstract":false,"location":{"filename":"src/messages.cr","line_number":146,"url":null},"def":{"name":"temperature","return_type":"Float64 | ::Nil","visibility":"Public","body":"@temperature"}},{"html_id":"tools:String|Nil-instance-method","name":"tools","abstract":false,"location":{"filename":"src/messages.cr","line_number":148,"url":null},"def":{"name":"tools","return_type":"String | ::Nil","visibility":"Public","body":"@tools"}},{"html_id":"top_k:Int64|Nil-instance-method","name":"top_k","abstract":false,"location":{"filename":"src/messages.cr","line_number":149,"url":null},"def":{"name":"top_k","return_type":"Int64 | ::Nil","visibility":"Public","body":"@top_k"}},{"html_id":"top_p:Float64|Nil-instance-method","name":"top_p","abstract":false,"location":{"filename":"src/messages.cr","line_number":150,"url":null},"def":{"name":"top_p","return_type":"Float64 | ::Nil","visibility":"Public","body":"@top_p"}}]}]},{"html_id":"anthropic/Anthropic/MessageStart","path":"Anthropic/MessageStart.html","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":149,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"message:GeneratedMessage-instance-method","name":"message","abstract":false,"location":{"filename":"src/event_source.cr","line_number":150,"url":null},"def":{"name":"message","return_type":"GeneratedMessage","visibility":"Public","body":"@message"}}]},{"html_id":"anthropic/Anthropic/MessageStop","path":"Anthropic/MessageStop.html","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":152,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/MessageStream","path":"Anthropic/MessageStream.html","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":153,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Model","path":"Anthropic/Model.html","kind":"enum","full_name":"Anthropic::Model","name":"Model","abstract":false,"ancestors":[{"html_id":"anthropic/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"anthropic/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/model.cr","line_number":13,"url":null}],"repository_name":"anthropic","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"Haiku","name":"Haiku","value":"0"},{"id":"Sonnet","name":"Sonnet","value":"1"},{"id":"Opus","name":"Opus","value":"2"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"instance_methods":[{"html_id":"haiku?-instance-method","name":"haiku?","abstract":false,"location":{"filename":"src/model.cr","line_number":14,"url":null},"def":{"name":"haiku?","visibility":"Public","body":"self == Haiku"}},{"html_id":"opus?-instance-method","name":"opus?","abstract":false,"location":{"filename":"src/model.cr","line_number":16,"url":null},"def":{"name":"opus?","visibility":"Public","body":"self == Opus"}},{"html_id":"sonnet?-instance-method","name":"sonnet?","abstract":false,"location":{"filename":"src/model.cr","line_number":15,"url":null},"def":{"name":"sonnet?","visibility":"Public","body":"self == Sonnet"}}]},{"html_id":"anthropic/Anthropic/Ping","path":"Anthropic/Ping.html","kind":"struct","full_name":"Anthropic::Ping","name":"Ping","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Anthropic/Event","kind":"struct","full_name":"Anthropic::Event","name":"Event"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":154,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}]},{"html_id":"anthropic/Anthropic/Resource","path":"Anthropic/Resource.html","kind":"module","full_name":"Anthropic::Resource","name":"Resource","abstract":false,"locations":[{"filename":"src/resource.cr","line_number":4,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"anthropic/Anthropic/ContentBlockDelta","kind":"struct","full_name":"Anthropic::ContentBlockDelta","name":"ContentBlockDelta"},{"html_id":"anthropic/Anthropic/ContentBlockStart","kind":"struct","full_name":"Anthropic::ContentBlockStart","name":"ContentBlockStart"},{"html_id":"anthropic/Anthropic/ContentBlockStart/ContentBlock","kind":"struct","full_name":"Anthropic::ContentBlockStart::ContentBlock","name":"ContentBlock"},{"html_id":"anthropic/Anthropic/ContentBlockStop","kind":"struct","full_name":"Anthropic::ContentBlockStop","name":"ContentBlockStop"},{"html_id":"anthropic/Anthropic/Error/Response","kind":"struct","full_name":"Anthropic::Error::Response","name":"Response"},{"html_id":"anthropic/Anthropic/Error/Response/Error","kind":"struct","full_name":"Anthropic::Error::Response::Error","name":"Error"},{"html_id":"anthropic/Anthropic/GeneratedMessage","kind":"struct","full_name":"Anthropic::GeneratedMessage","name":"GeneratedMessage"},{"html_id":"anthropic/Anthropic/GeneratedMessage/Content","kind":"struct","full_name":"Anthropic::GeneratedMessage::Content","name":"Content"},{"html_id":"anthropic/Anthropic/GeneratedMessage/Usage","kind":"struct","full_name":"Anthropic::GeneratedMessage::Usage","name":"Usage"},{"html_id":"anthropic/Anthropic/Image/Source","kind":"struct","full_name":"Anthropic::Image::Source","name":"Source"},{"html_id":"anthropic/Anthropic/Message","kind":"struct","full_name":"Anthropic::Message","name":"Message"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/Anthropic/MessageDelta","kind":"struct","full_name":"Anthropic::MessageDelta","name":"MessageDelta"},{"html_id":"anthropic/Anthropic/MessageDelta/Delta","kind":"struct","full_name":"Anthropic::MessageDelta::Delta","name":"Delta"},{"html_id":"anthropic/Anthropic/MessageDelta/Usage","kind":"struct","full_name":"Anthropic::MessageDelta::Usage","name":"Usage"},{"html_id":"anthropic/Anthropic/Messages/Body","kind":"struct","full_name":"Anthropic::Messages::Body","name":"Body"},{"html_id":"anthropic/Anthropic/Messages/Query","kind":"struct","full_name":"Anthropic::Messages::Query","name":"Query"},{"html_id":"anthropic/Anthropic/Messages/Request","kind":"struct","full_name":"Anthropic::Messages::Request","name":"Request"},{"html_id":"anthropic/Anthropic/MessageStart","kind":"struct","full_name":"Anthropic::MessageStart","name":"MessageStart"},{"html_id":"anthropic/Anthropic/MessageStop","kind":"struct","full_name":"Anthropic::MessageStop","name":"MessageStop"},{"html_id":"anthropic/Anthropic/MessageStream","kind":"struct","full_name":"Anthropic::MessageStream","name":"MessageStream"},{"html_id":"anthropic/Anthropic/Ping","kind":"struct","full_name":"Anthropic::Ping","name":"Ping"},{"html_id":"anthropic/Anthropic/TextDelta","kind":"struct","full_name":"Anthropic::TextDelta","name":"TextDelta"},{"html_id":"anthropic/Anthropic/Tool","kind":"struct","full_name":"Anthropic::Tool(T)","name":"Tool"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"}},{"html_id":"anthropic/Anthropic/Text","path":"Anthropic/Text.html","kind":"struct","full_name":"Anthropic::Text","name":"Text","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/TextOrImageContent","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent"},{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":25,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":25,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(text:String)-class-method","name":"new","abstract":false,"args":[{"name":"text","external_name":"text","restriction":"::String"}],"args_string":"(text : String)","args_html":"(text : String)","location":{"filename":"src/message_content.cr","line_number":29,"url":null},"def":{"name":"new","args":[{"name":"text","external_name":"text","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(text)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"text:String-instance-method","name":"text","abstract":false,"location":{"filename":"src/message_content.cr","line_number":27,"url":null},"def":{"name":"text","return_type":"String","visibility":"Public","body":"@text"}},{"html_id":"to_s(io):Nil-instance-method","name":"to_s","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io) : Nil","args_html":"(io) : Nil","location":{"filename":"src/message_content.cr","line_number":32,"url":null},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""}],"return_type":"Nil","visibility":"Public","body":"if text = @text\n io.puts(text)\nend"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":26,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"anthropic/Anthropic/TextDelta","path":"Anthropic/TextDelta.html","kind":"struct","full_name":"Anthropic::TextDelta","name":"TextDelta","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/event_source.cr","line_number":156,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"text:String|Nil-instance-method","name":"text","abstract":false,"location":{"filename":"src/event_source.cr","line_number":162,"url":null},"def":{"name":"text","return_type":"String | ::Nil","visibility":"Public","body":"@text"}}]},{"html_id":"anthropic/Anthropic/TextOrImageContent","path":"Anthropic/TextOrImageContent.html","kind":"struct","full_name":"Anthropic::TextOrImageContent","name":"TextOrImageContent","abstract":true,"superclass":{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":19,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"anthropic/Anthropic/Image","kind":"struct","full_name":"Anthropic::Image","name":"Image"},{"html_id":"anthropic/Anthropic/Text","kind":"struct","full_name":"Anthropic::Text","name":"Text"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":20,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"raise(\"oops\")"}}]},{"html_id":"anthropic/Anthropic/Tool","path":"Anthropic/Tool.html","kind":"struct","full_name":"Anthropic::Tool(T)","name":"Tool","abstract":false,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/tool.cr","line_number":24,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(name:String,description:Nil|String,input_type:T)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"description","external_name":"description","restriction":"::Nil | ::String"},{"name":"input_type","external_name":"input_type","restriction":"T"}],"args_string":"(name : String, description : Nil | String, input_type : T)","args_html":"(name : String, description : Nil | String, input_type : T)","location":{"filename":"src/tool.cr","line_number":31,"url":null},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"description","external_name":"description","restriction":"::Nil | ::String"},{"name":"input_type","external_name":"input_type","restriction":"T"}],"visibility":"Public","body":"_ = Tool(T).allocate\n_.initialize(name, description, input_type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"description:String|Nil-instance-method","name":"description","abstract":false,"location":{"filename":"src/tool.cr","line_number":28,"url":null},"def":{"name":"description","return_type":"String | ::Nil","visibility":"Public","body":"@description"}},{"html_id":"input_type:T-instance-method","name":"input_type","abstract":false,"location":{"filename":"src/tool.cr","line_number":29,"url":null},"def":{"name":"input_type","return_type":"T","visibility":"Public","body":"@input_type"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/tool.cr","line_number":27,"url":null},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"to_json(json:JSON::Builder):Nil-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"args_string":"(json : JSON::Builder) : Nil","args_html":"(json : JSON::Builder) : Nil","location":{"filename":"src/tool.cr","line_number":34,"url":null},"def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"return_type":"Nil","visibility":"Public","body":"json.object do\n json.field(\"name\", name)\n if description\n json.field(\"description\", description)\n end\n json.field(\"input_schema\") do\n input_type.json_schema.to_json(json)\n end\nend"}}],"types":[{"html_id":"anthropic/Anthropic/Tool/Handler","path":"Anthropic/Tool/Handler.html","kind":"struct","full_name":"Anthropic::Tool::Handler","name":"Handler","abstract":true,"superclass":{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/tool.cr","line_number":46,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"}],"extended_modules":[{"html_id":"anthropic/JSON/Schema","kind":"module","full_name":"JSON::Schema","name":"Schema"}],"namespace":{"html_id":"anthropic/Anthropic/Tool","kind":"struct","full_name":"Anthropic::Tool(T)","name":"Tool"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/tool.cr","line_number":49,"url":null},"def":{"name":"description","visibility":"Public","body":""}},{"html_id":"parse(json:String)-class-method","name":"parse","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"String"}],"args_string":"(json : String)","args_html":"(json : String)","location":{"filename":"src/tool.cr","line_number":52,"url":null},"def":{"name":"parse","args":[{"name":"json","external_name":"json","restriction":"String"}],"visibility":"Public","body":"raise(NotImplementedError.new(\"Can't parse #{self} from #{json}\"))"}}],"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/tool.cr","line_number":47,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}}],"instance_methods":[{"html_id":"call-instance-method","name":"call","abstract":true,"location":{"filename":"src/tool.cr","line_number":62,"url":null},"def":{"name":"call","visibility":"Public","body":""}}]}]},{"html_id":"anthropic/Anthropic/ToolResult","path":"Anthropic/ToolResult.html","kind":"struct","full_name":"Anthropic::ToolResult","name":"ToolResult","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":85,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":85,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,tool_use_id:String,error:Bool=false,content:Array(Text)|Array(Image))-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"String"},{"name":"error","default_value":"false","external_name":"error","restriction":"Bool"},{"name":"content","external_name":"content","restriction":"Array(Text) | Array(Image)"}],"args_string":"(*, tool_use_id : String, error : Bool = false, content : Array(Text) | Array(Image))","args_html":"(*, tool_use_id : String, error : Bool = false, content : Array(Text) | Array(Image))","location":{"filename":"src/message_content.cr","line_number":92,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"String"},{"name":"error","default_value":"false","external_name":"error","restriction":"Bool"},{"name":"content","external_name":"content","restriction":"Array(Text) | Array(Image)"}],"splat_index":0,"visibility":"Public","body":"new(tool_use_id: tool_use_id, error: error, content: content.map do |__arg0|\n __arg0.as(Text | Image)\nend)"}},{"html_id":"new(*,tool_use_id:String,error:Bool=false,content:Array(Anthropic::TextOrImageContent))-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"::String"},{"name":"error","default_value":"false","external_name":"error","restriction":"::Bool"},{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::TextOrImageContent)"}],"args_string":"(*, tool_use_id : String, error : Bool = false, content : Array(Anthropic::TextOrImageContent))","args_html":"(*, tool_use_id : String, error : Bool = false, content : Array(Anthropic::TextOrImageContent))","location":{"filename":"src/message_content.cr","line_number":100,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"tool_use_id","external_name":"tool_use_id","restriction":"::String"},{"name":"error","default_value":"false","external_name":"error","restriction":"::Bool"},{"name":"content","external_name":"content","restriction":"::Array(::Anthropic::TextOrImageContent)"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(tool_use_id: tool_use_id, error: error, content: content)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"content:Array(Text|Image)-instance-method","name":"content","abstract":false,"location":{"filename":"src/message_content.cr","line_number":90,"url":null},"def":{"name":"content","return_type":"Array(Text | Image)","visibility":"Public","body":"@content"}},{"html_id":"error?:Bool-instance-method","name":"error?","abstract":false,"location":{"filename":"src/message_content.cr","line_number":89,"url":null},"def":{"name":"error?","return_type":"Bool","visibility":"Public","body":"@error"}},{"html_id":"tool_use_id:String-instance-method","name":"tool_use_id","abstract":false,"location":{"filename":"src/message_content.cr","line_number":87,"url":null},"def":{"name":"tool_use_id","return_type":"String","visibility":"Public","body":"@tool_use_id"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":86,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"anthropic/Anthropic/ToolUse","path":"Anthropic/ToolUse.html","kind":"struct","full_name":"Anthropic::ToolUse","name":"ToolUse","abstract":false,"superclass":{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},"ancestors":[{"html_id":"anthropic/Anthropic/MessageContent","kind":"struct","full_name":"Anthropic::MessageContent","name":"MessageContent"},{"html_id":"anthropic/JSON/Serializable","kind":"module","full_name":"JSON::Serializable","name":"Serializable"},{"html_id":"anthropic/Anthropic/Resource","kind":"module","full_name":"Anthropic::Resource","name":"Resource"},{"html_id":"anthropic/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"anthropic/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"anthropic/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/message_content.cr","line_number":75,"url":null}],"repository_name":"anthropic","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"anthropic/Anthropic","kind":"module","full_name":"Anthropic","name":"Anthropic"},"constructors":[{"html_id":"new(pull:JSON::PullParser)-class-method","name":"new","abstract":false,"args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"args_string":"(pull : JSON::PullParser)","args_html":"(pull : JSON::PullParser)","location":{"filename":"src/message_content.cr","line_number":75,"url":null},"def":{"name":"new","args":[{"name":"pull","external_name":"pull","restriction":"::JSON::PullParser"}],"visibility":"Public","body":"new_from_json_pull_parser(pull)"}},{"html_id":"new(*,id:String,name:String,input:Hash(String,Array(JSON::Any)|Bool|Float64|Hash(String,JSON::Any)|Int64|String|Nil))-class-method","name":"new","abstract":false,"args":[{"name":"","external_name":"","restriction":""},{"name":"id","external_name":"id","restriction":"::String"},{"name":"name","external_name":"name","restriction":"::String"},{"name":"input","external_name":"input","restriction":"::Hash(::String, ::Array(::JSON::Any) | ::Bool | ::Float64 | ::Hash(::String, ::JSON::Any) | ::Int64 | ::String | ::Nil)"}],"args_string":"(*, id : String, name : String, input : Hash(String, Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil))","args_html":"(*, id : String, name : String, input : Hash(String, Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil))","location":{"filename":"src/message_content.cr","line_number":81,"url":null},"def":{"name":"new","args":[{"name":"","external_name":"","restriction":""},{"name":"id","external_name":"id","restriction":"::String"},{"name":"name","external_name":"name","restriction":"::String"},{"name":"input","external_name":"input","restriction":"::Hash(::String, ::Array(::JSON::Any) | ::Bool | ::Float64 | ::Hash(::String, ::JSON::Any) | ::Int64 | ::String | ::Nil)"}],"splat_index":0,"visibility":"Public","body":"_ = allocate\n_.initialize(id: id, name: name, input: input)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"id:String-instance-method","name":"id","abstract":false,"location":{"filename":"src/message_content.cr","line_number":77,"url":null},"def":{"name":"id","return_type":"String","visibility":"Public","body":"@id"}},{"html_id":"input:Hash(String,JSON::Any::Type)-instance-method","name":"input","abstract":false,"location":{"filename":"src/message_content.cr","line_number":79,"url":null},"def":{"name":"input","return_type":"Hash(String, JSON::Any::Type)","visibility":"Public","body":"@input"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/message_content.cr","line_number":78,"url":null},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/message_content.cr","line_number":76,"url":null},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]}]}]}}) \ No newline at end of file diff --git a/src/api.cr b/src/api.cr index 859ce62..87d1f49 100644 --- a/src/api.cr +++ b/src/api.cr @@ -1,7 +1,7 @@ require "./client" module Anthropic - abstract struct API + private abstract struct API getter client : Client def initialize(@client) diff --git a/src/client.cr b/src/client.cr index facca50..ec391cf 100644 --- a/src/client.cr +++ b/src/client.cr @@ -7,10 +7,31 @@ require "log" require "./tool" require "./error" +# The `Anthropic::Client` is the entrypoint for using the Anthropic API in +# Crystal. +# +# ``` +# claude = Anthropic::Client.new # get API key from the ENV +# puts claude.messages.create( +# model: Anthropic.model_name(:haiku), +# messages: [Anthropic::Message.new("Write a haiku about the Crystal programming language")], +# max_tokens: 4096, +# ) +# # Sparkling Crystal code, +# # Elegant and swift syntax, +# # Shines with precision. +# ``` +# +# The client is concurrency-safe, so you don't need to wrap requests in a mutex +# or manage a connection pool yourself. class Anthropic::Client getter api_key : String getter base_uri : URI + # Instantiate a new client with the API key provided either directly or via + # the `ANTHROPIC_API_KEY` environment variable. You can optionally provide a + # base URI to connect to if you are using a different but compatible API + # provider. def initialize( @api_key = ENV["ANTHROPIC_API_KEY"], @base_uri = URI.parse(ENV.fetch("ANTHROPIC_BASE_URL", "https://api.anthropic.com")), diff --git a/src/event_source.cr b/src/event_source.cr index 4754772..b989e94 100644 --- a/src/event_source.cr +++ b/src/event_source.cr @@ -97,12 +97,12 @@ module Anthropic retry : Int64? = nil abstract struct Event + # :nodoc: TYPE_MAP = {} of String => self.class macro define(type) struct {{type}} < ::Anthropic::Event include Resource - include JSON::Serializable::Unmapped Event::TYPE_MAP[{{type.stringify.underscore}}] = {{type}} @@ -119,17 +119,8 @@ module Anthropic getter index : Int64 getter content_block : ContentBlock? - # {"type" => "content_block_start", - # "index" => 1, - # "content_block" => - # {"type" => "tool_use", - # "id" => "toolu_01CTSNRChbymYy9kk5SeLbsc", - # "name" => "current_time", - # "input" => {}}}) - struct ContentBlock include Resource - include JSON::Serializable::Unmapped getter type : GeneratedMessage::Content::Type? getter id : String? @@ -164,7 +155,6 @@ module Anthropic struct TextDelta include Resource - include JSON::Serializable::Unmapped # This is always the literal "text_delta" # getter type : String diff --git a/src/generated_message.cr b/src/generated_message.cr index 137bbef..560e09e 100644 --- a/src/generated_message.cr +++ b/src/generated_message.cr @@ -144,7 +144,6 @@ struct Anthropic::GeneratedMessage struct Schema include JSON::Serializable - include JSON::Serializable::Unmapped getter properties : JSON::Any end diff --git a/src/messages.cr b/src/messages.cr index 89925a4..d8dcbe0 100644 --- a/src/messages.cr +++ b/src/messages.cr @@ -8,7 +8,7 @@ module Anthropic *, model : String, max_tokens : Int32, - messages : Array(Message), + messages : Array(Anthropic::Message), system : String? = nil, temperature : Float64? = nil, top_k : Int64? = nil, @@ -89,6 +89,8 @@ module Anthropic end end + # Send your prompt to the API and yield `Event`s as they are fed back in. + @[Experimental("Streaming message events kinda/sorta works, but needs further testing")] def create( *, model : String, @@ -98,7 +100,8 @@ module Anthropic temperature : Float64? = nil, top_k : Int64? = nil, top_p : Float64? = nil, - tools : Array(Tool)? = client.tools.values, + # Tools are not supported yet for the block form of the method. + # tools : Array(Tool)? = client.tools.values, &block : Event -> T ) forall T client.http do |http| @@ -188,7 +191,7 @@ module Anthropic end end - module Converters + private module Converters module TimeSpan extend self