Class: Conductor::Http::Api::PromptResourceApi

Inherits:
Object
  • Object
show all
Defined in:
lib/conductor/http/api/prompt_resource_api.rb

Overview

PromptResourceApi - API for prompt template management operations (Orkes)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = nil) ⇒ PromptResourceApi

Returns a new instance of PromptResourceApi.



12
13
14
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 12

def initialize(api_client = nil)
  @api_client = api_client || ApiClient.new
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



10
11
12
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 10

def api_client
  @api_client
end

Instance Method Details

#delete_prompt(name) ⇒ Object

Delete a prompt template



52
53
54
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 52

def delete_prompt(name)
  @api_client.call_api('/prompts/{name}', 'DELETE', path_params: { name: name }, return_http_data_only: true)
end

#delete_tag_for_prompt_template(name, tags) ⇒ Object

Delete tags for a prompt template



69
70
71
72
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 69

def delete_tag_for_prompt_template(name, tags)
  @api_client.call_api('/prompts/{name}/tags', 'DELETE', path_params: { name: name }, body: tags,
                                                         return_http_data_only: true)
end

#get_prompt(name) ⇒ Object

Get a prompt template



41
42
43
44
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 41

def get_prompt(name)
  @api_client.call_api('/prompts/{name}', 'GET', path_params: { name: name }, return_type: 'PromptTemplate',
                                                 return_http_data_only: true)
end

#get_promptsObject

Get all prompt templates



47
48
49
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 47

def get_prompts
  @api_client.call_api('/prompts', 'GET', return_type: 'Array<PromptTemplate>', return_http_data_only: true)
end

#get_tags_for_prompt_template(name) ⇒ Object

Get tags for a prompt template



57
58
59
60
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 57

def get_tags_for_prompt_template(name)
  @api_client.call_api('/prompts/{name}/tags', 'GET', path_params: { name: name },
                                                      return_type: 'Array<TagObject>', return_http_data_only: true)
end

#save_prompt(name, body, description: nil, models: nil, version: nil, auto_increment: false) ⇒ Object

Save a prompt template

Parameters:

  • name (String)

    Prompt name

  • body (String)

    Prompt template text

  • description (String) (defaults to: nil)

    Description

  • models (Array<String>) (defaults to: nil)

    Associated models

  • version (Integer) (defaults to: nil)

    Version number

  • auto_increment (Boolean) (defaults to: false)

    Auto increment version



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 23

def save_prompt(name, body, description: nil, models: nil, version: nil, auto_increment: false)
  query = {}
  query[:description] = description if description
  query[:models] = models if models
  query[:version] = version if version
  query[:autoIncrement] = auto_increment if auto_increment

  @api_client.call_api(
    '/prompts/{name}',
    'POST',
    path_params: { name: name },
    query_params: query,
    body: body,
    return_http_data_only: true
  )
end

#test_prompt(body) ⇒ Object

Test a prompt template



75
76
77
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 75

def test_prompt(body)
  @api_client.call_api('/prompts/test', 'POST', body: body, return_type: 'String', return_http_data_only: true)
end

#update_tag_for_prompt_template(name, tags) ⇒ Object

Update tags for a prompt template



63
64
65
66
# File 'lib/conductor/http/api/prompt_resource_api.rb', line 63

def update_tag_for_prompt_template(name, tags)
  @api_client.call_api('/prompts/{name}/tags', 'PUT', path_params: { name: name }, body: tags,
                                                      return_http_data_only: true)
end