autoflux-openai 0.2.0 → 0.3.0

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: e645074c500ce6b5ad07961575ac7dbbdb7ef71e7aa2ab43cf4e64c2bf7e1803
4
- data.tar.gz: 4f490577cce14147d94dc9da67f8daeb21d73331c719495f581a6ce21427f320
3
+ metadata.gz: 9f6a06620fc9aaad94651a79c50f43e0e6620c0170195e3f6e0e7b37e7e1a5bc
4
+ data.tar.gz: cf620fa918dcbb690a78c09ac53b9f77d2e4a76db0c9703d0563743e2ad6fc01
5
5
  SHA512:
6
- metadata.gz: e33369742bb10fc82baa2a0b64cac4a631f231143412ac7f87e55beeab4e6cc8d8b9d4449f756bafaa1f9facec416726d5113d42132b6498cd5eee068a2d3f90
7
- data.tar.gz: e837e78f01bbd99dc26ab5c93cd4f269ed0dcf507de5c1062cefc9516b2aacb0362f94d56b44a1a4c510f1cfeee636e6e6272b15ca75fac147605f4ca0c0fb56
6
+ metadata.gz: b9873032436f3cbb76471d7de41fe03b25580e7b5a850bbc11660c51ab30c9be69ed65379deb1937a8e38bbf0cc4230daed0ef092430ffbdf8c288e2d09b52c1
7
+ data.tar.gz: 5fd593e5c8cf1c4ae12b14fdd2e8bafb1d853f06195d4ca00d9bf800de6e4fbadf471133fa7e58ef1e5b6aeb9aafbac5bd09ca46b47956a7b0617a70aa892d83
data/README.md CHANGED
@@ -37,6 +37,20 @@ res = agent.call("Hello, world!")
37
37
  # => "Hello, world!" from OpenAI
38
38
  ```
39
39
 
40
+ The agent use same parameters to call the OpenAI API. You can customize it when creating the agent.
41
+
42
+ ```ruby
43
+ agent = Autoflux::OpenAI::Agent.new(
44
+ model: "gpt-4o-mini", # Required
45
+ # Extra parameters
46
+ temperature: 0.5,
47
+ )
48
+ res = agent.call("Hello, world!")
49
+ # => "Hello, world!" from OpenAI
50
+ ```
51
+
52
+ > The `model`, `messages`, and `tools` will be override by the agent. The stream mode is not supported.
53
+
40
54
  ### Tool
41
55
 
42
56
  You can attach tool to the agent to give it more capabilities.
@@ -8,12 +8,13 @@ module Autoflux
8
8
 
9
9
  attr_reader :name, :model, :memory
10
10
 
11
- def initialize(model:, name: DEFAULT_NAME, client: Client.new, tools: [], memory: [])
11
+ def initialize(model:, name: DEFAULT_NAME, client: Client.new, tools: [], memory: [], **options) # rubocop:disable Metrics/ParameterLists
12
12
  @client = client
13
13
  @model = model
14
14
  @name = name
15
15
  @memory = memory
16
16
  @_tools = tools
17
+ @options = options
17
18
  end
18
19
 
19
20
  def call(prompt, **context)
@@ -62,9 +63,11 @@ module Autoflux
62
63
 
63
64
  def complete
64
65
  @client.call(
65
- model: @model,
66
- messages: @memory.to_a,
67
- tools: tools
66
+ @options.merge(
67
+ model: @model,
68
+ messages: @memory.to_a,
69
+ tools: tools
70
+ )
68
71
  ).dig(:choices, 0, :message)
69
72
  end
70
73
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Autoflux
4
4
  module OpenAI
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@ module Autoflux
2
2
  module OpenAI
3
3
  type agentResponse = Hash[Symbol, untyped] & _ToJson
4
4
  type toolCall = Hash[Symbol, untyped]
5
+ type prompt = String | Array[{ type: String } & Hash[Symbol, untyped]]
5
6
 
6
7
  # The agent is design to use OpenAI as an agent
7
8
  class Agent
@@ -12,9 +13,10 @@ module Autoflux
12
13
  @name: String
13
14
  @memory: _Memory
14
15
  @_tools: Array[_Tool]
16
+ @options: Hash[Symbol, untyped]
15
17
 
16
- def initialize: (model: String, ?name: String, ?client: Client, ?memory: _Memory) -> void
17
- def call: (String prompt, **untyped context) -> _ToS
18
+ def initialize: (model: String, ?name: String, ?client: Client, ?memory: _Memory, **untyped options) -> void
19
+ def call: (prompt prompt, **untyped context) -> _ToS
18
20
  def use: (toolCall call, **untyped context) -> _ToJson
19
21
  def complete: () -> agentResponse
20
22
  def tools: () -> Array[_ToJson]?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoflux-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aotokitsuruya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-11 00:00:00.000000000 Z
11
+ date: 2025-01-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The OpenAI agent for Autoflux
14
14
  email: