iachat/enterprise/app/services/captain/llm/assistant_chat_service.rb
Shivam Mishra 451c28a7a1
feat: add prompt suggestions and June events (#10726)
This PR adds the following two features

1. Prompt suggestions to get started with Copilot Chat
2. June events for each action

![CleanShot 2025-01-20 at 21 00
52@2x](https://github.com/user-attachments/assets/d73e7982-0f78-4d85-873e-da2c16762688)

---------

Co-authored-by: Pranav <pranavrajs@gmail.com>
2025-01-21 22:52:42 +05:30

29 lines
652 B
Ruby

require 'openai'
class Captain::Llm::AssistantChatService < Captain::Llm::BaseOpenAiService
include Captain::ChatHelper
def initialize(assistant: nil)
super()
@assistant = assistant
@messages = [system_message]
@response = ''
end
def generate_response(input, previous_messages = [], role = 'user')
@messages += previous_messages
@messages << { role: role, content: input } if input.present?
request_chat_completion
end
private
def system_message
{
role: 'system',
content: Captain::Llm::SystemPromptsService.assistant_response_generator(@assistant.config['product_name'])
}
end
end