Skip to content

Conversation

@PSchmiedmayer
Copy link
Member

Improve Parameter Handling and Logger Output

♻️ Current situation & Problem

  • Some request combinations can lead to errors when sending LLM questions (e.g. passing in a temperature to GPT5). We currently don't have a nice way to log this and don't provide an user-facing error for this.

⚙️ Release Notes

  • Add error handling
  • Improve debug logging.
  • Only pass in stop parameter if specified.

📝 Code of Conduct & Contributing Guidelines

By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

Copy link

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 improves error handling and debugging capabilities for the OpenAI LLM integration by adding support for invalid request errors (HTTP 400), enhancing debug logging for undocumented responses, and fixing parameter handling to only send the stop parameter when it's specified.

Key Changes:

  • Add new invalidRequest error case with localized error messages for HTTP 400 responses
  • Implement debug logging to capture response body details when undocumented errors occur
  • Conditionally include the stop parameter only when the stop sequence is not empty

Reviewed changes

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

File Description
Sources/SpeziLLMOpenAI/Resources/Localizable.xcstrings Adds localized strings for invalid request error (description, failure reason, recovery suggestion)
Sources/SpeziLLMOpenAI/LLMOpenAISession+Generation.swift Adds debug logging to capture and log response body for undocumented errors
Sources/SpeziLLMOpenAI/LLMOpenAISession+Configuration.swift Conditionally sets stop parameter to nil when stopSequence is empty
Sources/SpeziLLMOpenAI/LLMOpenAIError.swift Adds new invalidRequest error case, implements error handling for HTTP 400, and adds error messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.47%. Comparing base (375d0fc) to head (cd366fa).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/SpeziLLMOpenAI/LLMOpenAISession+Generation.swift 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #134      +/-   ##
==========================================
- Coverage   44.64%   44.47%   -0.17%     
==========================================
  Files          69       69              
  Lines         522      524       +2     
==========================================
  Hits          233      233              
- Misses        289      291       +2     
Files with missing lines Coverage Δ
...es/SpeziLLM/InferenceQueue/LLMInferenceQueue.swift 68.43% <100.00%> (ø)
.../FunctionCalling/LLMFunctionParameterWrapper.swift 77.78% <ø> (ø)
Sources/SpeziLLMOpenAI/LLMOpenAIError.swift 0.00% <ø> (ø)
...peziLLMOpenAI/LLMOpenAISession+Configuration.swift 0.00% <ø> (ø)
Sources/SpeziLLMOpenAI/LLMOpenAISession.swift 26.09% <ø> (ø)
...s/SpeziLLMOpenAI/LLMOpenAISession+Generation.swift 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 375d0fc...cd366fa. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PSchmiedmayer PSchmiedmayer merged commit aff3d77 into main Dec 2, 2025
16 of 18 checks passed
@PSchmiedmayer PSchmiedmayer deleted the debugBody branch December 2, 2025 22:52
@github-project-automation github-project-automation bot moved this from Backlog to Done in Project Planning Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants