This PR adds the following two features 1. Prompt suggestions to get started with Copilot Chat 2. June events for each action  --------- Co-authored-by: Pranav <pranavrajs@gmail.com>
40 lines
921 B
Ruby
40 lines
921 B
Ruby
require 'openai'
|
|
|
|
class Captain::Copilot::ChatService < Captain::Llm::BaseOpenAiService
|
|
include Captain::ChatHelper
|
|
|
|
def initialize(assistant, config)
|
|
super()
|
|
|
|
@assistant = assistant
|
|
@conversation_history = config[:conversation_history]
|
|
@previous_messages = config[:previous_messages] || []
|
|
@messages = [system_message, conversation_history_context] + @previous_messages
|
|
@response = ''
|
|
end
|
|
|
|
def generate_response(input)
|
|
@messages << { role: 'user', content: input } if input.present?
|
|
request_chat_completion
|
|
end
|
|
|
|
private
|
|
|
|
def system_message
|
|
{
|
|
role: 'system',
|
|
content: Captain::Llm::SystemPromptsService.copilot_response_generator(@assistant.config['product_name'])
|
|
}
|
|
end
|
|
|
|
def conversation_history_context
|
|
{
|
|
role: 'system',
|
|
content: "
|
|
Message History with the user is below:
|
|
#{@conversation_history}
|
|
"
|
|
}
|
|
end
|
|
end
|