-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Fix some issues in WASM self-hosted coding assistant config.
- Loading branch information
Showing
8 changed files
with
110 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...braries/Highbyte.DotNet6502.AI/CodingAssistant/Inference/OpenAI/DisableActivityHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Highbyte.DotNet6502.AI.CodingAssistant.Inference.OpenAI; | ||
public class DisableActivityHandler : DelegatingHandler | ||
{ | ||
/// <summary> | ||
/// Distributed tracing headers that is set automatically by .NET that local Ollama API CORS rules doesn't allow. | ||
/// </summary> | ||
static readonly List<string> s_HeadersToRemove = new List<string> | ||
{ | ||
"x-ms-client-request-id", | ||
"x-ms-return-client-request-id" | ||
}; | ||
|
||
public DisableActivityHandler(HttpMessageHandler innerHandler) : base(innerHandler) | ||
{ | ||
|
||
} | ||
|
||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
{ | ||
// Note: A workaround by setting Activity.Current = null doesn't seem to work. Instead remove headers manually below. | ||
//Activity.Current = null; | ||
|
||
// Remove s_HeadersToRemove list of header from request if they exist. | ||
foreach (var headerName in s_HeadersToRemove) | ||
{ | ||
if (request.Headers.Contains(headerName)) | ||
{ | ||
request.Headers.Remove(headerName); | ||
Activity.Current = null; | ||
} | ||
} | ||
|
||
return await base.SendAsync(request, cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters