Skip to content

Conversation

@redreceipt
Copy link
Member

Summary

  • request JSON from OpenAI when generating the weekly changelog
  • parse returned JSON to build Slack message

Testing

  • flake8 *.py (fails: command not found)

https://chatgpt.com/codex/tasks/task_e_68795dd834108324859407cad4f969fb

Copilot AI review requested due to automatic review settings July 17, 2025 20:42
@redreceipt redreceipt temporarily deployed to bug-board-codex-format--uisydz July 17, 2025 20:43 Inactive

This comment was marked as outdated.

@redreceipt redreceipt temporarily deployed to bug-board-codex-format--uisydz July 18, 2025 16:44 Inactive
@redreceipt redreceipt temporarily deployed to bug-board-codex-format--uisydz July 18, 2025 16:46 Inactive
@redreceipt redreceipt requested a review from Copilot July 18, 2025 16:47

This comment was marked as outdated.

redreceipt and others added 2 commits July 18, 2025 12:49
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@redreceipt redreceipt temporarily deployed to bug-board-codex-format--uisydz July 18, 2025 16:50 Inactive
@redreceipt redreceipt temporarily deployed to bug-board-codex-format--uisydz July 18, 2025 18:58 Inactive
@redreceipt redreceipt requested a review from Copilot July 18, 2025 18:59

This comment was marked as outdated.

@redreceipt redreceipt temporarily deployed to bug-board-codex-format--uisydz July 18, 2025 19:06 Inactive
@redreceipt redreceipt requested a review from Copilot July 18, 2025 19:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the OpenAI integration to use function calling for generating structured JSON changelogs instead of plain text responses. The changes enable more reliable parsing and formatting of weekly changelog data by requesting structured JSON output from OpenAI and building formatted Slack messages from the parsed results.

  • Replaced the generic get_chat_completion function with get_chat_function_call that uses OpenAI's function calling feature
  • Updated the changelog generation to request structured JSON with predefined sections (New Features, Bug Fixes, Improvements)
  • Added error handling and JSON parsing logic to build formatted Slack messages from the structured response

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
openai_client.py Refactored to use OpenAI's modern client and function calling API instead of the deprecated responses API
jobs.py Updated changelog generation to use structured JSON output with proper error handling and message formatting

# Ensure functions is a list of function specifications
if not isinstance(functions, list):
functions = [functions]
response = client.chat.completions.create(
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OpenAI API has deprecated the 'functions' parameter in favor of 'tools'. Consider updating to use tools=[{"type": "function", "function": functions[0]}] and tool_choice={"type": "function", "function": {"name": function_call_name}} for future compatibility.

Copilot uses AI. Check for mistakes.
temperature=temperature,
)
return resp.output_text.strip()
arguments = response.choices[0].message.function_call.arguments
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error handling for cases where the response doesn't contain function_call or choices is empty. Consider checking if response.choices exists and has function_call before accessing arguments.

Copilot uses AI. Check for mistakes.
"Failed to generate or parse changelog via function call. Error: %s",
e,
)
changelog_data = {}
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting changelog_data to an empty dict on error will result in an empty changelog. Consider providing a fallback message or default structure to inform users that changelog generation failed.

Suggested change
changelog_data = {}
changelog_data = {
"Error": ["Changelog generation failed. Please try again later."]
}

Copilot uses AI. Check for mistakes.
@redreceipt redreceipt merged commit ea4cc23 into main Jul 18, 2025
2 checks passed
@redreceipt redreceipt deleted the codex/format-weekly-changelog-consistently branch July 18, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants