mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 11:01:38 +00:00
Handle context window overflow in error handling
This commit is contained in:
parent
a1f69c8dad
commit
3a938fa137
@ -164,7 +164,18 @@ public abstract class BaseProvider : IProvider, ISecretId
|
||||
|
||||
if(nextResponse.StatusCode is HttpStatusCode.BadRequest)
|
||||
{
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.CloudOff, string.Format(TB("Tried to communicate with the LLM provider '{0}'. The required message format might be changed. The provider message is: '{1}'"), this.InstanceName, nextResponse.ReasonPhrase)));
|
||||
// Check if the error body contains "context" and "token" (case-insensitive),
|
||||
// which indicates that the context window is likely exceeded:
|
||||
if(errorBody.Contains("context", StringComparison.InvariantCultureIgnoreCase) &&
|
||||
errorBody.Contains("token", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.CloudOff, string.Format(TB("We tried to communicate with the LLM provider '{0}' (type={1}). The data of the chat, including all file attachments, is probably too large for the selected model and provider. The provider message is: '{2}'"), this.InstanceName, this.Provider, nextResponse.ReasonPhrase)));
|
||||
}
|
||||
else
|
||||
{
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.CloudOff, string.Format(TB("We tried to communicate with the LLM provider '{0}' (type={1}). The required message format might be changed. The provider message is: '{2}'"), this.InstanceName, this.Provider, nextResponse.ReasonPhrase)));
|
||||
}
|
||||
|
||||
this.logger.LogError("Failed request with status code {ResponseStatusCode} (message = '{ResponseReasonPhrase}', error body = '{ErrorBody}').", nextResponse.StatusCode, nextResponse.ReasonPhrase, errorBody);
|
||||
errorMessage = nextResponse.ReasonPhrase;
|
||||
break;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# v26.1.2, build 232 (2026-01-xx xx:xx UTC)
|
||||
- Added the option to hide specific assistants by configuration plugins. This is useful for enterprise environments in organizations.
|
||||
- Added the current date and time to the system prompt for better context in conversations. Thanks Peer `peerschuett` for the contribution.
|
||||
- Added error handling for context window overflow, which can occur with huge file attachments in chats or the document analysis assistant.
|
||||
- Improved error handling for model loading in provider dialogs (LLMs, embeddings, transcriptions).
|
||||
- Improved the microphone handling (transcription preview) so that all sound effects and the voice recording are processed without interruption.
|
||||
- Improved the handling of self-hosted providers in the configuration dialogs (LLMs, embeddings, and transcriptions) when the host cannot provide a list of models.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user