omniai-openai 1.7.0 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41461329b48f40e24c8d2f69a58ece1a8e07726c7d45deda20c83fc58d6a1a54
4
- data.tar.gz: 6699b15afe94e512ddec9c1919d74b121a2044f5d50c390fd7899f4498b7cf19
3
+ metadata.gz: 0bc756e1ccefb9777b3103759fd819b73d39ee71fccf8eacb01d53c93b80b5cd
4
+ data.tar.gz: 752e9be7a594471210e6f85aeefb0443a917ebe2bc1eea776aa8cdcd34c5fe12
5
5
  SHA512:
6
- metadata.gz: c30e7ded2ee30804f3cc6b9d1dcb2ca62c52d7454fe722caedf518d96f019183a73265d81803a526453b3b6044c210260b6c0ef4c8e0909fead982ebe59ae3bb
7
- data.tar.gz: f99a44a88ad1c564101cb9caff9d57e33214d93c5716cad13ab0fabc3792bf3196f693ec3783eaeadfef121db785ff5d38d1c7ebd6b32d5b2f1150c10ec2687f
6
+ metadata.gz: 4c821761f9616bfda0a2f4ccd8abd203a25a44310a2d4820a6f2f5858bb3d47772b117b0dd1906b01b1e949618673aaf9db6e47e746713cf50a435864f90b6e2
7
+ data.tar.gz: 91091db68f9030aa628cfa1669603627c736410c4a449da015d438f2d5b3f9141bb64227679b7b40f8cf67d4960acc4388e92602742bdfda6c9dce88fc5bbf57
data/README.md CHANGED
@@ -62,19 +62,21 @@ _For details on installation or running Ollama checkout [the project README](htt
62
62
 
63
63
  ### Chat
64
64
 
65
- A chat completion is generated by passing in prompts using any a variety of formats:
65
+ A chat completion is generated by passing in a simple text prompt:
66
66
 
67
67
  ```ruby
68
68
  completion = client.chat('Tell me a joke!')
69
- completion.choice.message.content # 'Why did the chicken cross the road? To get to the other side.'
69
+ completion.content # 'Why did the chicken cross the road? To get to the other side.'
70
70
  ```
71
71
 
72
+ A chat completion may also be generated by using a prompt builder:
73
+
72
74
  ```ruby
73
75
  completion = client.chat do |prompt|
74
76
  prompt.system('Your are an expert in geography.')
75
77
  prompt.user('What is the capital of Canada?')
76
78
  end
77
- completion.choice.message.content # 'The capital of Canada is Ottawa.'
79
+ completion.content # 'The capital of Canada is Ottawa.'
78
80
  ```
79
81
 
80
82
  #### Model
@@ -83,7 +85,7 @@ completion.choice.message.content # 'The capital of Canada is Ottawa.'
83
85
 
84
86
  ```ruby
85
87
  completion = client.chat('How fast is a cheetah?', model: OmniAI::OpenAI::Chat::Model::GPT_3_5_TURBO)
86
- completion.choice.message.content # 'A cheetah can reach speeds over 100 km/h.'
88
+ completion.content # 'A cheetah can reach speeds over 100 km/h.'
87
89
  ```
88
90
 
89
91
  [OpenAI API Reference `model`](https://platform.openai.com/docs/api-reference/chat/create#chat-create-model)
@@ -94,7 +96,7 @@ completion.choice.message.content # 'A cheetah can reach speeds over 100 km/h.'
94
96
 
95
97
  ```ruby
96
98
  completion = client.chat('Pick a number between 1 and 5', temperature: 2.0)
97
- completion.choice.message.content # '3'
99
+ completion.content # '3'
98
100
  ```
99
101
 
100
102
  [OpenAI API Reference `temperature`](https://platform.openai.com/docs/api-reference/chat/create#chat-create-temperature)
@@ -105,7 +107,7 @@ completion.choice.message.content # '3'
105
107
 
106
108
  ```ruby
107
109
  stream = proc do |chunk|
108
- print(chunk.choice.delta.content) # 'Better', 'three', 'hours', ...
110
+ print(chunk.content) # 'Better', 'three', 'hours', ...
109
111
  end
110
112
  client.chat('Be poetic.', stream:)
111
113
  ```
@@ -121,7 +123,7 @@ completion = client.chat(format: :json) do |prompt|
121
123
  prompt.system(OmniAI::Chat::JSON_PROMPT)
122
124
  prompt.user('What is the name of the drummer for the Beatles?')
123
125
  end
124
- JSON.parse(completion.choice.message.content) # { "name": "Ringo" }
126
+ JSON.parse(completion.content) # { "name": "Ringo" }
125
127
  ```
126
128
 
127
129
  [OpenAI API Reference `response_format`](https://platform.openai.com/docs/api-reference/chat/create#chat-create-stream)
@@ -34,7 +34,7 @@ module OmniAI
34
34
  stream: @stream.nil? ? nil : !@stream.nil?,
35
35
  temperature: @temperature,
36
36
  response_format: (JSON_RESPONSE_FORMAT if @format.eql?(:json)),
37
- tools: @tools&.map(&:prepare),
37
+ tools: @tools&.map(&:serialize),
38
38
  }).compact
39
39
  end
40
40
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module OpenAI
5
- VERSION = '1.7.0'
5
+ VERSION = '1.8.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-02 00:00:00.000000000 Z
11
+ date: 2024-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: event_stream_parser