easy_talk 0.1.7 → 0.1.8
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 +4 -4
- data/.rubocop.yml +17 -1
- data/CHANGELOG.md +3 -0
- data/Rakefile +1 -2
- data/lib/easy_talk/builders/object_builder.rb +1 -1
- data/lib/easy_talk/property.rb +33 -9
- data/lib/easy_talk/tools/function_builder.rb +6 -0
- data/lib/easy_talk/version.rb +1 -1
- metadata +89 -6
- data/easy_talk.gemspec +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da6e2b2c29860236280b654d18e4df4af908ab0246f01e1e5e376805f8359d37
|
4
|
+
data.tar.gz: 1a36d4e08f82069391386c3b2bd03becfeaea198657b8db05ff2ebda793d4ec8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9026006c5e296adf2f3a7c826757ffe4b17a1387c3621907442ac47293d2d7d89eb4779fe3863ef24f6a8fc34174a7b4e7e22d2aaf0a26a4534ddc65f08ab482
|
7
|
+
data.tar.gz: d3cd70fb2ac65241cf395606d0eae55e2282006578f4f78096f9e03256ae6fa91bd371b0874d20aa797667b4972be4ff91c5b38b4396ee1be89a3b4d057d4681
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
TargetRubyVersion: 3.2
|
7
|
+
|
8
|
+
RSpec/FilePath:
|
9
|
+
SpecSuffixOnly: true
|
10
|
+
|
11
|
+
RSpec/ExampleLength:
|
12
|
+
Max: 10
|
13
|
+
Exclude:
|
14
|
+
- 'spec/easy_talk/examples/**/*'
|
3
15
|
|
4
16
|
Metrics/BlockLength:
|
5
17
|
Exclude:
|
@@ -11,4 +23,8 @@ Lint/ConstantDefinitionInBlock:
|
|
11
23
|
|
12
24
|
Layout/LineLength:
|
13
25
|
Exclude:
|
14
|
-
- 'spec/**/*'
|
26
|
+
- 'spec/**/*'
|
27
|
+
|
28
|
+
RSpec/DescribeClass:
|
29
|
+
Exclude:
|
30
|
+
- 'spec/easy_talk/examples/**/*'
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/lib/easy_talk/property.rb
CHANGED
@@ -17,6 +17,16 @@ require_relative 'builders/union_builder'
|
|
17
17
|
|
18
18
|
# frozen_string_literal: true
|
19
19
|
|
20
|
+
# EasyTalk module provides classes for building JSON schema properties.
|
21
|
+
#
|
22
|
+
# This module contains the `Property` class, which is used to build a JSON schema property.
|
23
|
+
# It also defines a constant `TYPE_TO_BUILDER` which maps property types to their respective builders.
|
24
|
+
#
|
25
|
+
# Example usage:
|
26
|
+
# property = EasyTalk::Property.new(:name, 'String', minLength: 3, maxLength: 50)
|
27
|
+
# property.build
|
28
|
+
#
|
29
|
+
# @see EasyTalk::Property
|
20
30
|
module EasyTalk
|
21
31
|
# Property class for building a JSON schema property.
|
22
32
|
class Property
|
@@ -56,22 +66,36 @@ module EasyTalk
|
|
56
66
|
raise ArgumentError, 'property type is missing' if type.blank?
|
57
67
|
end
|
58
68
|
|
69
|
+
# Builds the property based on the specified type, constraints, and builder.
|
70
|
+
#
|
71
|
+
# If the type responds to the `schema` method, it returns the schema of the type.
|
72
|
+
# Otherwise, it returns 'object'.
|
73
|
+
#
|
74
|
+
# If a builder is specified, it uses the builder to build the property.
|
75
|
+
# The arguments passed to the builder depend on whether the builder is a collection type or not.
|
76
|
+
#
|
77
|
+
# @return [Object] The built property.
|
59
78
|
def build
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
builder.new(name, constraints).build
|
65
|
-
end
|
66
|
-
else
|
67
|
-
type.respond_to?(:schema) ? type.schema : 'object'
|
68
|
-
end
|
79
|
+
return type.respond_to?(:schema) ? type.schema : 'object' unless builder
|
80
|
+
|
81
|
+
args = builder.collection_type? ? [name, type, constraints] : [name, constraints]
|
82
|
+
builder.new(*args).build
|
69
83
|
end
|
70
84
|
|
85
|
+
# Converts the object to a JSON representation.
|
86
|
+
#
|
87
|
+
# @param _args [Array] Optional arguments
|
88
|
+
# @return [Hash] The JSON representation of the object
|
71
89
|
def as_json(*_args)
|
72
90
|
build.as_json
|
73
91
|
end
|
74
92
|
|
93
|
+
# Returns the builder associated with the property type.
|
94
|
+
#
|
95
|
+
# The builder is responsible for constructing the property based on its type.
|
96
|
+
# It looks up the builder based on the type's class name or name.
|
97
|
+
#
|
98
|
+
# @return [Builder] The builder associated with the property type.
|
75
99
|
def builder
|
76
100
|
TYPE_TO_BUILDER[type.class.name.to_s] || TYPE_TO_BUILDER[type.name.to_s]
|
77
101
|
end
|
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
module EasyTalk
|
4
4
|
module Tools
|
5
|
+
# FunctionBuilder is a module that builds a hash with the function type and function details.
|
6
|
+
# The return value is typically passed as argument to LLM function calling APIs.
|
5
7
|
module FunctionBuilder
|
8
|
+
# Creates a new function object based on the given model.
|
9
|
+
#
|
10
|
+
# @param [Model] model The EasyTalk model containing the function details.
|
11
|
+
# @return [Hash] The function object.
|
6
12
|
def self.new(model)
|
7
13
|
{
|
8
14
|
type: 'function',
|
data/lib/easy_talk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_talk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Bayona
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.10
|
61
|
+
version: '3.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.10
|
68
|
+
version: '3.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,90 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '13.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-json_expectations
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec-mocks
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.13'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.13'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.21'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.21'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.6'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.6'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '2.29'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '2.29'
|
83
167
|
description: Generate json-schema from plain Ruby classes.
|
84
168
|
email:
|
85
169
|
- bayona.sergio@gmail.com
|
@@ -93,7 +177,6 @@ files:
|
|
93
177
|
- LICENSE.txt
|
94
178
|
- README.md
|
95
179
|
- Rakefile
|
96
|
-
- easy_talk.gemspec
|
97
180
|
- lib/easy_talk.rb
|
98
181
|
- lib/easy_talk/builders/all_of_builder.rb
|
99
182
|
- lib/easy_talk/builders/any_of_builder.rb
|
@@ -146,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
229
|
- !ruby/object:Gem::Version
|
147
230
|
version: '0'
|
148
231
|
requirements: []
|
149
|
-
rubygems_version: 3.5.
|
232
|
+
rubygems_version: 3.5.9
|
150
233
|
signing_key:
|
151
234
|
specification_version: 4
|
152
235
|
summary: Generate json-schema from Ruby classes.
|
data/easy_talk.gemspec
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'lib/easy_talk/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'easy_talk'
|
7
|
-
spec.version = EasyTalk::VERSION
|
8
|
-
spec.authors = ['Sergio Bayona']
|
9
|
-
spec.email = ['bayona.sergio@gmail.com']
|
10
|
-
|
11
|
-
spec.summary = 'Generate json-schema from Ruby classes.'
|
12
|
-
spec.description = 'Generate json-schema from plain Ruby classes.'
|
13
|
-
spec.homepage = 'https://github.com/sergiobayona/easy_talk'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = '>= 3.2'
|
16
|
-
|
17
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
-
|
19
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
-
spec.metadata['source_code_uri'] = 'https://github.com/sergiobayona/easy_talk'
|
21
|
-
spec.metadata['changelog_uri'] = 'https://github.com/sergiobayona/easy_talk/blob/main/CHANGELOG.md'
|
22
|
-
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files = Dir.chdir(__dir__) do
|
26
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
(File.expand_path(f) == __FILE__) ||
|
28
|
-
f.start_with?(*%w[bin/ spec/ .git .github Gemfile])
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
spec.require_paths = ['lib']
|
33
|
-
|
34
|
-
spec.add_dependency 'activesupport', '~> 7.0'
|
35
|
-
spec.add_dependency 'json-schema', '~> 4'
|
36
|
-
spec.add_dependency 'sorbet-runtime', '~> 0.5'
|
37
|
-
spec.add_development_dependency 'pry-byebug', '>= 3.10.1'
|
38
|
-
spec.add_development_dependency 'rake', '~> 13.1'
|
39
|
-
end
|