Class: GAI18n::OpenAI::Assistant
- Inherits:
-
Object
- Object
- GAI18n::OpenAI::Assistant
- Defined in:
- lib/gai18n/openai/assistant.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#file_ids ⇒ Object
readonly
Returns the value of attribute file_ids.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Assistant
constructor
A new instance of Assistant.
Constructor Details
#initialize(response) ⇒ Assistant
Returns a new instance of Assistant.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gai18n/openai/assistant.rb', line 58 def initialize(response) @id = response['id'] @object = response['object'] @created_at = response['created_at'] @name = response['name'] @description = response['description'] @model = response['model'] @instructions = response['instructions'] @tools = response['tools'] @file_ids = response['file_ids'] @metadata = response['metadata'] end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def description @description end |
#file_ids ⇒ Object (readonly)
Returns the value of attribute file_ids.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def file_ids @file_ids end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def id @id end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def instructions @instructions end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def @metadata end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def name @name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def object @object end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
55 56 57 |
# File 'lib/gai18n/openai/assistant.rb', line 55 def tools @tools end |
Class Method Details
.create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gai18n/openai/assistant.rb', line 5 def create description = ['This assisistant was created by GAI18n', 'to help with internationalization.'].join ' ' instructions = "You are a software localization engineer. You have been tasked with translating the English source to the target language. You will be given a key and a source string. You will be asked to translate the source string to the target language. Once translated, please call the translation.submit function with the key, translated string, and the target language. If you are asked to translate into multiple target languages, please call the translation.submit function for each target language." openai_client = GAI18n.config.openai_client model = GAI18n.config.model parameters = { model: model, name: "GAI18n-#{Time.now.to_i}", description: description, instructions: instructions, tools: [ { type: "function", function: { name: "translation.submit", description: "Submit a translation", parameters: { type: "object", properties: { key: { type: "string", description: "The given key that's associated to the string needing translation." }, translation: { type: "string", description: "The translated string." }, language: { type: "string", description: "The language of the translation." } }, required: ["key", "translation", "language"] } } } ] } response = openai_client.assistants.create parameters: parameters new response end |