fetch_hive 0.2.2
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 +7 -0
- data/README.md +64 -0
- data/lib/fetch_hive/client.rb +160 -0
- data/lib/fetch_hive/generated/api/agents_api.rb +90 -0
- data/lib/fetch_hive/generated/api/prompts_api.rb +90 -0
- data/lib/fetch_hive/generated/api/workflows_api.rb +90 -0
- data/lib/fetch_hive/generated/api_client.rb +441 -0
- data/lib/fetch_hive/generated/api_error.rb +58 -0
- data/lib/fetch_hive/generated/api_model_base.rb +88 -0
- data/lib/fetch_hive/generated/configuration.rb +415 -0
- data/lib/fetch_hive/generated/models/agent_message.rb +228 -0
- data/lib/fetch_hive/generated/models/async_config.rb +175 -0
- data/lib/fetch_hive/generated/models/error_response.rb +158 -0
- data/lib/fetch_hive/generated/models/invoke_agent_request.rb +250 -0
- data/lib/fetch_hive/generated/models/invoke_agent_response.rb +200 -0
- data/lib/fetch_hive/generated/models/invoke_prompt_request.rb +211 -0
- data/lib/fetch_hive/generated/models/invoke_prompt_response.rb +177 -0
- data/lib/fetch_hive/generated/models/invoke_workflow_async_response.rb +193 -0
- data/lib/fetch_hive/generated/models/invoke_workflow_request.rb +208 -0
- data/lib/fetch_hive/generated/models/invoke_workflow_response.rb +223 -0
- data/lib/fetch_hive/generated/models/sse_chunk.rb +228 -0
- data/lib/fetch_hive/generated/models/token_usage.rb +169 -0
- data/lib/fetch_hive/generated/models/tool_invocation.rb +169 -0
- data/lib/fetch_hive/generated/version.rb +15 -0
- data/lib/fetch_hive/streaming.rb +65 -0
- data/lib/fetch_hive/version.rb +5 -0
- data/lib/fetch_hive.rb +10 -0
- metadata +101 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: cb9c7b6224f335829b0c44df8fcbf9eb51a116d1adc8349662d5f19299fe0561
|
|
4
|
+
data.tar.gz: 00c639eeb3ae5857ba4044d481ece8f4e61d443522eec500e52ce05f1aa35406
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e202d13a1a682b2ceaa470e07153b42c2959398d6dfea6c15a4661c298fcbace443f557110b2783186eaac2186cc0ee50913a4948f68328f9981f029af5ca696
|
|
7
|
+
data.tar.gz: 911804e51870a54f5be80bd57fcb56088adf098fd9fbec00f518505eff89e68afb7ef28df44b9b80fcac2db2621bba4a2997ead022096e9ce792460aede7d663
|
data/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Fetch Hive Ruby SDK
|
|
2
|
+
|
|
3
|
+
Official Ruby SDK for the [Fetch Hive](https://fetchhive.com) API — invoke prompts, workflows, and agents with a clean, idiomatic interface.
|
|
4
|
+
|
|
5
|
+
**Version:** 0.2.2
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add to your `Gemfile`:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem "fetch_hive", "~> 0.2.2"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then run:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bundle install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or install directly:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
gem install fetch_hive
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require "fetch_hive"
|
|
31
|
+
|
|
32
|
+
client = FetchHive::Client.new(api_key: ENV["FETCH_HIVE_API_KEY"])
|
|
33
|
+
|
|
34
|
+
# Invoke a prompt
|
|
35
|
+
result = client.invoke_prompt(deployment: "my-prompt", inputs: { name: "Alice" })
|
|
36
|
+
puts result["response"]
|
|
37
|
+
|
|
38
|
+
# Invoke a workflow
|
|
39
|
+
run = client.invoke_workflow(deployment: "my-workflow", inputs: { topic: "AI" })
|
|
40
|
+
puts run["output"]
|
|
41
|
+
|
|
42
|
+
# Send a message to an agent (non-streaming)
|
|
43
|
+
reply = client.invoke_agent(agent: "my-agent", message: "Hello!")
|
|
44
|
+
puts reply["response"]
|
|
45
|
+
|
|
46
|
+
# Stream an agent response
|
|
47
|
+
client.invoke_agent_stream(agent: "my-agent", message: "Tell me a story") do |chunk|
|
|
48
|
+
print chunk["content"] if chunk["type"] == "delta"
|
|
49
|
+
end
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
| Option | Default | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `api_key` | `ENV["FETCH_HIVE_API_KEY"]` | Bearer token from the Fetch Hive dashboard |
|
|
57
|
+
| `base_url` | `https://api.fetchhive.com/v1` | Override the API base URL |
|
|
58
|
+
| `timeout` | `120` | Request timeout in seconds |
|
|
59
|
+
|
|
60
|
+
## Links
|
|
61
|
+
|
|
62
|
+
- [Fetch Hive dashboard](https://app.fetchhive.com)
|
|
63
|
+
- [API documentation](https://docs.fetchhive.com)
|
|
64
|
+
- [GitHub](https://github.com/Fetch-Hive/ruby-sdk)
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "faraday"
|
|
4
|
+
require "json"
|
|
5
|
+
require_relative "streaming"
|
|
6
|
+
|
|
7
|
+
module FetchHive
|
|
8
|
+
# Idiomatic facade over the OpenAPI-generated code.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
#
|
|
12
|
+
# client = FetchHive::Client.new(api_key: ENV["FETCH_HIVE_API_KEY"])
|
|
13
|
+
#
|
|
14
|
+
# # Non-streaming prompt
|
|
15
|
+
# result = client.invoke_prompt(deployment: "my-prompt", inputs: { name: "Alice" })
|
|
16
|
+
# puts result["response"]
|
|
17
|
+
#
|
|
18
|
+
# # Streaming agent
|
|
19
|
+
# client.invoke_agent_stream(agent: "my-agent", message: "Hello") do |chunk|
|
|
20
|
+
# print chunk["content"] if chunk["type"] == "delta"
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
class Client
|
|
24
|
+
DEFAULT_BASE_URL = "https://api.fetchhive.com/v1"
|
|
25
|
+
|
|
26
|
+
# @param api_key [String, nil] Bearer token. Falls back to +FETCH_HIVE_API_KEY+ env var.
|
|
27
|
+
# @param base_url [String] Override the API base URL.
|
|
28
|
+
# @param timeout [Integer] Request timeout in seconds (default: 120).
|
|
29
|
+
def initialize(api_key: nil, base_url: DEFAULT_BASE_URL, timeout: 120)
|
|
30
|
+
resolved = api_key || ENV["FETCH_HIVE_API_KEY"]
|
|
31
|
+
raise ArgumentError, "api_key is required. Pass it explicitly or set FETCH_HIVE_API_KEY." if resolved.nil? || resolved.empty?
|
|
32
|
+
|
|
33
|
+
@api_key = resolved
|
|
34
|
+
@base_url = base_url.to_s.sub(%r{/+\z}, "")
|
|
35
|
+
@timeout = timeout
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# ── Prompt ─────────────────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
# Invoke a prompt deployment and return the full response hash.
|
|
41
|
+
def invoke_prompt(deployment:, variant: nil, inputs: nil, user: nil)
|
|
42
|
+
body = { deployment: deployment, streaming: false }
|
|
43
|
+
body[:variant] = variant if variant
|
|
44
|
+
body[:inputs] = inputs if inputs
|
|
45
|
+
body[:user] = user if user
|
|
46
|
+
post("/invoke", body)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Invoke a prompt deployment and stream SSE events.
|
|
50
|
+
# Yields each parsed event hash. Returns an Enumerator when no block given.
|
|
51
|
+
def invoke_prompt_stream(deployment:, variant: nil, inputs: nil, user: nil, &block)
|
|
52
|
+
body = { deployment: deployment, streaming: true }
|
|
53
|
+
body[:variant] = variant if variant
|
|
54
|
+
body[:inputs] = inputs if inputs
|
|
55
|
+
body[:user] = user if user
|
|
56
|
+
post_stream("/invoke", body, &block)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# ── Workflow ────────────────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
# Invoke a workflow deployment (sync or async).
|
|
62
|
+
def invoke_workflow(deployment:, variant: nil, inputs: nil, async_mode: false, callback_url: nil, user: nil)
|
|
63
|
+
body = { deployment: deployment }
|
|
64
|
+
body[:variant] = variant if variant
|
|
65
|
+
body[:inputs] = inputs if inputs
|
|
66
|
+
body[:user] = user if user
|
|
67
|
+
if async_mode
|
|
68
|
+
body[:async] = { enabled: true }
|
|
69
|
+
body[:async][:callback_url] = callback_url if callback_url
|
|
70
|
+
end
|
|
71
|
+
post("/workflow/invoke", body)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# ── Agent ───────────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
# Send a message to an agent and return the full response hash.
|
|
77
|
+
def invoke_agent(agent:, message:, thread_id: nil, user: nil, messages: nil, image_urls: nil)
|
|
78
|
+
body = { agent: agent, message: message, streaming: false }
|
|
79
|
+
body[:thread_id] = thread_id if thread_id
|
|
80
|
+
body[:user] = user if user
|
|
81
|
+
body[:messages] = messages if messages
|
|
82
|
+
body[:image_urls] = image_urls if image_urls
|
|
83
|
+
post("/agent/invoke", body)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Send a message to an agent and stream SSE events.
|
|
87
|
+
# Yields each parsed event hash. Returns an Enumerator when no block given.
|
|
88
|
+
def invoke_agent_stream(agent:, message:, thread_id: nil, user: nil, messages: nil, image_urls: nil, &block)
|
|
89
|
+
body = { agent: agent, message: message, streaming: true }
|
|
90
|
+
body[:thread_id] = thread_id if thread_id
|
|
91
|
+
body[:user] = user if user
|
|
92
|
+
body[:messages] = messages if messages
|
|
93
|
+
body[:image_urls] = image_urls if image_urls
|
|
94
|
+
post_stream("/agent/invoke", body, &block)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
def default_headers
|
|
100
|
+
{
|
|
101
|
+
"Authorization" => "Bearer #{@api_key}",
|
|
102
|
+
"Content-Type" => "application/json"
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def connection
|
|
107
|
+
Faraday.new(url: @base_url, request: { timeout: @timeout }) do |f|
|
|
108
|
+
f.adapter Faraday.default_adapter
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def post(path, body)
|
|
113
|
+
resp = connection.post(path) do |req|
|
|
114
|
+
req.headers.merge!(default_headers)
|
|
115
|
+
req.body = JSON.generate(body)
|
|
116
|
+
end
|
|
117
|
+
raise "FetchHive API error #{resp.status}: #{resp.body}" unless resp.success?
|
|
118
|
+
|
|
119
|
+
JSON.parse(resp.body)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def post_stream(path, body, &block)
|
|
123
|
+
return enum_for(:post_stream, path, body) unless block
|
|
124
|
+
|
|
125
|
+
io, writer = IO.pipe
|
|
126
|
+
|
|
127
|
+
thread = Thread.new do
|
|
128
|
+
conn = Faraday.new(url: @base_url, request: { timeout: @timeout }) do |f|
|
|
129
|
+
f.adapter Faraday.default_adapter
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
resp = conn.post(path) do |req|
|
|
133
|
+
req.headers.merge!(default_headers)
|
|
134
|
+
req.body = JSON.generate(body)
|
|
135
|
+
req.options.on_data = proc do |chunk, _size, env|
|
|
136
|
+
if env && !env.status.between?(200, 299)
|
|
137
|
+
writer.close
|
|
138
|
+
raise "FetchHive API error #{env.status}: #{chunk}"
|
|
139
|
+
end
|
|
140
|
+
writer.write(chunk)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
unless resp.success?
|
|
145
|
+
writer.close
|
|
146
|
+
raise "FetchHive API error #{resp.status}: #{resp.body}"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
writer.close
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
begin
|
|
153
|
+
FetchHive::Streaming.parse_sse(io, &block)
|
|
154
|
+
ensure
|
|
155
|
+
io.close
|
|
156
|
+
thread.join
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Fetch Hive Public API
|
|
3
|
+
|
|
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
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.2.2
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module FetchHive::Generated
|
|
16
|
+
class AgentsApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Invoke an agent
|
|
23
|
+
# Sends a message to a configured agent and returns its response. Agents can use tools, maintain conversation history via `thread_id`, or accept ephemeral history via the `messages` field. Set `streaming: true` to receive a Server-Sent Events stream. Each `data:` line contains a JSON object of type `SseChunk`. Image URLs can be supplied in `image_urls` for multimodal inputs (must be HTTPS).
|
|
24
|
+
# @param invoke_agent_request [InvokeAgentRequest]
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @return [InvokeAgentResponse]
|
|
27
|
+
def invoke_agent(invoke_agent_request, opts = {})
|
|
28
|
+
data, _status_code, _headers = invoke_agent_with_http_info(invoke_agent_request, opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Invoke an agent
|
|
33
|
+
# Sends a message to a configured agent and returns its response. Agents can use tools, maintain conversation history via `thread_id`, or accept ephemeral history via the `messages` field. Set `streaming: true` to receive a Server-Sent Events stream. Each `data:` line contains a JSON object of type `SseChunk`. Image URLs can be supplied in `image_urls` for multimodal inputs (must be HTTPS).
|
|
34
|
+
# @param invoke_agent_request [InvokeAgentRequest]
|
|
35
|
+
# @param [Hash] opts the optional parameters
|
|
36
|
+
# @return [Array<(InvokeAgentResponse, Integer, Hash)>] InvokeAgentResponse data, response status code and response headers
|
|
37
|
+
def invoke_agent_with_http_info(invoke_agent_request, opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: AgentsApi.invoke_agent ...'
|
|
40
|
+
end
|
|
41
|
+
# verify the required parameter 'invoke_agent_request' is set
|
|
42
|
+
if @api_client.config.client_side_validation && invoke_agent_request.nil?
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'invoke_agent_request' when calling AgentsApi.invoke_agent"
|
|
44
|
+
end
|
|
45
|
+
# resource path
|
|
46
|
+
local_var_path = '/agent/invoke'
|
|
47
|
+
|
|
48
|
+
# query parameters
|
|
49
|
+
query_params = opts[:query_params] || {}
|
|
50
|
+
|
|
51
|
+
# header parameters
|
|
52
|
+
header_params = opts[:header_params] || {}
|
|
53
|
+
# HTTP header 'Accept' (if needed)
|
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
55
|
+
# HTTP header 'Content-Type'
|
|
56
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
57
|
+
if !content_type.nil?
|
|
58
|
+
header_params['Content-Type'] = content_type
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# form parameters
|
|
62
|
+
form_params = opts[:form_params] || {}
|
|
63
|
+
|
|
64
|
+
# http body (model)
|
|
65
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(invoke_agent_request)
|
|
66
|
+
|
|
67
|
+
# return_type
|
|
68
|
+
return_type = opts[:debug_return_type] || 'InvokeAgentResponse'
|
|
69
|
+
|
|
70
|
+
# auth_names
|
|
71
|
+
auth_names = opts[:debug_auth_names] || ['BearerAuth']
|
|
72
|
+
|
|
73
|
+
new_options = opts.merge(
|
|
74
|
+
:operation => :"AgentsApi.invoke_agent",
|
|
75
|
+
:header_params => header_params,
|
|
76
|
+
:query_params => query_params,
|
|
77
|
+
:form_params => form_params,
|
|
78
|
+
:body => post_body,
|
|
79
|
+
:auth_names => auth_names,
|
|
80
|
+
:return_type => return_type
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
84
|
+
if @api_client.config.debugging
|
|
85
|
+
@api_client.config.logger.debug "API called: AgentsApi#invoke_agent\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
86
|
+
end
|
|
87
|
+
return data, status_code, headers
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Fetch Hive Public API
|
|
3
|
+
|
|
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
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.2.2
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module FetchHive::Generated
|
|
16
|
+
class PromptsApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Invoke a prompt deployment
|
|
23
|
+
# Runs a configured prompt deployment and returns the model response. Set `streaming: true` to receive a Server-Sent Events stream instead of a single JSON object.
|
|
24
|
+
# @param invoke_prompt_request [InvokePromptRequest]
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @return [InvokePromptResponse]
|
|
27
|
+
def invoke_prompt(invoke_prompt_request, opts = {})
|
|
28
|
+
data, _status_code, _headers = invoke_prompt_with_http_info(invoke_prompt_request, opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Invoke a prompt deployment
|
|
33
|
+
# Runs a configured prompt deployment and returns the model response. Set `streaming: true` to receive a Server-Sent Events stream instead of a single JSON object.
|
|
34
|
+
# @param invoke_prompt_request [InvokePromptRequest]
|
|
35
|
+
# @param [Hash] opts the optional parameters
|
|
36
|
+
# @return [Array<(InvokePromptResponse, Integer, Hash)>] InvokePromptResponse data, response status code and response headers
|
|
37
|
+
def invoke_prompt_with_http_info(invoke_prompt_request, opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: PromptsApi.invoke_prompt ...'
|
|
40
|
+
end
|
|
41
|
+
# verify the required parameter 'invoke_prompt_request' is set
|
|
42
|
+
if @api_client.config.client_side_validation && invoke_prompt_request.nil?
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'invoke_prompt_request' when calling PromptsApi.invoke_prompt"
|
|
44
|
+
end
|
|
45
|
+
# resource path
|
|
46
|
+
local_var_path = '/invoke'
|
|
47
|
+
|
|
48
|
+
# query parameters
|
|
49
|
+
query_params = opts[:query_params] || {}
|
|
50
|
+
|
|
51
|
+
# header parameters
|
|
52
|
+
header_params = opts[:header_params] || {}
|
|
53
|
+
# HTTP header 'Accept' (if needed)
|
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
55
|
+
# HTTP header 'Content-Type'
|
|
56
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
57
|
+
if !content_type.nil?
|
|
58
|
+
header_params['Content-Type'] = content_type
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# form parameters
|
|
62
|
+
form_params = opts[:form_params] || {}
|
|
63
|
+
|
|
64
|
+
# http body (model)
|
|
65
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(invoke_prompt_request)
|
|
66
|
+
|
|
67
|
+
# return_type
|
|
68
|
+
return_type = opts[:debug_return_type] || 'InvokePromptResponse'
|
|
69
|
+
|
|
70
|
+
# auth_names
|
|
71
|
+
auth_names = opts[:debug_auth_names] || ['BearerAuth']
|
|
72
|
+
|
|
73
|
+
new_options = opts.merge(
|
|
74
|
+
:operation => :"PromptsApi.invoke_prompt",
|
|
75
|
+
:header_params => header_params,
|
|
76
|
+
:query_params => query_params,
|
|
77
|
+
:form_params => form_params,
|
|
78
|
+
:body => post_body,
|
|
79
|
+
:auth_names => auth_names,
|
|
80
|
+
:return_type => return_type
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
84
|
+
if @api_client.config.debugging
|
|
85
|
+
@api_client.config.logger.debug "API called: PromptsApi#invoke_prompt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
86
|
+
end
|
|
87
|
+
return data, status_code, headers
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Fetch Hive Public API
|
|
3
|
+
|
|
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
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.2.2
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module FetchHive::Generated
|
|
16
|
+
class WorkflowsApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Invoke a workflow deployment
|
|
23
|
+
# Runs a configured workflow deployment. Supports both synchronous and asynchronous execution via the `async` field. When `async.enabled` is `false` (default), the request blocks until the workflow completes and returns the output directly. When `async.enabled` is `true`, the server returns a `202` with a `run_id`. Poll `GET /v1/workflow_runs/{id}` on the management API to check status.
|
|
24
|
+
# @param invoke_workflow_request [InvokeWorkflowRequest]
|
|
25
|
+
# @param [Hash] opts the optional parameters
|
|
26
|
+
# @return [InvokeWorkflowResponse]
|
|
27
|
+
def invoke_workflow(invoke_workflow_request, opts = {})
|
|
28
|
+
data, _status_code, _headers = invoke_workflow_with_http_info(invoke_workflow_request, opts)
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Invoke a workflow deployment
|
|
33
|
+
# Runs a configured workflow deployment. Supports both synchronous and asynchronous execution via the `async` field. When `async.enabled` is `false` (default), the request blocks until the workflow completes and returns the output directly. When `async.enabled` is `true`, the server returns a `202` with a `run_id`. Poll `GET /v1/workflow_runs/{id}` on the management API to check status.
|
|
34
|
+
# @param invoke_workflow_request [InvokeWorkflowRequest]
|
|
35
|
+
# @param [Hash] opts the optional parameters
|
|
36
|
+
# @return [Array<(InvokeWorkflowResponse, Integer, Hash)>] InvokeWorkflowResponse data, response status code and response headers
|
|
37
|
+
def invoke_workflow_with_http_info(invoke_workflow_request, opts = {})
|
|
38
|
+
if @api_client.config.debugging
|
|
39
|
+
@api_client.config.logger.debug 'Calling API: WorkflowsApi.invoke_workflow ...'
|
|
40
|
+
end
|
|
41
|
+
# verify the required parameter 'invoke_workflow_request' is set
|
|
42
|
+
if @api_client.config.client_side_validation && invoke_workflow_request.nil?
|
|
43
|
+
fail ArgumentError, "Missing the required parameter 'invoke_workflow_request' when calling WorkflowsApi.invoke_workflow"
|
|
44
|
+
end
|
|
45
|
+
# resource path
|
|
46
|
+
local_var_path = '/workflow/invoke'
|
|
47
|
+
|
|
48
|
+
# query parameters
|
|
49
|
+
query_params = opts[:query_params] || {}
|
|
50
|
+
|
|
51
|
+
# header parameters
|
|
52
|
+
header_params = opts[:header_params] || {}
|
|
53
|
+
# HTTP header 'Accept' (if needed)
|
|
54
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
55
|
+
# HTTP header 'Content-Type'
|
|
56
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
57
|
+
if !content_type.nil?
|
|
58
|
+
header_params['Content-Type'] = content_type
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# form parameters
|
|
62
|
+
form_params = opts[:form_params] || {}
|
|
63
|
+
|
|
64
|
+
# http body (model)
|
|
65
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(invoke_workflow_request)
|
|
66
|
+
|
|
67
|
+
# return_type
|
|
68
|
+
return_type = opts[:debug_return_type] || 'InvokeWorkflowResponse'
|
|
69
|
+
|
|
70
|
+
# auth_names
|
|
71
|
+
auth_names = opts[:debug_auth_names] || ['BearerAuth']
|
|
72
|
+
|
|
73
|
+
new_options = opts.merge(
|
|
74
|
+
:operation => :"WorkflowsApi.invoke_workflow",
|
|
75
|
+
:header_params => header_params,
|
|
76
|
+
:query_params => query_params,
|
|
77
|
+
:form_params => form_params,
|
|
78
|
+
:body => post_body,
|
|
79
|
+
:auth_names => auth_names,
|
|
80
|
+
:return_type => return_type
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
84
|
+
if @api_client.config.debugging
|
|
85
|
+
@api_client.config.logger.debug "API called: WorkflowsApi#invoke_workflow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
86
|
+
end
|
|
87
|
+
return data, status_code, headers
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|