-
Notifications
You must be signed in to change notification settings - Fork 17
Add --http-log CLI flag to replace DEBUG environment variable for HTTP request logging #77
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
Add --http-log CLI flag to replace DEBUG environment variable for HTTP request logging #77
Conversation
…eter Co-authored-by: pelikhan <[email protected]>
…usage Co-authored-by: pelikhan <[email protected]>
|
Add the httpLog flag to the Context instead of arguments |
Co-authored-by: pelikhan <[email protected]>
Done! I've refactored the HTTP logging to use Context instead of function parameters as requested. The changes include:
The functionality remains the same for users - the Commit: a46680e |
internal/azuremodels/azure_client.go
Outdated
| fmt.Fprintf(httpFile, "x-ms-user-agent: github-cli-models\n") | ||
| fmt.Fprintf(httpFile, "\n%s\n\n", string(bodyBytes)) | ||
| defer logFile.Close() | ||
| fmt.Fprintf(logFile, "### %s\n", time.Now().Format(time.RFC3339)) |
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.
Group all writes into a single Fprintf call to execute a single file write operation
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.
Done! Consolidated all the individual fmt.Fprintf calls into a single call to perform one file write operation instead of six separate writes. This improves performance by reducing the number of I/O operations.
Commit: e5e5b8f
Co-authored-by: pelikhan <[email protected]>
cmd/run/http_log_test.go
Outdated
| @@ -0,0 +1,50 @@ | |||
| package run | |||
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.
Remove this file
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.
Removed the file as requested. Commit: d19f533
| @@ -0,0 +1,34 @@ | |||
| package azuremodels | |||
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.
remove file
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.
Removed the file as requested. Commit: d19f533
Co-authored-by: pelikhan <[email protected]>
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 replaces the DEBUG environment variable with explicit --http-log CLI flags for controlling HTTP request logging in LLM inference commands. The implementation moves HTTP log configuration from environment variables to command-line parameters and uses context to pass this configuration through the call chain.
- Adds
--http-logflag torun,eval, andgeneratecommands for explicit HTTP logging control - Updates the
azuremodels.Clientinterface to use context-based HTTP log configuration instead of environment variables - Replaces
os.Getenv("DEBUG")checks with context-based HTTP log file retrieval
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/azuremodels/client.go | Adds context helper functions for HTTP log file management |
| internal/azuremodels/azure_client.go | Updates HTTP logging logic to use context instead of DEBUG environment variable |
| cmd/run/run.go | Adds --http-log flag and context integration |
| cmd/eval/eval.go | Adds --http-log flag and context integration |
| cmd/generate/generate.go | Adds --http-log flag and context integration |
| internal/azuremodels/debug_removal_test.go | Tests context-based HTTP logging functionality |
| cmd/run/http_log_test.go | Tests HTTP log parameter passing through the run command |
Co-authored-by: Copilot <[email protected]>
Summary
This PR adds a new
--http-logCLI flag to all commands that use LLM inference (run,eval,generate) and removes the dependency on theDEBUGenvironment variable for HTTP request logging.Changes Made
Interface Updates
azuremodels.Clientinterface to accept an optionalhttpLogFileparameter inGetChatCompletionStreamAzureClient,MockClient, andUnauthenticatedClientimplementations to match the new interfaceCLI Flag Addition
Added
--http-logflag to three commands:gh models run --http-log /path/to/logfile.loggh models eval --http-log /path/to/logfile.loggh models generate --http-log /path/to/logfile.logImplementation Details
os.Getenv("DEBUG")check withhttpLogFile != ""condition in HTTP logging codeBackward Compatibility
--http-logflag is not provided, no HTTP logging occurs (same as before when DEBUG was not set)Usage Examples
Testing
Fixes the issue by providing explicit control over HTTP logging through CLI flags instead of relying on environment variables.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.