easy_talk 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/easy_talk/model.rb +19 -0
- data/lib/easy_talk/tools/function_builder.rb +20 -0
- data/lib/easy_talk/version.rb +1 -1
- data/lib/easy_talk.rb +1 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef35c90e8f4ecd74af7743e5c4e8503a3f1df9099c4395c5d8376d8b7be2f325
|
4
|
+
data.tar.gz: 85e4bec40186ed896834b59707ad68a9ede133db9fe1c4da99570de416f8abb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a74dd4133b14bb81882224e06c97488be0ac1e85e4c3a52452c3ce396a52928aefc13de45a7e284c846ae8acc09e73043381bb46d9acad7cfcfdfcf5e290a45
|
7
|
+
data.tar.gz: 0f78ef87354030469e5c9b8897331870a1232724bc33a2e6d0af7bffaf44617f86e8ecd4a44684955d964d9dd55fbdca5944a14699db49fc981d0803a31489a9
|
data/CHANGELOG.md
CHANGED
data/lib/easy_talk/model.rb
CHANGED
@@ -24,6 +24,21 @@ module EasyTalk
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def initialize(properties = {})
|
28
|
+
properties.each do |key, value|
|
29
|
+
instance_variable_set("@#{key}", value)
|
30
|
+
self.class.class_eval { attr_reader key }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def valid?
|
35
|
+
self.class.validate_json(properties)
|
36
|
+
end
|
37
|
+
|
38
|
+
def properties
|
39
|
+
as_json.symbolize_keys!
|
40
|
+
end
|
41
|
+
|
27
42
|
# This module provides extension methods for subclasses with schema definitions.
|
28
43
|
module SubclassExtension
|
29
44
|
# Returns true if the class inherits a schema.
|
@@ -82,6 +97,10 @@ module EasyTalk
|
|
82
97
|
"#/$defs/#{name}"
|
83
98
|
end
|
84
99
|
|
100
|
+
def function_name
|
101
|
+
name.humanize.titleize
|
102
|
+
end
|
103
|
+
|
85
104
|
def validate_json(json)
|
86
105
|
JSON::Validator.validate(json_schema, json)
|
87
106
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module EasyTalk
|
2
|
+
module Tools
|
3
|
+
module FunctionBuilder
|
4
|
+
def self.new(model)
|
5
|
+
{
|
6
|
+
type: 'function',
|
7
|
+
function: {
|
8
|
+
name: model.function_name,
|
9
|
+
description: generate_description(model),
|
10
|
+
parameters: model.json_schema
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.generate_description(model)
|
16
|
+
"Correctly extracted `#{model.name}` with all the required parameters with correct types"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/easy_talk/version.rb
CHANGED
data/lib/easy_talk.rb
CHANGED
@@ -12,16 +12,9 @@ module EasyTalk
|
|
12
12
|
require 'easy_talk/builder'
|
13
13
|
require 'easy_talk/property'
|
14
14
|
require 'easy_talk/schema_definition'
|
15
|
+
require 'easy_talk/tools/function_builder'
|
15
16
|
require 'easy_talk/version'
|
16
17
|
|
17
18
|
class UnsupportedTypeError < ArgumentError; end
|
18
19
|
class UnsupportedConstraintError < ArgumentError; end
|
19
|
-
|
20
|
-
def self.schemas
|
21
|
-
@schemas ||= {}
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.add_schema(ref, schema)
|
25
|
-
schemas[ref] = schema
|
26
|
-
end
|
27
20
|
end
|
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.6
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/easy_talk/property.rb
|
119
119
|
- lib/easy_talk/schema_definition.rb
|
120
120
|
- lib/easy_talk/sorbet_extension.rb
|
121
|
+
- lib/easy_talk/tools/function_builder.rb
|
121
122
|
- lib/easy_talk/types/all_of.rb
|
122
123
|
- lib/easy_talk/types/any_of.rb
|
123
124
|
- lib/easy_talk/types/base_composer.rb
|