instructor-rb 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5baca74deed1078f1695501139db2033ca2cb4b1e0d414ba9898b13100263bed
4
- data.tar.gz: b845048bd4b712181eab322d94ba20fd64aae15eb3949560028ff3a4058d594c
3
+ metadata.gz: c5f3b630f135c5ab67b275814d8986b732a0deac2a8cb751189444d5774ab169
4
+ data.tar.gz: cc25330573de9056fdf7e6c5f14d4fb143777b9f26a7d085e00499df6610c8da
5
5
  SHA512:
6
- metadata.gz: a949d892bf2fef53c9c34fd06da30b143e08acdfc8967e428b262eedc7eabcc7147421f1b41dcde2007fe58677c808a1ca6bb9dc1be72a4f9c20c3a5474a91bb
7
- data.tar.gz: ccfc2bf5c2c702b226972895eb290c68f2a625b688936979d9f5093e39e185f1c8423aedc4f40537b3b1ad2d313ea73e4f058491bbacadb075ad3cca1cacaae7
6
+ metadata.gz: 90ce22b6ca7bdc23a063b7fcee1329a194cc493b71803902d2455d0c22d105de7506c7387f6b0e7b682405493dc7eb9c7da68e6da68feedb89bdbcbea598cea2
7
+ data.tar.gz: f6ebf426c755b1d55cb809d75c56a38e5861515419e61e235097c2033729abf8e7e9df200146844c742fcc17fb8b984b4b6cd11d751927a1d93760db321f670c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.1.2] - 2024-05-17
2
+ - Improved the ability to customize the function name and the LLM function call description (instructions).
3
+
1
4
  ## [0.1.1] - 2024-05-07
2
5
  - Improved documentation in /docs folder.
3
6
  - Readme updates.
@@ -118,19 +118,29 @@ module Instructor
118
118
  {
119
119
  type: 'function',
120
120
  function: {
121
- name: model.name.humanize.titleize,
121
+ name: generate_function_name(model),
122
122
  description: generate_description(model),
123
123
  parameters: model.json_schema
124
124
  }
125
125
  }
126
126
  end
127
127
 
128
+ def generate_function_name(model)
129
+ model.schema.fetch(:title, model.name)
130
+ end
131
+
128
132
  # Generates the description for the function.
129
133
  #
130
134
  # @param model [Class] The response model class.
131
135
  # @return [String] The generated description.
132
136
  def generate_description(model)
133
- "Correctly extracted `#{model.name}` with all the required parameters with correct types"
137
+ if model.respond_to?(:instructions)
138
+ raise Instructor::Error, 'The instructions must be a string' unless model.instructions.is_a?(String)
139
+
140
+ model.instructions
141
+ else
142
+ "Correctly extracted `#{model.name}` with all the required parameters with correct types"
143
+ end
134
144
  end
135
145
 
136
146
  # Checks if the response is iterable.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Instructor
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instructor-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Bayona
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-05-07 00:00:00.000000000 Z
12
+ date: 2024-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport