fetch_hive 0.2.2 → 0.2.4
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 +99 -14
- data/lib/fetch_hive/client.rb +5 -1
- data/lib/fetch_hive/generated/api/agents_api.rb +1 -1
- data/lib/fetch_hive/generated/api/prompts_api.rb +1 -1
- data/lib/fetch_hive/generated/api/workflows_api.rb +1 -1
- data/lib/fetch_hive/generated/api_client.rb +1 -1
- data/lib/fetch_hive/generated/api_error.rb +1 -1
- data/lib/fetch_hive/generated/api_model_base.rb +1 -1
- data/lib/fetch_hive/generated/configuration.rb +1 -1
- data/lib/fetch_hive/generated/models/agent_message.rb +1 -1
- data/lib/fetch_hive/generated/models/async_config.rb +1 -1
- data/lib/fetch_hive/generated/models/error_response.rb +1 -1
- data/lib/fetch_hive/generated/models/invoke_agent_request.rb +1 -1
- data/lib/fetch_hive/generated/models/invoke_agent_response.rb +1 -1
- data/lib/fetch_hive/generated/models/invoke_prompt_request.rb +1 -1
- data/lib/fetch_hive/generated/models/invoke_prompt_response.rb +1 -1
- data/lib/fetch_hive/generated/models/invoke_workflow_async_response.rb +1 -1
- data/lib/fetch_hive/generated/models/invoke_workflow_request.rb +1 -1
- data/lib/fetch_hive/generated/models/invoke_workflow_response.rb +1 -1
- data/lib/fetch_hive/generated/models/sse_chunk.rb +106 -24
- data/lib/fetch_hive/generated/models/token_usage.rb +1 -1
- data/lib/fetch_hive/generated/models/tool_invocation.rb +1 -1
- data/lib/fetch_hive/generated/version.rb +1 -1
- data/lib/fetch_hive/streaming.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37b77a6a159964d561dc379a54c47c8231e235a8f60b2397bed73aaeb79304b3
|
|
4
|
+
data.tar.gz: a805ca9d930d1ad821b673a84b95a8bf854611eccb619716895b24d256aa6b1e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffa21ea91982cf6cbf080b2db47f41688e2b30465f738c6cb8cc166173dfa4efb7ab367195bcd3cff48e22d18a5c88ea38e22ece304020d5cbfb0e5238421591
|
|
7
|
+
data.tar.gz: e4da47bd790f4fa171613251bd89cf5db5dbc1eb7539ed044e1fb9cd7e5bc0005ef0ea91606353211c8f94f3479c74a0bc09bfacc6c803929ea97f972399a6b9
|
data/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# fetch_hive
|
|
2
2
|
|
|
3
|
-
Official Ruby SDK for
|
|
3
|
+
Official Ruby SDK for [Fetch Hive](https://fetchhive.com) — invoke AI prompts, workflows, and agents from your application.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://rubygems.org/gems/fetch_hive)
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
Add to your `Gemfile`:
|
|
10
10
|
|
|
11
11
|
```ruby
|
|
12
|
-
gem "fetch_hive", "~> 0.2.
|
|
12
|
+
gem "fetch_hive", "~> 0.2.4"
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Then run:
|
|
@@ -30,25 +30,102 @@ gem install fetch_hive
|
|
|
30
30
|
require "fetch_hive"
|
|
31
31
|
|
|
32
32
|
client = FetchHive::Client.new(api_key: ENV["FETCH_HIVE_API_KEY"])
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Get your API key from the [Fetch Hive dashboard](https://app.fetchhive.com).
|
|
36
|
+
|
|
37
|
+
## Invoke a prompt
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
result = client.invoke_prompt(
|
|
39
|
+
```ruby
|
|
40
|
+
result = client.invoke_prompt(
|
|
41
|
+
deployment: "my-prompt",
|
|
42
|
+
inputs: { name: "Alice", topic: "machine learning" }
|
|
43
|
+
)
|
|
36
44
|
puts result["response"]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Invoke a prompt (streaming)
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
client.invoke_prompt_stream(deployment: "my-prompt", inputs: { name: "Alice" }) do |chunk|
|
|
51
|
+
case chunk["type"]
|
|
52
|
+
when "response" then print chunk["response"]
|
|
53
|
+
when "usage" then puts "\nUsage: #{chunk['usage']}"
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
```
|
|
37
57
|
|
|
38
|
-
|
|
39
|
-
run = client.invoke_workflow(deployment: "my-workflow", inputs: { topic: "AI" })
|
|
40
|
-
puts run["output"]
|
|
58
|
+
## Invoke a workflow
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
```ruby
|
|
61
|
+
run = client.invoke_workflow(
|
|
62
|
+
deployment: "my-workflow",
|
|
63
|
+
inputs: { customer_id: "42" }
|
|
64
|
+
)
|
|
65
|
+
puts run["status"], run["output"]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Invoke a workflow (async)
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
run = client.invoke_workflow(
|
|
72
|
+
deployment: "my-workflow",
|
|
73
|
+
inputs: { customer_id: "42" },
|
|
74
|
+
async_mode: true,
|
|
75
|
+
callback_url: "https://example.com/webhook"
|
|
76
|
+
)
|
|
77
|
+
puts "Queued: #{run['run_id']}"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Invoke an agent
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
reply = client.invoke_agent(
|
|
84
|
+
agent: "my-agent",
|
|
85
|
+
message: "What is the weather in London?"
|
|
86
|
+
)
|
|
44
87
|
puts reply["response"]
|
|
88
|
+
```
|
|
45
89
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
90
|
+
## Invoke an agent (streaming)
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
client.invoke_agent_stream(
|
|
94
|
+
agent: "my-agent",
|
|
95
|
+
message: "What is the weather in London?",
|
|
96
|
+
thread_id: "session-abc123" # optional — persist conversation history
|
|
97
|
+
) do |chunk|
|
|
98
|
+
case chunk["type"]
|
|
99
|
+
when "response" then print chunk["response"]
|
|
100
|
+
when "tool" then puts "\nCalling tool: #{chunk['tool']}"
|
|
101
|
+
when "usage" then puts "\nUsage: #{chunk['usage']}"
|
|
102
|
+
end
|
|
49
103
|
end
|
|
50
104
|
```
|
|
51
105
|
|
|
106
|
+
## Multimodal (image) inputs
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
result = client.invoke_agent(
|
|
110
|
+
agent: "vision-agent",
|
|
111
|
+
message: "Describe this image",
|
|
112
|
+
image_urls: ["https://example.com/photo.jpg"]
|
|
113
|
+
)
|
|
114
|
+
puts result["response"]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Authentication
|
|
118
|
+
|
|
119
|
+
Pass the API key to the constructor or set the environment variable:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
export FETCH_HIVE_API_KEY=fhk_...
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
client = FetchHive::Client.new # picks up FETCH_HIVE_API_KEY automatically
|
|
127
|
+
```
|
|
128
|
+
|
|
52
129
|
## Configuration
|
|
53
130
|
|
|
54
131
|
| Option | Default | Description |
|
|
@@ -62,3 +139,11 @@ end
|
|
|
62
139
|
- [Fetch Hive dashboard](https://app.fetchhive.com)
|
|
63
140
|
- [API documentation](https://docs.fetchhive.com)
|
|
64
141
|
- [GitHub](https://github.com/Fetch-Hive/ruby-sdk)
|
|
142
|
+
|
|
143
|
+
## Version
|
|
144
|
+
|
|
145
|
+
0.2.4
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT — see [LICENSE](LICENSE).
|
data/lib/fetch_hive/client.rb
CHANGED
|
@@ -17,7 +17,11 @@ module FetchHive
|
|
|
17
17
|
#
|
|
18
18
|
# # Streaming agent
|
|
19
19
|
# client.invoke_agent_stream(agent: "my-agent", message: "Hello") do |chunk|
|
|
20
|
-
#
|
|
20
|
+
# case chunk["type"]
|
|
21
|
+
# when "response" then print chunk["response"]
|
|
22
|
+
# when "tool" then puts "\nCalling tool: #{chunk['tool']}"
|
|
23
|
+
# when "usage" then puts "\nUsage: #{chunk['usage']}"
|
|
24
|
+
# end
|
|
21
25
|
# end
|
|
22
26
|
#
|
|
23
27
|
class Client
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -14,30 +14,54 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module FetchHive::Generated
|
|
17
|
-
# A single event in a Server-Sent Events stream. The type field is a runtime discriminator. Known values:
|
|
17
|
+
# A single event in a Server-Sent Events stream. The `type` field is a runtime discriminator. Known values: - `reasoning` — a reasoning / thinking chunk (prompt and agent streams) - `response` — a text chunk (prompt and agent streams) - `tool` — a tool invocation result (agent stream only) - `usage` — final token usage event; signals end of meaningful stream content - `summary` — auto-summarization event emitted before reasoning when a thread history was compressed (agent stream only) - `error` — server-side error during streaming The stream is terminated by `data: [DONE]`, which is handled by the SSE parser and never surfaced as a chunk.
|
|
18
18
|
class SseChunk < ApiModelBase
|
|
19
19
|
# Event type discriminator.
|
|
20
20
|
attr_accessor :type
|
|
21
21
|
|
|
22
|
-
# Text
|
|
23
|
-
attr_accessor :
|
|
22
|
+
# Text content of the chunk. Present for `reasoning` and `response` event types.
|
|
23
|
+
attr_accessor :response
|
|
24
24
|
|
|
25
|
-
# Present on
|
|
25
|
+
# Unique request identifier. Present on most events; always present on `usage`.
|
|
26
26
|
attr_accessor :request_id
|
|
27
27
|
|
|
28
|
-
# Present on
|
|
28
|
+
# Model identifier. Present on `response` and `reasoning` events (prompt stream).
|
|
29
29
|
attr_accessor :model
|
|
30
30
|
|
|
31
|
-
#
|
|
32
|
-
attr_accessor :
|
|
31
|
+
# Per-chunk boolean flag on `response` and `reasoning` events (agent stream). Not a terminal event type — use the `usage` event to detect end of stream.
|
|
32
|
+
attr_accessor :done
|
|
33
33
|
|
|
34
|
-
#
|
|
34
|
+
# Unique tool invocation identifier. Present for `tool` events.
|
|
35
|
+
attr_accessor :tool_id
|
|
36
|
+
|
|
37
|
+
# Tool name. Present for `tool` events (e.g. \"google_search\").
|
|
38
|
+
attr_accessor :tool
|
|
39
|
+
|
|
40
|
+
# Internal tool type identifier. Present for `tool` events.
|
|
41
|
+
attr_accessor :tool_type
|
|
42
|
+
|
|
43
|
+
# Parsed tool input arguments. Present for `tool` events.
|
|
35
44
|
attr_accessor :tool_input
|
|
36
45
|
|
|
37
|
-
# Serialised JSON tool result
|
|
46
|
+
# Serialised JSON tool result. Present for `tool` events.
|
|
38
47
|
attr_accessor :observation
|
|
39
48
|
|
|
40
|
-
#
|
|
49
|
+
# Reason the stream ended. Present on `usage` events (e.g. \"completed\").
|
|
50
|
+
attr_accessor :stop_reason
|
|
51
|
+
|
|
52
|
+
# Compressed summary of the prior conversation. Present for `summary` events.
|
|
53
|
+
attr_accessor :summary_text
|
|
54
|
+
|
|
55
|
+
# Token count before summarization. Present for `summary` events.
|
|
56
|
+
attr_accessor :original_token_count
|
|
57
|
+
|
|
58
|
+
# Model context window size. Present for `summary` events.
|
|
59
|
+
attr_accessor :context_limit
|
|
60
|
+
|
|
61
|
+
# LLM provider used for summarization. Present for `summary` events.
|
|
62
|
+
attr_accessor :provider
|
|
63
|
+
|
|
64
|
+
# Error message. Present for `error` events.
|
|
41
65
|
attr_accessor :error
|
|
42
66
|
|
|
43
67
|
attr_accessor :usage
|
|
@@ -46,12 +70,20 @@ module FetchHive::Generated
|
|
|
46
70
|
def self.attribute_map
|
|
47
71
|
{
|
|
48
72
|
:'type' => :'type',
|
|
49
|
-
:'
|
|
73
|
+
:'response' => :'response',
|
|
50
74
|
:'request_id' => :'request_id',
|
|
51
75
|
:'model' => :'model',
|
|
52
|
-
:'
|
|
76
|
+
:'done' => :'done',
|
|
77
|
+
:'tool_id' => :'tool_id',
|
|
78
|
+
:'tool' => :'tool',
|
|
79
|
+
:'tool_type' => :'tool_type',
|
|
53
80
|
:'tool_input' => :'tool_input',
|
|
54
81
|
:'observation' => :'observation',
|
|
82
|
+
:'stop_reason' => :'stop_reason',
|
|
83
|
+
:'summary_text' => :'summary_text',
|
|
84
|
+
:'original_token_count' => :'original_token_count',
|
|
85
|
+
:'context_limit' => :'context_limit',
|
|
86
|
+
:'provider' => :'provider',
|
|
55
87
|
:'error' => :'error',
|
|
56
88
|
:'usage' => :'usage'
|
|
57
89
|
}
|
|
@@ -71,12 +103,20 @@ module FetchHive::Generated
|
|
|
71
103
|
def self.openapi_types
|
|
72
104
|
{
|
|
73
105
|
:'type' => :'String',
|
|
74
|
-
:'
|
|
106
|
+
:'response' => :'String',
|
|
75
107
|
:'request_id' => :'String',
|
|
76
108
|
:'model' => :'String',
|
|
77
|
-
:'
|
|
78
|
-
:'
|
|
109
|
+
:'done' => :'Boolean',
|
|
110
|
+
:'tool_id' => :'String',
|
|
111
|
+
:'tool' => :'String',
|
|
112
|
+
:'tool_type' => :'String',
|
|
113
|
+
:'tool_input' => :'Hash<String, Object>',
|
|
79
114
|
:'observation' => :'String',
|
|
115
|
+
:'stop_reason' => :'String',
|
|
116
|
+
:'summary_text' => :'String',
|
|
117
|
+
:'original_token_count' => :'Integer',
|
|
118
|
+
:'context_limit' => :'Integer',
|
|
119
|
+
:'provider' => :'String',
|
|
80
120
|
:'error' => :'String',
|
|
81
121
|
:'usage' => :'TokenUsage'
|
|
82
122
|
}
|
|
@@ -108,8 +148,8 @@ module FetchHive::Generated
|
|
|
108
148
|
self.type = attributes[:'type']
|
|
109
149
|
end
|
|
110
150
|
|
|
111
|
-
if attributes.key?(:'
|
|
112
|
-
self.
|
|
151
|
+
if attributes.key?(:'response')
|
|
152
|
+
self.response = attributes[:'response']
|
|
113
153
|
end
|
|
114
154
|
|
|
115
155
|
if attributes.key?(:'request_id')
|
|
@@ -120,18 +160,52 @@ module FetchHive::Generated
|
|
|
120
160
|
self.model = attributes[:'model']
|
|
121
161
|
end
|
|
122
162
|
|
|
123
|
-
if attributes.key?(:'
|
|
124
|
-
self.
|
|
163
|
+
if attributes.key?(:'done')
|
|
164
|
+
self.done = attributes[:'done']
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
if attributes.key?(:'tool_id')
|
|
168
|
+
self.tool_id = attributes[:'tool_id']
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
if attributes.key?(:'tool')
|
|
172
|
+
self.tool = attributes[:'tool']
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
if attributes.key?(:'tool_type')
|
|
176
|
+
self.tool_type = attributes[:'tool_type']
|
|
125
177
|
end
|
|
126
178
|
|
|
127
179
|
if attributes.key?(:'tool_input')
|
|
128
|
-
|
|
180
|
+
if (value = attributes[:'tool_input']).is_a?(Hash)
|
|
181
|
+
self.tool_input = value
|
|
182
|
+
end
|
|
129
183
|
end
|
|
130
184
|
|
|
131
185
|
if attributes.key?(:'observation')
|
|
132
186
|
self.observation = attributes[:'observation']
|
|
133
187
|
end
|
|
134
188
|
|
|
189
|
+
if attributes.key?(:'stop_reason')
|
|
190
|
+
self.stop_reason = attributes[:'stop_reason']
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
if attributes.key?(:'summary_text')
|
|
194
|
+
self.summary_text = attributes[:'summary_text']
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
if attributes.key?(:'original_token_count')
|
|
198
|
+
self.original_token_count = attributes[:'original_token_count']
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
if attributes.key?(:'context_limit')
|
|
202
|
+
self.context_limit = attributes[:'context_limit']
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
if attributes.key?(:'provider')
|
|
206
|
+
self.provider = attributes[:'provider']
|
|
207
|
+
end
|
|
208
|
+
|
|
135
209
|
if attributes.key?(:'error')
|
|
136
210
|
self.error = attributes[:'error']
|
|
137
211
|
end
|
|
@@ -162,12 +236,20 @@ module FetchHive::Generated
|
|
|
162
236
|
return true if self.equal?(o)
|
|
163
237
|
self.class == o.class &&
|
|
164
238
|
type == o.type &&
|
|
165
|
-
|
|
239
|
+
response == o.response &&
|
|
166
240
|
request_id == o.request_id &&
|
|
167
241
|
model == o.model &&
|
|
168
|
-
|
|
242
|
+
done == o.done &&
|
|
243
|
+
tool_id == o.tool_id &&
|
|
244
|
+
tool == o.tool &&
|
|
245
|
+
tool_type == o.tool_type &&
|
|
169
246
|
tool_input == o.tool_input &&
|
|
170
247
|
observation == o.observation &&
|
|
248
|
+
stop_reason == o.stop_reason &&
|
|
249
|
+
summary_text == o.summary_text &&
|
|
250
|
+
original_token_count == o.original_token_count &&
|
|
251
|
+
context_limit == o.context_limit &&
|
|
252
|
+
provider == o.provider &&
|
|
171
253
|
error == o.error &&
|
|
172
254
|
usage == o.usage
|
|
173
255
|
end
|
|
@@ -181,7 +263,7 @@ module FetchHive::Generated
|
|
|
181
263
|
# Calculates hash code according to all attributes.
|
|
182
264
|
# @return [Integer] Hash code
|
|
183
265
|
def hash
|
|
184
|
-
[type,
|
|
266
|
+
[type, response, request_id, model, done, tool_id, tool, tool_type, tool_input, observation, stop_reason, summary_text, original_token_count, context_limit, provider, error, usage].hash
|
|
185
267
|
end
|
|
186
268
|
|
|
187
269
|
# Builds the object from hash
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Fetch Hive public API lets you invoke prompts, workflows, and agents programmatically using an API token. ## Authentication All requests require a Bearer token in the `Authorization` header: ``` Authorization: Bearer <your-api-token> ``` ## Streaming Pass `\"streaming\": true` in the request body to receive a `text/event-stream` response. Each event is a JSON object sent as `data: <json>\\n\\n`. The stream ends with `data: [DONE]\\n\\n`.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document: 0.2.
|
|
6
|
+
The version of the OpenAPI document: 0.2.4
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
data/lib/fetch_hive/streaming.rb
CHANGED
|
@@ -9,7 +9,10 @@ module FetchHive
|
|
|
9
9
|
#
|
|
10
10
|
# io = response.body # any IO or string
|
|
11
11
|
# FetchHive::Streaming.parse_sse(io) do |event|
|
|
12
|
-
#
|
|
12
|
+
# case event["type"]
|
|
13
|
+
# when "response" then print event["response"]
|
|
14
|
+
# when "usage" then puts "\nUsage: #{event['usage']}"
|
|
15
|
+
# end
|
|
13
16
|
# end
|
|
14
17
|
#
|
|
15
18
|
module Streaming
|