Module: RubyTodo::AIAssistant::TaskOpenAIQuery
- Included in:
- TaskCreatorCombined
- Defined in:
- lib/ruby_todo/ai_assistant/task_creator.rb
Overview
Module for OpenAI query related to task creation
Instance Method Summary collapse
-
#query_openai_for_task_details(task_query, api_key) ⇒ Object
Query OpenAI for task details.
Instance Method Details
#query_openai_for_task_details(task_query, api_key) ⇒ Object
Query OpenAI for task details
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/ruby_todo/ai_assistant/task_creator.rb', line 73 def query_openai_for_task_details(task_query, api_key) client = OpenAI::Client.new(access_token: api_key) system_prompt = " You are a task management assistant that generates professional task details.\n\n Transform simple task descriptions into professional, action-oriented titles that clearly communicate purpose.\n\n Examples of transformations:\n - \"add new relic infra to questions-engine\" \u2192 \"Integrate New Relic Infrastructure with Questions Engine\"\n - \"update docker image for app\" \u2192 \"Update and Standardize Docker Image Configuration for Application\"\n - \"fix login bug\" \u2192 \"Resolve Authentication Issue in Login System\"\n - \"add monitoring to service\" \u2192 \"Implement Comprehensive Monitoring Solution for Service\"\n - \"migrate repo to new org\" \u2192 \"Migrate Repository to New Organization Structure\"\n - \"add newrelic to the questions engine app\" \u2192 \"Integrate New Relic Monitoring with Questions Engine Application\"\n - \"create a new task to add newrelic to the questions engine app\" \u2192 \"Implement New Relic Monitoring for Questions Engine Application\"\n\n Create concise but descriptive titles that use proper capitalization and professional terminology.\n\n IMPORTANT: For priority field, you MUST use ONLY one of these exact values: \"high\", \"medium\", or \"low\" (lowercase).\n PROMPT\n\n messages = [\n { role: \"system\", content: system_prompt },\n { role: \"user\", content: task_query }\n ]\n\n say \"Generating professional task details...\" if @options[:verbose]\n\n response = client.chat(parameters: {\n model: \"gpt-4o\",\n messages: messages,\n temperature: 0.6,\n max_tokens: 500\n })\n\n response[\"choices\"][0][\"message\"][\"content\"]\nrescue StandardError => e\n # If gpt-4o fails (not available), fallback to gpt-4o-mini\n if e.message.include?(\"gpt-4o\")\n client.chat(parameters: {\n model: \"gpt-4o-mini\",\n messages: messages,\n temperature: 0.6,\n max_tokens: 500\n })[\"choices\"][0][\"message\"][\"content\"]\n else\n raise e\n end\nend\n" |