autoflux-openai 0.2.0 → 0.3.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 +4 -4
- data/README.md +14 -0
- data/lib/autoflux/openai/agent.rb +7 -4
- data/lib/autoflux/openai/version.rb +1 -1
- data/sig/autoflux/openai/agent.rbs +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f6a06620fc9aaad94651a79c50f43e0e6620c0170195e3f6e0e7b37e7e1a5bc
|
4
|
+
data.tar.gz: cf620fa918dcbb690a78c09ac53b9f77d2e4a76db0c9703d0563743e2ad6fc01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
66
|
-
|
67
|
-
|
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,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: (
|
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.
|
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
|
+
date: 2025-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The OpenAI agent for Autoflux
|
14
14
|
email:
|