raix 0.4.1 → 0.4.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: 00be6de8258fbe226ea622d4d0e591fa6035ddd8d5ad627dd316291561317355
4
- data.tar.gz: 2749f23745e8385a770d1214c131c3babd2b48e2c983c10eaa1775ae85151879
3
+ metadata.gz: cd88f295667264948d2710fb7eb0bcd74e5ab0177e76678314c34958e79fa6bd
4
+ data.tar.gz: b86495b4b67c5259915a7ef20502005d90ededf6be991821703d1d83e876c572
5
5
  SHA512:
6
- metadata.gz: 561520feed1ab27d400e1482ecc3a3740fdb3d21b0ac09603f59b1b798facf9d6bb83f910c4f77b66ce7b5a60d6278bbe174429853e74aa5e5ccda771603566e
7
- data.tar.gz: 537a7d27ad0d9a717f52bdb7a0aaa0d6f8479f0261f9730f18d0e93255c734e027d577d9284425a213d151fb08dd95c2f988a21015cd7746706e989dedb91cd0
6
+ metadata.gz: cf1982b065312860c046a363486169a3d4572b65bd5ded3e82e270e3cbb689a173d6ff94cbcc897d6d8e5f27ef7e6558193ea3b266c18cc5bd1a8f2ca54fa6cd
7
+ data.tar.gz: 58eb7f54eb7d3a2656dbdd3e44a977c04b1dfb5ef5f7bd549ece96ecce9a931007edea5d364f189a1916883838c6a674e794799365914a1a5cab2402994da5f1
data/CHANGELOG.md CHANGED
@@ -15,3 +15,6 @@
15
15
  ## [0.4.0] - 2024-10-18
16
16
  - adds support for Anthropic-style prompt caching
17
17
  - defaults to `max_completion_tokens` when using OpenAI directly
18
+
19
+ ## [0.4.2] - 2024-11-05
20
+ - adds support for [Predicted Outputs](https://platform.openai.com/docs/guides/latency-optimization#use-predicted-outputs) with the `prediction` option for OpenAI
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raix (0.4.1)
4
+ raix (0.4.2)
5
5
  activesupport (>= 6.0)
6
6
  open_router (~> 0.2)
7
7
 
data/README.md CHANGED
@@ -42,6 +42,14 @@ transcript << { role: "user", content: "What is the meaning of life?" }
42
42
 
43
43
  One of the advantages of OpenRouter and the reason that it is used by default by this library is that it handles mapping message formats from the OpenAI standard to whatever other model you're wanting to use (Anthropic, Cohere, etc.)
44
44
 
45
+ ### Predicted Outputs
46
+
47
+ Raix supports [Predicted Outputs](https://platform.openai.com/docs/guides/latency-optimization#use-predicted-outputs) with the `prediction` parameter for OpenAI.
48
+
49
+ ```ruby
50
+ >> ai.chat_completion(openai: "gpt-4o", params: { prediction: })
51
+ ```
52
+
45
53
  ### Prompt Caching
46
54
 
47
55
  Raix supports [Anthropic-style prompt caching](https://openrouter.ai/docs/prompt-caching#anthropic-claude) when using Anthropic's Claud family of models. You can specify a `cache_at` parameter when doing a chat completion. If the character count for the content of a particular message is longer than the cache_at parameter, it will be sent to Anthropic as a multipart message with a cache control "breakpoint" set to "ephemeral".
@@ -20,7 +20,7 @@ module Raix
20
20
  extend ActiveSupport::Concern
21
21
 
22
22
  attr_accessor :cache_at, :frequency_penalty, :logit_bias, :logprobs, :loop, :min_p, :model, :presence_penalty,
23
- :repetition_penalty, :response_format, :stream, :temperature, :max_completion_tokens,
23
+ :prediction, :repetition_penalty, :response_format, :stream, :temperature, :max_completion_tokens,
24
24
  :max_tokens, :seed, :stop, :top_a, :top_k, :top_logprobs, :top_p, :tools, :tool_choice, :provider
25
25
 
26
26
  # This method performs chat completion based on the provided transcript and parameters.
@@ -40,6 +40,7 @@ module Raix
40
40
  params[:max_completion_tokens] ||= max_completion_tokens.presence || Raix.configuration.max_completion_tokens
41
41
  params[:max_tokens] ||= max_tokens.presence || Raix.configuration.max_tokens
42
42
  params[:min_p] ||= min_p.presence
43
+ params[:prediction] = { type: "content", content: params[:prediction] || prediction } if params[:prediction] || prediction.present?
43
44
  params[:presence_penalty] ||= presence_penalty.presence
44
45
  params[:provider] ||= provider.presence
45
46
  params[:repetition_penalty] ||= repetition_penalty.presence
@@ -150,8 +151,12 @@ module Raix
150
151
  private
151
152
 
152
153
  def openai_request(params:, model:, messages:)
153
- # deprecated in favor of max_completion_tokens
154
- params.delete(:max_tokens)
154
+ if params[:prediction]
155
+ params.delete(:max_completion_tokens)
156
+ else
157
+ params[:max_completion_tokens] ||= params[:max_tokens]
158
+ params.delete(:max_tokens)
159
+ end
155
160
 
156
161
  params[:stream] ||= stream.presence
157
162
  params[:stream_options] = { include_usage: true } if params[:stream]
data/lib/raix/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Raix
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Obie Fernandez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-22 00:00:00.000000000 Z
11
+ date: 2024-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.5.21
89
+ rubygems_version: 3.4.10
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: Ruby AI eXtensions