Class: MockGraphqlAi::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_graphql_ai.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Resource

Returns a new instance of Resource.



9
10
11
12
13
14
# File 'lib/mock_graphql_ai.rb', line 9

def initialize(options={})
  @query = options[:query]
  @openai_access_token = options[:token]
  @temperature = 0.3
  @model = "gpt-3.5-turbo"
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/mock_graphql_ai.rb', line 7

def client
  @client
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/mock_graphql_ai.rb', line 7

def name
  @name
end

#openai_access_tokenObject

Returns the value of attribute openai_access_token.



7
8
9
# File 'lib/mock_graphql_ai.rb', line 7

def openai_access_token
  @openai_access_token
end

#queryObject

Returns the value of attribute query.



7
8
9
# File 'lib/mock_graphql_ai.rb', line 7

def query
  @query
end

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/mock_graphql_ai.rb', line 7

def response
  @response
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/mock_graphql_ai.rb', line 7

def type
  @type
end

Instance Method Details

#respond!Object



16
17
18
19
20
# File 'lib/mock_graphql_ai.rb', line 16

def respond!
  @type, @name = grab_query_details
  initiate_openai_client
  get_response_from_ai
end