instructor-rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +38 -0
- data/LICENSE +21 -0
- data/README.md +111 -0
- data/Rakefile +11 -0
- data/bin/console +8 -0
- data/ellipsis.Dockerfile +12 -0
- data/ellipsis.yaml +38 -0
- data/lib/instructor/openai/patch.rb +144 -0
- data/lib/instructor/openai/response.rb +71 -0
- data/lib/instructor/version.rb +5 -0
- data/lib/instructor.rb +28 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 65a1936ae4e512d2ec6606f592ef35be36dbf80b2013abe099056ab3048f5c7d
|
4
|
+
data.tar.gz: d094e3894f65f1d0062be5cfbd8e3c07bb9572f62e78425990e64c2c46e78425
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b2eb9e6ad25aabe51a7e04d6fae1526228c362608daf00608aa0035577981e21fbe091fe138f7e09f3d9d58f062ab5f6bdc0ae77f7c88de2d95564b64191840
|
7
|
+
data.tar.gz: b1faeba25a79bb016becce490488d7cd06bc546ab5e7f9a1ec8c1d6d26ce3ee9115de665625a790f47b6463e280c77f4b9b90f976192e68d9b2b597dd4f88a7d
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.1
|
7
|
+
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Exclude:
|
10
|
+
- 'spec/**/*'
|
11
|
+
|
12
|
+
Lint/ConstantDefinitionInBlock:
|
13
|
+
Exclude:
|
14
|
+
- 'spec/**/*'
|
15
|
+
|
16
|
+
Layout/LineLength:
|
17
|
+
Exclude:
|
18
|
+
- 'spec/**/*'
|
19
|
+
|
20
|
+
RSpec/FilePath:
|
21
|
+
SpecSuffixOnly: true
|
22
|
+
|
23
|
+
RSpec/MultipleExpectations:
|
24
|
+
Max: 4
|
25
|
+
|
26
|
+
RSpec/ExampleLength:
|
27
|
+
Max: 10
|
28
|
+
Exclude:
|
29
|
+
- spec/examples/*
|
30
|
+
|
31
|
+
RSpec/DescribeClass:
|
32
|
+
Exclude:
|
33
|
+
- spec/examples/*
|
34
|
+
- spec/features/*
|
35
|
+
|
36
|
+
RSpec/MethodLength:
|
37
|
+
Exclude:
|
38
|
+
- spec/examples/*
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 instructor
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# instructor-rb
|
2
|
+
|
3
|
+
_Structured extraction in Ruby, powered by llms, designed for simplicity, transparency, and control._
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
[](https://twitter.com/jxnlco)
|
8
|
+
[](https://jxnl.github.io/instructor-rb)
|
9
|
+
[](https://github.com/instructor-ai/instructor-rb/issues)
|
10
|
+
[](https://discord.gg/CV8sPM5k5Y)
|
11
|
+
|
12
|
+
Dive into the world of Ruby-based structured extraction, by OpenAI's function calling API and ActiveRecord, ruby-first schema validation with type inference. Instructor stands out for its simplicity, transparency, and user-centric design. Whether you're a seasoned developer or just starting out, you'll find Instructor's approach intuitive and steerable.
|
13
|
+
|
14
|
+
> ℹ️ **Tip:** Support in other languages
|
15
|
+
|
16
|
+
Check out ports to other languages below:
|
17
|
+
|
18
|
+
- [Python](https://www.github.com/jxnl/instructor)
|
19
|
+
- [TS/JS](https://github.com/instructor-ai/instructor-js/)
|
20
|
+
- [Ruby](https://github.com/instructor-ai/instructor-rb)
|
21
|
+
- [Elixir](https://github.com/thmsmlr/instructor_ex/)
|
22
|
+
|
23
|
+
If you want to port Instructor to another language, please reach out to us on [Twitter](https://twitter.com/jxnlco) we'd love to help you get started!
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
export your OpenAI API key:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
export OPENAI_API_KEY=sk-...
|
31
|
+
```
|
32
|
+
|
33
|
+
Then use Instructor to extract structured data from text in Ruby:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require 'instructor'
|
37
|
+
|
38
|
+
class UserDetail
|
39
|
+
include EasyTalk::Model
|
40
|
+
|
41
|
+
define_schema do
|
42
|
+
property :name, String
|
43
|
+
property :age, Integer
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
client = Instructor.patch(OpenAI::Client).new
|
48
|
+
|
49
|
+
user = client.chat(
|
50
|
+
parameters: {
|
51
|
+
model: 'gpt-3.5-turbo',
|
52
|
+
messages: [{ role: 'user', content: 'Extract Jason is 25 years old' }]
|
53
|
+
},
|
54
|
+
response_model: UserDetail
|
55
|
+
)
|
56
|
+
|
57
|
+
puts(user.inspect)
|
58
|
+
{"name"=>"Jason", "age"=>25}
|
59
|
+
```
|
60
|
+
|
61
|
+
## Why use Instructor?
|
62
|
+
|
63
|
+
|
64
|
+
1. **OpenAI Integration** — Integrates seamlessly with OpenAI's API, facilitating efficient data management and manipulation.
|
65
|
+
|
66
|
+
2. **Customizable** — It offers significant flexibility. Users can tailor validation processes and define unique error messages.
|
67
|
+
|
68
|
+
3. **Widespread Adoption** — As a primary component in Ruby on Rails, it's widely used and backed by a substantial community.
|
69
|
+
|
70
|
+
4. **Tested and Trusted** — Its reliability is proven by extensive real-world application, underscored by its high adoption rate in Ruby-based projects.
|
71
|
+
|
72
|
+
## More Examples
|
73
|
+
|
74
|
+
If you'd like to see more check out our [cookbook](examples/index.md).
|
75
|
+
|
76
|
+
[Installing Instructor](installation.md) is a breeze.
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
If you want to help out, checkout some of the issues marked as `good-first-issue` or `help-wanted`. Found [here](https://github.com/instructor-ai/instructor-js/labels/good%20first%20issue). They could be anything from code improvements, a guest blog post, or a new cook book.
|
81
|
+
|
82
|
+
Checkout the [contribution guide]() for details on how to set things up, testing, changesets and guidelines.
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
This project is licensed under the terms of the MIT License.
|
87
|
+
|
88
|
+
## TODO
|
89
|
+
- [ ] Add patch
|
90
|
+
- [ ] Mode.FUNCTIONS
|
91
|
+
- [ ] Mode.TOOLS
|
92
|
+
- [ ] Mode.MD_JSON
|
93
|
+
- [ ] Mode.JSON
|
94
|
+
- [ ] Add response_model
|
95
|
+
- [ ] Support async
|
96
|
+
- [ ] Support stream=True, Partial[T] and iterable[T]
|
97
|
+
- [ ] Support Streaming
|
98
|
+
- [ ] Optional/Maybe types
|
99
|
+
- [ ] Add Tutorials, include in docs
|
100
|
+
- [ ] Text Classification
|
101
|
+
- [ ] Search Queries
|
102
|
+
- [ ] Query Decomposition
|
103
|
+
- [ ] Citations
|
104
|
+
- [ ] Knowledge Graph
|
105
|
+
- [ ] Self Critique
|
106
|
+
- [ ] Image Extracting Tables
|
107
|
+
- [ ] Moderation
|
108
|
+
- [ ] Entity Resolution
|
109
|
+
- [ ] Action Item and Dependency Mapping
|
110
|
+
- [ ] Logging for Distillation / Finetuning
|
111
|
+
- [ ] Add `llm_validator`
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/ellipsis.Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#======================================
|
2
|
+
# This Dockerfile was generated by Ellipsis.
|
3
|
+
# It should be referenced from your `ellipsis.yaml` config file.
|
4
|
+
# For more details, see documentation: https://docs.ellipsis.dev
|
5
|
+
# Test with: $ docker build -f ellipsis.Dockerfile .
|
6
|
+
#======================================
|
7
|
+
|
8
|
+
FROM ubuntu:20.04
|
9
|
+
RUN apt-get update && apt-get install -y git build-essential
|
10
|
+
|
11
|
+
WORKDIR /app
|
12
|
+
COPY . .
|
data/ellipsis.yaml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# See https://docs.ellipsis.dev for all available configurations.
|
2
|
+
|
3
|
+
version: 1.1
|
4
|
+
pr_review:
|
5
|
+
auto_review_enabled: true # enable auto-review of PRs
|
6
|
+
auto_summarize_pr: true # enable auto-summary of PRs
|
7
|
+
confidence_threshold: 0.5 # Threshold for how confident Ellipsis needs to be in order to leave a comment, in range [0.0-1.0]
|
8
|
+
rules: # customize behavior
|
9
|
+
- "Code should be DRY (Don't Repeat Yourself)"
|
10
|
+
- "There should no secrets or credentials in the code"
|
11
|
+
|
12
|
+
# users can customize their own behavior
|
13
|
+
user_overrides:
|
14
|
+
# @hbrooks has disabled auto-summary and added a custom rule
|
15
|
+
- usernames: ["hbrooks"]
|
16
|
+
auto_summarize_pr: false
|
17
|
+
rules:
|
18
|
+
- "Code should be DRY (Don't Repeat Yourself)"
|
19
|
+
|
20
|
+
|
21
|
+
# Below is an example of how to configure Ellipsis to build and run your repo.
|
22
|
+
# Uncomment and replace with your own Dockerfile and commands.
|
23
|
+
|
24
|
+
dockerfile: "ellipsis.Dockerfile" # this will be used to build your repo
|
25
|
+
|
26
|
+
#=======================
|
27
|
+
# commands:
|
28
|
+
# - name: "build"
|
29
|
+
# description: "This command compiles the code and builds the project"
|
30
|
+
# command: "yarn build"
|
31
|
+
# return_output_on_success: false # If output isn't useful when the command succeeds
|
32
|
+
# auto_repair: true # Run this after every code change
|
33
|
+
# - name: "lint_fix"
|
34
|
+
# description: "Lints the code in fix mode, which will fix some errors."
|
35
|
+
# command: "yarn lint:fix"
|
36
|
+
# return_output_on_success: false
|
37
|
+
# auto_repair: true
|
38
|
+
#=======================
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The Instructor module provides functionality for interacting with OpenAI's chat API.
|
4
|
+
module Instructor
|
5
|
+
module OpenAI
|
6
|
+
# The `Patch` module provides methods for patching and modifying the OpenAI client behavior.
|
7
|
+
module Patch
|
8
|
+
# Executes a block of code with retries in case of specific exceptions.
|
9
|
+
#
|
10
|
+
# @param max_retries [Integer] The maximum number of retries.
|
11
|
+
# @param exceptions [Array<Class>] The exceptions to catch and retry.
|
12
|
+
# @yield The block of code to execute.
|
13
|
+
def with_retries(max_retries, exceptions, &block)
|
14
|
+
attempts = 0
|
15
|
+
begin
|
16
|
+
block.call
|
17
|
+
rescue *exceptions
|
18
|
+
attempts += 1
|
19
|
+
retry if attempts < max_retries
|
20
|
+
raise
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Sends a chat request to the API and processes the response.
|
25
|
+
#
|
26
|
+
# @param parameters [Hash] The parameters for the chat request as expected by the OpenAI client.
|
27
|
+
# @param response_model [Class] The response model class.
|
28
|
+
# @param max_retries [Integer] The maximum number of retries. Default is 0.
|
29
|
+
# @param validation_context [Hash] The validation context for the parameters. Optional.
|
30
|
+
# @return [Object] The processed response.
|
31
|
+
def chat(parameters:, response_model: nil, max_retries: 0, validation_context: nil)
|
32
|
+
with_retries(max_retries, [JSON::ParserError, Instructor::ValidationError, Faraday::ParsingError]) do
|
33
|
+
model = determine_model(response_model)
|
34
|
+
function = build_function(model)
|
35
|
+
parameters = prepare_parameters(parameters, validation_context, function)
|
36
|
+
response = json_post(path: '/chat/completions', parameters:)
|
37
|
+
process_response(response, model)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Prepares the parameters for the chat request.
|
42
|
+
#
|
43
|
+
# @param parameters [Hash] The original parameters.
|
44
|
+
# @param validation_context [Hash] The validation context for the parameters.
|
45
|
+
# @param function [Hash] The function details.
|
46
|
+
# @return [Hash] The prepared parameters.
|
47
|
+
def prepare_parameters(parameters, validation_context, function)
|
48
|
+
parameters = apply_validation_context(parameters, validation_context)
|
49
|
+
parameters.merge(tools: [function])
|
50
|
+
end
|
51
|
+
|
52
|
+
# Processes the API response.
|
53
|
+
#
|
54
|
+
# @param response [Hash] The API response.
|
55
|
+
# @param model [Class] The response model class.
|
56
|
+
# @return [Object] The processed response.
|
57
|
+
def process_response(response, model)
|
58
|
+
parsed_response = Response.new(response).parse
|
59
|
+
iterable? ? process_multiple_responses(parsed_response, model) : process_single_response(parsed_response, model)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Processes multiple responses from the API.
|
63
|
+
#
|
64
|
+
# @param parsed_response [Array<Hash>] The parsed API responses.
|
65
|
+
# @param model [Class] The response model class.
|
66
|
+
# @return [Array<Object>] The processed responses.
|
67
|
+
def process_multiple_responses(parsed_response, model)
|
68
|
+
parsed_response.map do |response|
|
69
|
+
instance = model.new(response)
|
70
|
+
instance.valid? ? instance : raise(Instructor::ValidationError)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Processes a single response from the API.
|
75
|
+
#
|
76
|
+
# @param parsed_response [Hash] The parsed API response.
|
77
|
+
# @param model [Class] The response model class.
|
78
|
+
# @return [Object] The processed response.
|
79
|
+
def process_single_response(parsed_response, model)
|
80
|
+
instance = model.new(parsed_response)
|
81
|
+
instance.valid? ? instance : raise(Instructor::ValidationError)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Determines the response model based on the provided value.
|
85
|
+
#
|
86
|
+
# @param response_model [Class] The response model class or typed array.
|
87
|
+
# @return [Class] The determined response model class.
|
88
|
+
def determine_model(response_model)
|
89
|
+
if response_model.is_a?(T::Types::TypedArray)
|
90
|
+
@iterable = true
|
91
|
+
response_model.type.raw_type
|
92
|
+
else
|
93
|
+
@iterable = false
|
94
|
+
response_model
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Applies the validation context to the parameters.
|
99
|
+
#
|
100
|
+
# @param parameters [Hash] The original parameters.
|
101
|
+
# @param validation_context [Hash] The validation context.
|
102
|
+
# @return [Hash] The parameters with applied validation context.
|
103
|
+
def apply_validation_context(parameters, validation_context)
|
104
|
+
return parameters unless validation_context.is_a?(Hash)
|
105
|
+
|
106
|
+
Array[validation_context].each_with_index do |message, index|
|
107
|
+
parameters[:messages][index][:content] = parameters[:messages][index][:content] % message
|
108
|
+
end
|
109
|
+
|
110
|
+
parameters
|
111
|
+
end
|
112
|
+
|
113
|
+
# Builds the function details for the API request.
|
114
|
+
#
|
115
|
+
# @param model [Class] The response model class.
|
116
|
+
# @return [Hash] The function details.
|
117
|
+
def build_function(model)
|
118
|
+
{
|
119
|
+
type: 'function',
|
120
|
+
function: {
|
121
|
+
name: model.name.humanize.titleize,
|
122
|
+
description: generate_description(model),
|
123
|
+
parameters: model.json_schema
|
124
|
+
}
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
128
|
+
# Generates the description for the function.
|
129
|
+
#
|
130
|
+
# @param model [Class] The response model class.
|
131
|
+
# @return [String] The generated description.
|
132
|
+
def generate_description(model)
|
133
|
+
"Correctly extracted `#{model.name}` with all the required parameters with correct types"
|
134
|
+
end
|
135
|
+
|
136
|
+
# Checks if the response is iterable.
|
137
|
+
#
|
138
|
+
# @return [Boolean] `true` if the response is iterable, `false` otherwise.
|
139
|
+
def iterable?
|
140
|
+
@iterable
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Instructor
|
4
|
+
module OpenAI
|
5
|
+
# The Response class represents the response received from the OpenAI API.
|
6
|
+
# It takes the raw response and provides convenience methods to access the chat completions,
|
7
|
+
# tool calls, function responses, and parsed arguments.
|
8
|
+
class Response
|
9
|
+
# Initializes a new instance of the Response class.
|
10
|
+
#
|
11
|
+
# @param response [Hash] The response received from the OpenAI API.
|
12
|
+
def initialize(response)
|
13
|
+
@response = response
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the chat completions from the response.
|
17
|
+
#
|
18
|
+
# @return [Array] An array of chat completions.
|
19
|
+
def chat_completions
|
20
|
+
@response['choices']
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns the tool calls from the chat completions.
|
24
|
+
#
|
25
|
+
# @return [Hash, nil] The tool calls or nil if not found.
|
26
|
+
def tool_calls
|
27
|
+
chat_completions&.dig(0, 'message', 'tool_calls')
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns the function responses from the tool calls.
|
31
|
+
#
|
32
|
+
# @return [Array, nil] An array of function responses or nil if not found.
|
33
|
+
def function_responses
|
34
|
+
tool_calls&.map { |tool_call| tool_call['function'] }
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the first function response.
|
38
|
+
#
|
39
|
+
# @return [Hash, nil] The first function response or nil if not found.
|
40
|
+
def function_response
|
41
|
+
function_responses&.first
|
42
|
+
end
|
43
|
+
|
44
|
+
# Checks if there is only a single function response.
|
45
|
+
#
|
46
|
+
# @return [Boolean] True if there is only a single function response, false otherwise.
|
47
|
+
def single_response?
|
48
|
+
function_responses&.size == 1
|
49
|
+
end
|
50
|
+
|
51
|
+
# Parses the function response(s) and returns the parsed arguments.
|
52
|
+
#
|
53
|
+
# @return [Array, Hash] The parsed arguments.
|
54
|
+
def parse
|
55
|
+
if single_response?
|
56
|
+
JSON.parse(function_response['arguments'])
|
57
|
+
else
|
58
|
+
function_responses.map { |res| JSON.parse(res['arguments']) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the arguments of the function with the specified name.
|
63
|
+
#
|
64
|
+
# @param function_name [String] The name of the function.
|
65
|
+
# @return [Hash, nil] The arguments of the function or nil if not found.
|
66
|
+
def by_function_name(function_name)
|
67
|
+
function_responses&.find { |res| res['name'] == function_name }&.dig('arguments')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/instructor.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'openai'
|
4
|
+
require 'easy_talk'
|
5
|
+
require 'active_support/all'
|
6
|
+
require_relative 'instructor/version'
|
7
|
+
require_relative 'instructor/openai/patch'
|
8
|
+
require_relative 'instructor/openai/response'
|
9
|
+
|
10
|
+
# Instructor makes it easy to reliably get structured data like JSON from Large Language Models (LLMs)
|
11
|
+
# like GPT-3.5, GPT-4, GPT-4-Vision
|
12
|
+
module Instructor
|
13
|
+
class Error < ::StandardError; end
|
14
|
+
|
15
|
+
# The ValidationError class represents an error that occurs during validation.
|
16
|
+
class ValidationError < ::StandardError; end
|
17
|
+
|
18
|
+
# Patches the OpenAI client to add the following functionality:
|
19
|
+
# - Retries on exceptions
|
20
|
+
# - Accepts and validates a response model
|
21
|
+
# - Accepts a validation_context argument
|
22
|
+
#
|
23
|
+
# @param openai_client [OpenAI::Client] The OpenAI client to be patched.
|
24
|
+
# @return [OpenAI::Client] The patched OpenAI client.
|
25
|
+
def self.patch(openai_client)
|
26
|
+
openai_client.prepend(Instructor::OpenAI::Patch)
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: instructor-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergio Bayona
|
8
|
+
- Jason Liu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '7.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '7.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: easy_talk
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.1.8
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.1.8
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: ruby-openai
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '6'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '6'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry-byebug
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.10'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.10'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '13.1'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '13.1'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec-json_expectations
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '2.0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rubocop
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.21'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.21'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rubocop-rake
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0.6'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.6'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop-rspec
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2.29'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '2.29'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: vcr
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '6.0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '6.0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: webmock
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '3.13'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '3.13'
|
182
|
+
description: Explore the power of LLM structured extraction in Ruby with the Instructor
|
183
|
+
gem.
|
184
|
+
email:
|
185
|
+
- bayona.sergio@gmail.com
|
186
|
+
- jason@jxnl.co
|
187
|
+
executables: []
|
188
|
+
extensions: []
|
189
|
+
extra_rdoc_files: []
|
190
|
+
files:
|
191
|
+
- ".rubocop.yml"
|
192
|
+
- LICENSE
|
193
|
+
- README.md
|
194
|
+
- Rakefile
|
195
|
+
- bin/console
|
196
|
+
- ellipsis.Dockerfile
|
197
|
+
- ellipsis.yaml
|
198
|
+
- lib/instructor.rb
|
199
|
+
- lib/instructor/openai/patch.rb
|
200
|
+
- lib/instructor/openai/response.rb
|
201
|
+
- lib/instructor/version.rb
|
202
|
+
homepage: https://github.com/instructor-ai/instructor-rb
|
203
|
+
licenses:
|
204
|
+
- MIT
|
205
|
+
metadata:
|
206
|
+
allowed_push_host: https://rubygems.org
|
207
|
+
homepage_uri: https://github.com/instructor-ai/instructor-rb
|
208
|
+
source_code_uri: https://github.com/instructor-ai/instructor-rb
|
209
|
+
changelog_uri: https://github.com/instructor-ai/instructor-rb/blob/main/CHANGELOG.md
|
210
|
+
post_install_message:
|
211
|
+
rdoc_options: []
|
212
|
+
require_paths:
|
213
|
+
- lib
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: 3.1.0
|
219
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
requirements: []
|
225
|
+
rubygems_version: 3.5.9
|
226
|
+
signing_key:
|
227
|
+
specification_version: 4
|
228
|
+
summary: Structured extraction in Ruby, powered by llms.
|
229
|
+
test_files: []
|