Class: GetAiResponseJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
lib/generators/appchat/templates/get_ai_response_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chatObject (readonly)

Returns the value of attribute chat.



4
5
6
# File 'lib/generators/appchat/templates/get_ai_response_job.rb', line 4

def chat
  @chat
end

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/generators/appchat/templates/get_ai_response_job.rb', line 4

def client
  @client
end

#informed_promptObject (readonly)

Returns the value of attribute informed_prompt.



4
5
6
# File 'lib/generators/appchat/templates/get_ai_response_job.rb', line 4

def informed_prompt
  @informed_prompt
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/generators/appchat/templates/get_ai_response_job.rb', line 4

def message
  @message
end

#user_promptObject (readonly)

Returns the value of attribute user_prompt.



4
5
6
# File 'lib/generators/appchat/templates/get_ai_response_job.rb', line 4

def user_prompt
  @user_prompt
end

Instance Method Details

#perform(chat_id, user_prompt) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/generators/appchat/templates/get_ai_response_job.rb', line 6

def perform(chat_id, user_prompt)
  @client = new_client
  @chat = Chat.find(chat_id)
  @user_prompt = user_prompt
  @message = chat.messages.create(role: 'assistant')
  appchat_functions
  call_ollama
end