-
Notifications
You must be signed in to change notification settings - Fork 0
Request JSON from OpenAI for changelog #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this 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_completionfunction withget_chat_function_callthat 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( |
Copilot
AI
Jul 18, 2025
There was a problem hiding this comment.
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.
| temperature=temperature, | ||
| ) | ||
| return resp.output_text.strip() | ||
| arguments = response.choices[0].message.function_call.arguments |
Copilot
AI
Jul 18, 2025
There was a problem hiding this comment.
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.
| "Failed to generate or parse changelog via function call. Error: %s", | ||
| e, | ||
| ) | ||
| changelog_data = {} |
Copilot
AI
Jul 18, 2025
There was a problem hiding this comment.
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.
| changelog_data = {} | |
| changelog_data = { | |
| "Error": ["Changelog generation failed. Please try again later."] | |
| } |
Summary
Testing
flake8 *.py(fails: command not found)https://chatgpt.com/codex/tasks/task_e_68795dd834108324859407cad4f969fb