diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Chat.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Chat.g.cs
index 78180da..eececdd 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Chat.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Chat.g.cs
@@ -9,6 +9,7 @@ public partial interface IOllamaClient
/// Generate the next chat message in a conversation between a user and an assistant.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -25,6 +26,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task ChatAsync(
global::Ollama.ChatRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Generate a chat message
@@ -57,6 +59,7 @@ public partial interface IOllamaClient
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task ChatAsync(
@@ -69,6 +72,7 @@ public partial interface IOllamaClient
global::Ollama.OneOf? keepAlive = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.ChatAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.ChatAsStream.g.cs
index 6f1f814..6e36da1 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.ChatAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.ChatAsStream.g.cs
@@ -9,6 +9,7 @@ public partial interface IOllamaClient
/// Generate the next chat message in a conversation between a user and an assistant.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -25,6 +26,7 @@ public partial interface IOllamaClient
global::System.Collections.Generic.IAsyncEnumerable ChatAsStreamAsync(
global::Ollama.ChatRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Generate a chat message
@@ -57,6 +59,7 @@ public partial interface IOllamaClient
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Collections.Generic.IAsyncEnumerable ChatAsStreamAsync(
@@ -69,6 +72,7 @@ public partial interface IOllamaClient
global::Ollama.OneOf? keepAlive = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Copy.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Copy.g.cs
index 40c7c45..3e37865 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Copy.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Copy.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Copy a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -19,6 +20,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task CopyAsync(
global::Ollama.CopyRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Copy a model
@@ -29,11 +31,13 @@ public partial interface IOllamaClient
///
/// New model name to create
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task CopyAsync(
string source,
string destination,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Create.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Create.g.cs
index d5cd2c8..bef5b05 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Create.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Create.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Create a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -20,6 +21,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task CreateAsync(
global::Ollama.CreateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a model
@@ -48,6 +50,7 @@ public partial interface IOllamaClient
///
/// Quantization level to apply (e.g. `q4_K_M`, `q8_0`)
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task CreateAsync(
@@ -59,6 +62,7 @@ public partial interface IOllamaClient
object? parameters = default,
global::System.Collections.Generic.IList? messages = default,
string? quantize = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.CreateAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.CreateAsStream.g.cs
index 97900f5..8600e6f 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.CreateAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.CreateAsStream.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Create a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -20,6 +21,7 @@ public partial interface IOllamaClient
global::System.Collections.Generic.IAsyncEnumerable CreateAsStreamAsync(
global::Ollama.CreateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Create a model
@@ -48,6 +50,7 @@ public partial interface IOllamaClient
///
/// Quantization level to apply (e.g. `q4_K_M`, `q8_0`)
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Collections.Generic.IAsyncEnumerable CreateAsStreamAsync(
@@ -59,6 +62,7 @@ public partial interface IOllamaClient
object? parameters = default,
global::System.Collections.Generic.IList? messages = default,
string? quantize = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Delete.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Delete.g.cs
index 76a92ac..97d9f77 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Delete.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Delete.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Delete a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -18,6 +19,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task DeleteAsync(
global::Ollama.DeleteRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Delete a model
@@ -25,10 +27,12 @@ public partial interface IOllamaClient
///
/// Model name to delete
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task DeleteAsync(
string model,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Embed.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Embed.g.cs
index a4be95e..8b3c7b1 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Embed.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Embed.g.cs
@@ -9,6 +9,7 @@ public partial interface IOllamaClient
/// Creates vector embeddings representing the input text
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -20,6 +21,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task EmbedAsync(
global::Ollama.EmbedRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Generate embeddings
@@ -44,6 +46,7 @@ public partial interface IOllamaClient
///
/// Runtime options that control text generation
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task EmbedAsync(
@@ -53,6 +56,7 @@ public partial interface IOllamaClient
int? dimensions = default,
string? keepAlive = default,
global::Ollama.ModelOptions? options = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Generate.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Generate.g.cs
index e358775..0d7a461 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Generate.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Generate.g.cs
@@ -9,6 +9,7 @@ public partial interface IOllamaClient
/// Generates a response for the provided prompt
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -20,6 +21,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task GenerateAsync(
global::Ollama.GenerateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Generate a response
@@ -59,6 +61,7 @@ public partial interface IOllamaClient
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task GenerateAsync(
@@ -74,6 +77,7 @@ public partial interface IOllamaClient
global::Ollama.ModelOptions? options = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.GenerateAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.GenerateAsStream.g.cs
index a1b4172..890577b 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.GenerateAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.GenerateAsStream.g.cs
@@ -9,6 +9,7 @@ public partial interface IOllamaClient
/// Generates a response for the provided prompt
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -20,6 +21,7 @@ public partial interface IOllamaClient
global::System.Collections.Generic.IAsyncEnumerable GenerateAsStreamAsync(
global::Ollama.GenerateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Generate a response
@@ -59,6 +61,7 @@ public partial interface IOllamaClient
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Collections.Generic.IAsyncEnumerable GenerateAsStreamAsync(
@@ -74,6 +77,7 @@ public partial interface IOllamaClient
global::Ollama.ModelOptions? options = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.List.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.List.g.cs
index 0bbd309..c09b87c 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.List.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.List.g.cs
@@ -8,12 +8,14 @@ public partial interface IOllamaClient
/// List models
/// Fetch a list of models and their details
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
/// curl http://localhost:11434/api/tags
///
global::System.Threading.Tasks.Task ListAsync(
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Ps.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Ps.g.cs
index b4a983c..a0e6c26 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Ps.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Ps.g.cs
@@ -8,12 +8,14 @@ public partial interface IOllamaClient
/// List running models
/// Retrieve a list of models that are currently running
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
/// curl http://localhost:11434/api/ps
///
global::System.Threading.Tasks.Task PsAsync(
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Pull.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Pull.g.cs
index e75841c..588c25c 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Pull.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Pull.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Pull a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -18,6 +19,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task PullAsync(
global::Ollama.PullRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Pull a model
@@ -28,11 +30,13 @@ public partial interface IOllamaClient
///
/// Allow downloading over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task PullAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.PullAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.PullAsStream.g.cs
index 3582478..7fa276c 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.PullAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.PullAsStream.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Pull a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -18,6 +19,7 @@ public partial interface IOllamaClient
global::System.Collections.Generic.IAsyncEnumerable PullAsStreamAsync(
global::Ollama.PullRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Pull a model
@@ -28,11 +30,13 @@ public partial interface IOllamaClient
///
/// Allow downloading over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Collections.Generic.IAsyncEnumerable PullAsStreamAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Push.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Push.g.cs
index 80befd0..464e9b5 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Push.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Push.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Push a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -18,6 +19,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task PushAsync(
global::Ollama.PushRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Push a model
@@ -28,11 +30,13 @@ public partial interface IOllamaClient
///
/// Allow publishing over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task PushAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.PushAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.PushAsStream.g.cs
index 1bcb239..25e9d8e 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.PushAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.PushAsStream.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Push a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -18,6 +19,7 @@ public partial interface IOllamaClient
global::System.Collections.Generic.IAsyncEnumerable PushAsStreamAsync(
global::Ollama.PushRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Push a model
@@ -28,11 +30,13 @@ public partial interface IOllamaClient
///
/// Allow publishing over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Collections.Generic.IAsyncEnumerable PushAsStreamAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Show.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Show.g.cs
index 182e9db..aa7fa9a 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Show.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Show.g.cs
@@ -8,6 +8,7 @@ public partial interface IOllamaClient
/// Show model details
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -18,6 +19,7 @@ public partial interface IOllamaClient
global::System.Threading.Tasks.Task ShowAsync(
global::Ollama.ShowRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
///
/// Show model details
@@ -28,11 +30,13 @@ public partial interface IOllamaClient
///
/// If true, includes large verbose fields in the response.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
global::System.Threading.Tasks.Task ShowAsync(
string model,
bool? verbose = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Version.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Version.g.cs
index 6c7f373..424048a 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.Version.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.Version.g.cs
@@ -8,12 +8,14 @@ public partial interface IOllamaClient
/// Get version
/// Retrieve the version of the Ollama
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
/// curl http://localhost:11434/api/version
///
global::System.Threading.Tasks.Task VersionAsync(
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.IOllamaClient.g.cs b/src/libs/Ollama/Generated/Ollama.IOllamaClient.g.cs
index c531386..d21c253 100644
--- a/src/libs/Ollama/Generated/Ollama.IOllamaClient.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.IOllamaClient.g.cs
@@ -33,6 +33,11 @@ public partial interface IOllamaClient : global::System.IDisposable
/// ensuring is populated.
///
public bool ReadResponseAsString { get; set; }
+ ///
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ ///
+ public global::Ollama.AutoSDKClientOptions Options { get; }
+
///
///
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Chat.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Chat.g.cs
index 3bd5cfe..b8ccaa8 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Chat.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Chat.g.cs
@@ -26,6 +26,7 @@ partial void ProcessChatResponseContent(
/// Generate the next chat message in a conversation between a user and an assistant.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -42,6 +43,7 @@ partial void ProcessChatResponseContent(
public async global::System.Threading.Tasks.Task ChatAsync(
global::Ollama.ChatRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -65,126 +67,305 @@ partial void ProcessChatResponseContent(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/chat",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareChatRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessChatResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/chat",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessChatResponseContent(
+ request: __httpRequest);
+ PrepareChatRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest,
+ request: request);
- return
- global::Ollama.ChatResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.ChatResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Chat",
+ methodName: "ChatAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Chat",
+ methodName: "ChatAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Chat",
+ methodName: "ChatAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessChatResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Chat",
+ methodName: "ChatAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Chat",
+ methodName: "ChatAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessChatResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.ChatResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.ChatResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -218,6 +399,7 @@ partial void ProcessChatResponseContent(
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ChatAsync(
@@ -230,6 +412,7 @@ partial void ProcessChatResponseContent(
global::Ollama.OneOf? keepAlive = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.ChatRequest
@@ -248,6 +431,7 @@ partial void ProcessChatResponseContent(
return await ChatAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.ChatAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.ChatAsStream.g.cs
index aa63788..3432fea 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.ChatAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.ChatAsStream.g.cs
@@ -21,6 +21,7 @@ partial void ProcessChatAsStreamResponse(
/// Generate the next chat message in a conversation between a user and an assistant.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -37,6 +38,7 @@ partial void ProcessChatAsStreamResponse(
public async global::System.Collections.Generic.IAsyncEnumerable ChatAsStreamAsync(
global::Ollama.ChatRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -60,105 +62,284 @@ partial void ProcessChatAsStreamResponse(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/chat",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/chat",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareChatAsStreamRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareChatAsStreamRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessChatAsStreamResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ return __httpRequest;
+ }
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
try
{
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Net.Http.HttpRequestException __ex)
- {
- string? __content = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ChatAsStream",
+ methodName: "ChatAsStreamAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ChatAsStream",
+ methodName: "ChatAsStreamAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ChatAsStream",
+ methodName: "ChatAsStreamAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- using var __stream = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- using var __reader = new global::System.IO.StreamReader(__stream);
-
- while (!__reader.EndOfStream && !cancellationToken.IsCancellationRequested)
- {
- var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
- if (global::System.String.IsNullOrWhiteSpace(__content))
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessChatAsStreamResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- continue;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ChatAsStream",
+ methodName: "ChatAsStreamAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ChatAsStream",
+ methodName: "ChatAsStreamAsync",
+ pathTemplate: "\"/api/chat\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ }
+ catch (global::System.Net.Http.HttpRequestException __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
- var __streamedResponse = global::Ollama.ChatStreamEvent.FromJson(__content, JsonSerializerContext) ??
- throw new global::Ollama.ApiException(
- message: $"Response deserialization failed for \"{__content}\" ",
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
-
- yield return __streamedResponse;
+ using var __stream = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ using var __reader = new global::System.IO.StreamReader(__stream);
+
+ while (!__reader.EndOfStream && !__effectiveCancellationToken.IsCancellationRequested)
+ {
+ var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
+ if (global::System.String.IsNullOrWhiteSpace(__content))
+ {
+ continue;
+ }
+
+ var __streamedResponse = global::Ollama.ChatStreamEvent.FromJson(__content, JsonSerializerContext) ??
+ throw new global::Ollama.ApiException(
+ message: $"Response deserialization failed for \"{__content}\" ",
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+
+ yield return __streamedResponse;
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -192,6 +373,7 @@ partial void ProcessChatAsStreamResponse(
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Collections.Generic.IAsyncEnumerable ChatAsStreamAsync(
@@ -204,6 +386,7 @@ partial void ProcessChatAsStreamResponse(
global::Ollama.OneOf? keepAlive = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.ChatRequest
@@ -222,6 +405,7 @@ partial void ProcessChatAsStreamResponse(
var __enumerable = ChatAsStreamAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Copy.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Copy.g.cs
index 44bd0ff..4e4864d 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Copy.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Copy.g.cs
@@ -20,6 +20,7 @@ partial void ProcessCopyResponse(
/// Copy a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -31,6 +32,7 @@ partial void ProcessCopyResponse(
public async global::System.Threading.Tasks.Task CopyAsync(
global::Ollama.CopyRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -41,110 +43,289 @@ partial void ProcessCopyResponse(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/copy",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCopyRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCopyResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/copy",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
+ request: __httpRequest);
+ PrepareCopyRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Copy",
+ methodName: "CopyAsync",
+ pathTemplate: "\"/api/copy\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Copy",
+ methodName: "CopyAsync",
+ pathTemplate: "\"/api/copy\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Copy",
+ methodName: "CopyAsync",
+ pathTemplate: "\"/api/copy\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCopyResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Copy",
+ methodName: "CopyAsync",
+ pathTemplate: "\"/api/copy\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Copy",
+ methodName: "CopyAsync",
+ pathTemplate: "\"/api/copy\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -156,11 +337,13 @@ partial void ProcessCopyResponse(
///
/// New model name to create
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CopyAsync(
string source,
string destination,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.CopyRequest
@@ -171,6 +354,7 @@ partial void ProcessCopyResponse(
await CopyAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Create.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Create.g.cs
index 2ca28b1..77cfecf 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Create.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Create.g.cs
@@ -25,6 +25,7 @@ partial void ProcessCreateResponseContent(
/// Create a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -37,6 +38,7 @@ partial void ProcessCreateResponseContent(
public async global::System.Threading.Tasks.Task CreateAsync(
global::Ollama.CreateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -59,126 +61,305 @@ partial void ProcessCreateResponseContent(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/create",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/create",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateResponseContent(
+ request: __httpRequest);
+ PrepareCreateRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest,
+ request: request);
- return
- global::Ollama.StatusResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.StatusResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Create",
+ methodName: "CreateAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Create",
+ methodName: "CreateAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Create",
+ methodName: "CreateAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Create",
+ methodName: "CreateAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Create",
+ methodName: "CreateAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreateResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.StatusResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.StatusResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -208,6 +389,7 @@ partial void ProcessCreateResponseContent(
///
/// Quantization level to apply (e.g. `q4_K_M`, `q8_0`)
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CreateAsync(
@@ -219,6 +401,7 @@ partial void ProcessCreateResponseContent(
object? parameters = default,
global::System.Collections.Generic.IList? messages = default,
string? quantize = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.CreateRequest
@@ -236,6 +419,7 @@ partial void ProcessCreateResponseContent(
return await CreateAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.CreateAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.CreateAsStream.g.cs
index 633ef79..f99ad88 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.CreateAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.CreateAsStream.g.cs
@@ -20,6 +20,7 @@ partial void ProcessCreateAsStreamResponse(
/// Create a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -32,6 +33,7 @@ partial void ProcessCreateAsStreamResponse(
public async global::System.Collections.Generic.IAsyncEnumerable CreateAsStreamAsync(
global::Ollama.CreateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -54,105 +56,284 @@ partial void ProcessCreateAsStreamResponse(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/create",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/create",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateAsStreamRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateAsStreamRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateAsStreamResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ return __httpRequest;
+ }
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
try
{
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Net.Http.HttpRequestException __ex)
- {
- string? __content = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAsStream",
+ methodName: "CreateAsStreamAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAsStream",
+ methodName: "CreateAsStreamAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAsStream",
+ methodName: "CreateAsStreamAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- using var __stream = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- using var __reader = new global::System.IO.StreamReader(__stream);
-
- while (!__reader.EndOfStream && !cancellationToken.IsCancellationRequested)
- {
- var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
- if (global::System.String.IsNullOrWhiteSpace(__content))
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessCreateAsStreamResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- continue;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAsStream",
+ methodName: "CreateAsStreamAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAsStream",
+ methodName: "CreateAsStreamAsync",
+ pathTemplate: "\"/api/create\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ }
+ catch (global::System.Net.Http.HttpRequestException __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
- var __streamedResponse = global::Ollama.StatusEvent.FromJson(__content, JsonSerializerContext) ??
- throw new global::Ollama.ApiException(
- message: $"Response deserialization failed for \"{__content}\" ",
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
-
- yield return __streamedResponse;
+ using var __stream = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ using var __reader = new global::System.IO.StreamReader(__stream);
+
+ while (!__reader.EndOfStream && !__effectiveCancellationToken.IsCancellationRequested)
+ {
+ var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
+ if (global::System.String.IsNullOrWhiteSpace(__content))
+ {
+ continue;
+ }
+
+ var __streamedResponse = global::Ollama.StatusEvent.FromJson(__content, JsonSerializerContext) ??
+ throw new global::Ollama.ApiException(
+ message: $"Response deserialization failed for \"{__content}\" ",
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+
+ yield return __streamedResponse;
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -182,6 +363,7 @@ partial void ProcessCreateAsStreamResponse(
///
/// Quantization level to apply (e.g. `q4_K_M`, `q8_0`)
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Collections.Generic.IAsyncEnumerable CreateAsStreamAsync(
@@ -193,6 +375,7 @@ partial void ProcessCreateAsStreamResponse(
object? parameters = default,
global::System.Collections.Generic.IList? messages = default,
string? quantize = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.CreateRequest
@@ -210,6 +393,7 @@ partial void ProcessCreateAsStreamResponse(
var __enumerable = CreateAsStreamAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Delete.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Delete.g.cs
index fc53ea3..899f429 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Delete.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Delete.g.cs
@@ -20,6 +20,7 @@ partial void ProcessDeleteResponse(
/// Delete a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -30,6 +31,7 @@ partial void ProcessDeleteResponse(
public async global::System.Threading.Tasks.Task DeleteAsync(
global::Ollama.DeleteRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -40,110 +42,289 @@ partial void ProcessDeleteResponse(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/delete",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/delete",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
+ request: __httpRequest);
+ PrepareDeleteRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- try
- {
- __response.EnsureSuccessStatusCode();
-
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Delete",
+ methodName: "DeleteAsync",
+ pathTemplate: "\"/api/delete\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Delete",
+ methodName: "DeleteAsync",
+ pathTemplate: "\"/api/delete\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Delete",
+ methodName: "DeleteAsync",
+ pathTemplate: "\"/api/delete\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessDeleteResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Delete",
+ methodName: "DeleteAsync",
+ pathTemplate: "\"/api/delete\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Delete",
+ methodName: "DeleteAsync",
+ pathTemplate: "\"/api/delete\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -152,10 +333,12 @@ partial void ProcessDeleteResponse(
///
/// Model name to delete
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DeleteAsync(
string model,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.DeleteRequest
@@ -165,6 +348,7 @@ partial void ProcessDeleteResponse(
await DeleteAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Embed.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Embed.g.cs
index 81552c0..09134e4 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Embed.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Embed.g.cs
@@ -26,6 +26,7 @@ partial void ProcessEmbedResponseContent(
/// Creates vector embeddings representing the input text
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -37,6 +38,7 @@ partial void ProcessEmbedResponseContent(
public async global::System.Threading.Tasks.Task EmbedAsync(
global::Ollama.EmbedRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -47,126 +49,305 @@ partial void ProcessEmbedResponseContent(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/embed",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareEmbedRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessEmbedResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/embed",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessEmbedResponseContent(
+ request: __httpRequest);
+ PrepareEmbedRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest,
+ request: request);
- return
- global::Ollama.EmbedResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.EmbedResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Embed",
+ methodName: "EmbedAsync",
+ pathTemplate: "\"/api/embed\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Embed",
+ methodName: "EmbedAsync",
+ pathTemplate: "\"/api/embed\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Embed",
+ methodName: "EmbedAsync",
+ pathTemplate: "\"/api/embed\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessEmbedResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Embed",
+ methodName: "EmbedAsync",
+ pathTemplate: "\"/api/embed\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Embed",
+ methodName: "EmbedAsync",
+ pathTemplate: "\"/api/embed\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessEmbedResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.EmbedResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.EmbedResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -192,6 +373,7 @@ partial void ProcessEmbedResponseContent(
///
/// Runtime options that control text generation
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task EmbedAsync(
@@ -201,6 +383,7 @@ partial void ProcessEmbedResponseContent(
int? dimensions = default,
string? keepAlive = default,
global::Ollama.ModelOptions? options = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.EmbedRequest
@@ -215,6 +398,7 @@ partial void ProcessEmbedResponseContent(
return await EmbedAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Generate.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Generate.g.cs
index 4cd5fbc..33133b7 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Generate.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Generate.g.cs
@@ -26,6 +26,7 @@ partial void ProcessGenerateResponseContent(
/// Generates a response for the provided prompt
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -37,6 +38,7 @@ partial void ProcessGenerateResponseContent(
public async global::System.Threading.Tasks.Task GenerateAsync(
global::Ollama.GenerateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -63,126 +65,305 @@ partial void ProcessGenerateResponseContent(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/generate",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGenerateRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGenerateResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/generate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGenerateResponseContent(
+ request: __httpRequest);
+ PrepareGenerateRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest,
+ request: request);
- return
- global::Ollama.GenerateResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.GenerateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Generate",
+ methodName: "GenerateAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Generate",
+ methodName: "GenerateAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Generate",
+ methodName: "GenerateAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGenerateResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Generate",
+ methodName: "GenerateAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Generate",
+ methodName: "GenerateAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessGenerateResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.GenerateResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.GenerateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -223,6 +404,7 @@ partial void ProcessGenerateResponseContent(
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task GenerateAsync(
@@ -238,6 +420,7 @@ partial void ProcessGenerateResponseContent(
global::Ollama.ModelOptions? options = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.GenerateRequest
@@ -259,6 +442,7 @@ partial void ProcessGenerateResponseContent(
return await GenerateAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.GenerateAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.GenerateAsStream.g.cs
index ff2e62c..b5b7e98 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.GenerateAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.GenerateAsStream.g.cs
@@ -21,6 +21,7 @@ partial void ProcessGenerateAsStreamResponse(
/// Generates a response for the provided prompt
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -32,6 +33,7 @@ partial void ProcessGenerateAsStreamResponse(
public async global::System.Collections.Generic.IAsyncEnumerable GenerateAsStreamAsync(
global::Ollama.GenerateRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -58,105 +60,284 @@ partial void ProcessGenerateAsStreamResponse(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/generate",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/generate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGenerateAsStreamRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGenerateAsStreamRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGenerateAsStreamResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ return __httpRequest;
+ }
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
try
{
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Net.Http.HttpRequestException __ex)
- {
- string? __content = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateAsStream",
+ methodName: "GenerateAsStreamAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateAsStream",
+ methodName: "GenerateAsStreamAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateAsStream",
+ methodName: "GenerateAsStreamAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- using var __stream = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- using var __reader = new global::System.IO.StreamReader(__stream);
-
- while (!__reader.EndOfStream && !cancellationToken.IsCancellationRequested)
- {
- var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
- if (global::System.String.IsNullOrWhiteSpace(__content))
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGenerateAsStreamResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- continue;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateAsStream",
+ methodName: "GenerateAsStreamAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateAsStream",
+ methodName: "GenerateAsStreamAsync",
+ pathTemplate: "\"/api/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ }
+ catch (global::System.Net.Http.HttpRequestException __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
- var __streamedResponse = global::Ollama.GenerateStreamEvent.FromJson(__content, JsonSerializerContext) ??
- throw new global::Ollama.ApiException(
- message: $"Response deserialization failed for \"{__content}\" ",
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
-
- yield return __streamedResponse;
+ using var __stream = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ using var __reader = new global::System.IO.StreamReader(__stream);
+
+ while (!__reader.EndOfStream && !__effectiveCancellationToken.IsCancellationRequested)
+ {
+ var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
+ if (global::System.String.IsNullOrWhiteSpace(__content))
+ {
+ continue;
+ }
+
+ var __streamedResponse = global::Ollama.GenerateStreamEvent.FromJson(__content, JsonSerializerContext) ??
+ throw new global::Ollama.ApiException(
+ message: $"Response deserialization failed for \"{__content}\" ",
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+
+ yield return __streamedResponse;
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -197,6 +378,7 @@ partial void ProcessGenerateAsStreamResponse(
///
/// Number of most likely tokens to return at each token position when logprobs are enabled
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Collections.Generic.IAsyncEnumerable GenerateAsStreamAsync(
@@ -212,6 +394,7 @@ partial void ProcessGenerateAsStreamResponse(
global::Ollama.ModelOptions? options = default,
bool? logprobs = default,
int? topLogprobs = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.GenerateRequest
@@ -233,6 +416,7 @@ partial void ProcessGenerateAsStreamResponse(
var __enumerable = GenerateAsStreamAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.List.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.List.g.cs
index da0a795..4a83431 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.List.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.List.g.cs
@@ -23,12 +23,14 @@ partial void ProcessListResponseContent(
/// List models
/// Fetch a list of models and their details
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
/// curl http://localhost:11434/api/tags
///
public async global::System.Threading.Tasks.Task ListAsync(
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -36,119 +38,298 @@ partial void ProcessListResponseContent(
PrepareListArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/tags",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/tags",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListResponseContent(
+ request: __httpRequest);
+ PrepareListRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest);
- return
- global::Ollama.ListResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.ListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "List",
+ methodName: "ListAsync",
+ pathTemplate: "\"/api/tags\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "List",
+ methodName: "ListAsync",
+ pathTemplate: "\"/api/tags\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "List",
+ methodName: "ListAsync",
+ pathTemplate: "\"/api/tags\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessListResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "List",
+ methodName: "ListAsync",
+ pathTemplate: "\"/api/tags\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "List",
+ methodName: "ListAsync",
+ pathTemplate: "\"/api/tags\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.ListResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.ListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Ps.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Ps.g.cs
index a4098a3..b96aae7 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Ps.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Ps.g.cs
@@ -23,12 +23,14 @@ partial void ProcessPsResponseContent(
/// List running models
/// Retrieve a list of models that are currently running
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
/// curl http://localhost:11434/api/ps
///
public async global::System.Threading.Tasks.Task PsAsync(
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -36,119 +38,298 @@ partial void ProcessPsResponseContent(
PreparePsArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/ps",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/ps",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPsResponseContent(
+ request: __httpRequest);
+ PreparePsRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest);
- return
- global::Ollama.PsResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.PsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Ps",
+ methodName: "PsAsync",
+ pathTemplate: "\"/api/ps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Ps",
+ methodName: "PsAsync",
+ pathTemplate: "\"/api/ps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Ps",
+ methodName: "PsAsync",
+ pathTemplate: "\"/api/ps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Ps",
+ methodName: "PsAsync",
+ pathTemplate: "\"/api/ps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Ps",
+ methodName: "PsAsync",
+ pathTemplate: "\"/api/ps\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.PsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.PsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Pull.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Pull.g.cs
index a090926..9fa5ba9 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Pull.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Pull.g.cs
@@ -25,6 +25,7 @@ partial void ProcessPullResponseContent(
/// Pull a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -35,6 +36,7 @@ partial void ProcessPullResponseContent(
public async global::System.Threading.Tasks.Task PullAsync(
global::Ollama.PullRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -51,126 +53,305 @@ partial void ProcessPullResponseContent(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/pull",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePullRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPullResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/pull",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPullResponseContent(
+ request: __httpRequest);
+ PreparePullRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest,
+ request: request);
- return
- global::Ollama.StatusResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.StatusResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Pull",
+ methodName: "PullAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Pull",
+ methodName: "PullAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Pull",
+ methodName: "PullAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPullResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Pull",
+ methodName: "PullAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Pull",
+ methodName: "PullAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPullResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.StatusResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.StatusResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -182,11 +363,13 @@ partial void ProcessPullResponseContent(
///
/// Allow downloading over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task PullAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.PullRequest
@@ -198,6 +381,7 @@ partial void ProcessPullResponseContent(
return await PullAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.PullAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.PullAsStream.g.cs
index 3169cf5..73eed57 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.PullAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.PullAsStream.g.cs
@@ -20,6 +20,7 @@ partial void ProcessPullAsStreamResponse(
/// Pull a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -30,6 +31,7 @@ partial void ProcessPullAsStreamResponse(
public async global::System.Collections.Generic.IAsyncEnumerable PullAsStreamAsync(
global::Ollama.PullRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -46,105 +48,284 @@ partial void ProcessPullAsStreamResponse(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/pull",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/pull",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePullAsStreamRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePullAsStreamRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPullAsStreamResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ return __httpRequest;
+ }
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
try
{
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Net.Http.HttpRequestException __ex)
- {
- string? __content = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PullAsStream",
+ methodName: "PullAsStreamAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PullAsStream",
+ methodName: "PullAsStreamAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PullAsStream",
+ methodName: "PullAsStreamAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- using var __stream = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- using var __reader = new global::System.IO.StreamReader(__stream);
-
- while (!__reader.EndOfStream && !cancellationToken.IsCancellationRequested)
- {
- var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
- if (global::System.String.IsNullOrWhiteSpace(__content))
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPullAsStreamResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- continue;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PullAsStream",
+ methodName: "PullAsStreamAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PullAsStream",
+ methodName: "PullAsStreamAsync",
+ pathTemplate: "\"/api/pull\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ }
+ catch (global::System.Net.Http.HttpRequestException __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
- var __streamedResponse = global::Ollama.StatusEvent.FromJson(__content, JsonSerializerContext) ??
- throw new global::Ollama.ApiException(
- message: $"Response deserialization failed for \"{__content}\" ",
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
-
- yield return __streamedResponse;
+ using var __stream = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ using var __reader = new global::System.IO.StreamReader(__stream);
+
+ while (!__reader.EndOfStream && !__effectiveCancellationToken.IsCancellationRequested)
+ {
+ var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
+ if (global::System.String.IsNullOrWhiteSpace(__content))
+ {
+ continue;
+ }
+
+ var __streamedResponse = global::Ollama.StatusEvent.FromJson(__content, JsonSerializerContext) ??
+ throw new global::Ollama.ApiException(
+ message: $"Response deserialization failed for \"{__content}\" ",
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+
+ yield return __streamedResponse;
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -156,11 +337,13 @@ partial void ProcessPullAsStreamResponse(
///
/// Allow downloading over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Collections.Generic.IAsyncEnumerable PullAsStreamAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.PullRequest
@@ -172,6 +355,7 @@ partial void ProcessPullAsStreamResponse(
var __enumerable = PullAsStreamAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Push.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Push.g.cs
index c4357a6..f8b6354 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Push.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Push.g.cs
@@ -25,6 +25,7 @@ partial void ProcessPushResponseContent(
/// Push a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -35,6 +36,7 @@ partial void ProcessPushResponseContent(
public async global::System.Threading.Tasks.Task PushAsync(
global::Ollama.PushRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -51,126 +53,305 @@ partial void ProcessPushResponseContent(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/push",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePushRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPushResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/push",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPushResponseContent(
+ request: __httpRequest);
+ PreparePushRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest,
+ request: request);
- return
- global::Ollama.StatusResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.StatusResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Push",
+ methodName: "PushAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Push",
+ methodName: "PushAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Push",
+ methodName: "PushAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPushResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Push",
+ methodName: "PushAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Push",
+ methodName: "PushAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPushResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.StatusResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.StatusResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -182,11 +363,13 @@ partial void ProcessPushResponseContent(
///
/// Allow publishing over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task PushAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.PushRequest
@@ -198,6 +381,7 @@ partial void ProcessPushResponseContent(
return await PushAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.PushAsStream.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.PushAsStream.g.cs
index 75f18d0..633c01d 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.PushAsStream.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.PushAsStream.g.cs
@@ -20,6 +20,7 @@ partial void ProcessPushAsStreamResponse(
/// Push a model
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -30,6 +31,7 @@ partial void ProcessPushAsStreamResponse(
public async global::System.Collections.Generic.IAsyncEnumerable PushAsStreamAsync(
global::Ollama.PushRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -46,105 +48,284 @@ partial void ProcessPushAsStreamResponse(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/push",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/push",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePushAsStreamRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePushAsStreamRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPushAsStreamResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ return __httpRequest;
+ }
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
try
{
- __response.EnsureSuccessStatusCode();
- }
- catch (global::System.Net.Http.HttpRequestException __ex)
- {
- string? __content = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PushAsStream",
+ methodName: "PushAsStreamAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PushAsStream",
+ methodName: "PushAsStreamAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PushAsStream",
+ methodName: "PushAsStreamAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception)
+
+ if (__response == null)
{
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- using var __stream = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- using var __reader = new global::System.IO.StreamReader(__stream);
-
- while (!__reader.EndOfStream && !cancellationToken.IsCancellationRequested)
- {
- var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
- if (global::System.String.IsNullOrWhiteSpace(__content))
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPushAsStreamResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- continue;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PushAsStream",
+ methodName: "PushAsStreamAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PushAsStream",
+ methodName: "PushAsStreamAsync",
+ pathTemplate: "\"/api/push\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ }
+ catch (global::System.Net.Http.HttpRequestException __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
- var __streamedResponse = global::Ollama.StatusEvent.FromJson(__content, JsonSerializerContext) ??
- throw new global::Ollama.ApiException(
- message: $"Response deserialization failed for \"{__content}\" ",
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
-
- yield return __streamedResponse;
+ using var __stream = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ using var __reader = new global::System.IO.StreamReader(__stream);
+
+ while (!__reader.EndOfStream && !__effectiveCancellationToken.IsCancellationRequested)
+ {
+ var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
+ if (global::System.String.IsNullOrWhiteSpace(__content))
+ {
+ continue;
+ }
+
+ var __streamedResponse = global::Ollama.StatusEvent.FromJson(__content, JsonSerializerContext) ??
+ throw new global::Ollama.ApiException(
+ message: $"Response deserialization failed for \"{__content}\" ",
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+
+ yield return __streamedResponse;
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -156,11 +337,13 @@ partial void ProcessPushAsStreamResponse(
///
/// Allow publishing over insecure connections
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Collections.Generic.IAsyncEnumerable PushAsStreamAsync(
string model,
bool? insecure = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.PushRequest
@@ -172,6 +355,7 @@ partial void ProcessPushAsStreamResponse(
var __enumerable = PushAsStreamAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken);
await foreach (var __response in __enumerable)
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Show.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Show.g.cs
index 536fd5a..dea4d57 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Show.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Show.g.cs
@@ -25,6 +25,7 @@ partial void ProcessShowResponseContent(
/// Show model details
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
@@ -35,6 +36,7 @@ partial void ProcessShowResponseContent(
public async global::System.Threading.Tasks.Task ShowAsync(
global::Ollama.ShowRequest request,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -45,126 +47,305 @@ partial void ProcessShowResponseContent(
httpClient: HttpClient,
request: request);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/show",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareShowRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessShowResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/show",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessShowResponseContent(
+ request: __httpRequest);
+ PrepareShowRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest,
+ request: request);
- return
- global::Ollama.ShowResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.ShowResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Show",
+ methodName: "ShowAsync",
+ pathTemplate: "\"/api/show\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Show",
+ methodName: "ShowAsync",
+ pathTemplate: "\"/api/show\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Show",
+ methodName: "ShowAsync",
+ pathTemplate: "\"/api/show\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessShowResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Show",
+ methodName: "ShowAsync",
+ pathTemplate: "\"/api/show\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Show",
+ methodName: "ShowAsync",
+ pathTemplate: "\"/api/show\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessShowResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.ShowResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.ShowResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
///
@@ -176,11 +357,13 @@ partial void ProcessShowResponseContent(
///
/// If true, includes large verbose fields in the response.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ShowAsync(
string model,
bool? verbose = default,
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ollama.ShowRequest
@@ -191,6 +374,7 @@ partial void ProcessShowResponseContent(
return await ShowAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.Version.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.Version.g.cs
index 06601e1..3fdf43f 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.Version.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.Version.g.cs
@@ -23,12 +23,14 @@ partial void ProcessVersionResponseContent(
/// Get version
/// Retrieve the version of the Ollama
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
///
/// curl http://localhost:11434/api/version
///
public async global::System.Threading.Tasks.Task VersionAsync(
+ global::Ollama.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -36,119 +38,298 @@ partial void ProcessVersionResponseContent(
PrepareVersionArguments(
httpClient: HttpClient);
- var __pathBuilder = new global::Ollama.PathBuilder(
- path: "/api/version",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
-#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
-#endif
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareVersionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ using var __timeoutCancellationTokenSource = global::Ollama.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ollama.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ollama.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessVersionResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
-
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
+ var __pathBuilder = new global::Ollama.PathBuilder(
+ path: "/api/version",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ollama.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
- ).ConfigureAwait(false);
+ global::Ollama.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- ProcessResponseContent(
+ PrepareRequest(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessVersionResponseContent(
+ request: __httpRequest);
+ PrepareVersionRequest(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
- {
- __response.EnsureSuccessStatusCode();
+ httpRequestMessage: __httpRequest);
- return
- global::Ollama.VersionResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ return __httpRequest;
}
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Ollama.VersionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- string? __content = null;
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Version",
+ methodName: "VersionAsync",
+ pathTemplate: "\"/api/version\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- catch (global::System.Exception)
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Version",
+ methodName: "VersionAsync",
+ pathTemplate: "\"/api/version\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- throw new global::Ollama.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ollama.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Version",
+ methodName: "VersionAsync",
+ pathTemplate: "\"/api/version\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ollama.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessVersionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Version",
+ methodName: "VersionAsync",
+ pathTemplate: "\"/api/version\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ else
+ {
+ await global::Ollama.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ollama.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "Version",
+ methodName: "VersionAsync",
+ pathTemplate: "\"/api/version\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessVersionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ollama.VersionResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ollama.VersionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Ollama.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
}
}
}
diff --git a/src/libs/Ollama/Generated/Ollama.OllamaClient.g.cs b/src/libs/Ollama/Generated/Ollama.OllamaClient.g.cs
index f6f768d..4c246c9 100644
--- a/src/libs/Ollama/Generated/Ollama.OllamaClient.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.OllamaClient.g.cs
@@ -31,6 +31,9 @@ public sealed partial class OllamaClient : global::Ollama.IOllamaClient, global:
#if DEBUG
= true;
#endif
+
+ ///
+ public global::Ollama.AutoSDKClientOptions Options { get; }
///
///
///
@@ -50,11 +53,37 @@ public OllamaClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List? authorizations = null,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri,
+ authorizations,
+ options: null,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the OllamaClient.
+ /// If no httpClient is provided, a new one will be created.
+ /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
+ ///
+ /// The HttpClient instance. If not provided, a new one will be created.
+ /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.
+ /// The authorizations to use for the requests.
+ /// Client-wide request defaults such as headers, query parameters, retries, and timeout.
+ /// Dispose the HttpClient when the instance is disposed. True by default.
+ public OllamaClient(
+ global::System.Net.Http.HttpClient? httpClient = null,
+ global::System.Uri? baseUri = null,
+ global::System.Collections.Generic.List? authorizations = null,
+ global::Ollama.AutoSDKClientOptions? options = null,
bool disposeHttpClient = true)
{
+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List();
+ Options = options ?? new global::Ollama.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;
Initialized(HttpClient);
diff --git a/src/libs/Ollama/Generated/Ollama.OptionsSupport.g.cs b/src/libs/Ollama/Generated/Ollama.OptionsSupport.g.cs
new file mode 100644
index 0000000..356e130
--- /dev/null
+++ b/src/libs/Ollama/Generated/Ollama.OptionsSupport.g.cs
@@ -0,0 +1,462 @@
+
+#nullable enable
+
+namespace Ollama
+{
+ ///
+ /// Global defaults applied to generated SDK requests.
+ ///
+ public sealed class AutoSDKClientOptions
+ {
+ ///
+ /// Additional headers applied to every request after generated headers are set.
+ /// Entries with the same key overwrite earlier header values.
+ ///
+ public global::System.Collections.Generic.Dictionary Headers { get; } =
+ new global::System.Collections.Generic.Dictionary(global::System.StringComparer.OrdinalIgnoreCase);
+
+ ///
+ /// Additional query parameters appended to every request.
+ /// Request-level entries with the same key are appended after client defaults.
+ ///
+ public global::System.Collections.Generic.Dictionary QueryParameters { get; } =
+ new global::System.Collections.Generic.Dictionary(global::System.StringComparer.Ordinal);
+
+ ///
+ /// Optional timeout applied to the full request execution.
+ ///
+ public global::System.TimeSpan? Timeout { get; set; }
+
+ ///
+ /// Default retry behavior for generated HTTP requests.
+ ///
+ public global::Ollama.AutoSDKRetryOptions Retry { get; set; } = new global::Ollama.AutoSDKRetryOptions();
+
+ ///
+ /// Overrides the client-wide response buffering mode when set.
+ ///
+ public bool? ReadResponseAsString { get; set; }
+
+ ///
+ /// Reusable hooks invoked for every generated SDK request.
+ ///
+ public global::System.Collections.Generic.List Hooks { get; } =
+ new global::System.Collections.Generic.List();
+
+ ///
+ /// Registers a hook for all requests issued by this client.
+ ///
+ ///
+ /// The current options instance.
+ public global::Ollama.AutoSDKClientOptions AddHook(
+ global::Ollama.IAutoSDKHook hook)
+ {
+ Hooks.Add(hook ?? throw new global::System.ArgumentNullException(nameof(hook)));
+ return this;
+ }
+ }
+
+ ///
+ /// Per-request overrides applied on top of .
+ ///
+ public sealed class AutoSDKRequestOptions
+ {
+ ///
+ /// Additional headers applied after generated and client-level headers.
+ ///
+ public global::System.Collections.Generic.Dictionary Headers { get; } =
+ new global::System.Collections.Generic.Dictionary(global::System.StringComparer.OrdinalIgnoreCase);
+
+ ///
+ /// Additional query parameters appended after generated and client-level query parameters.
+ ///
+ public global::System.Collections.Generic.Dictionary QueryParameters { get; } =
+ new global::System.Collections.Generic.Dictionary(global::System.StringComparer.Ordinal);
+
+ ///
+ /// Optional timeout override for this request.
+ ///
+ public global::System.TimeSpan? Timeout { get; set; }
+
+ ///
+ /// Optional retry override for this request.
+ ///
+ public global::Ollama.AutoSDKRetryOptions? Retry { get; set; }
+
+ ///
+ /// Overrides response buffering for this request when set.
+ ///
+ public bool? ReadResponseAsString { get; set; }
+ }
+
+ ///
+ /// Retry settings for generated HTTP requests.
+ ///
+ public sealed class AutoSDKRetryOptions
+ {
+ ///
+ /// Total number of attempts, including the initial request.
+ /// Values less than 1 are normalized to 1.
+ ///
+ public int MaxAttempts { get; set; } = 1;
+
+ ///
+ /// Optional fixed delay between retry attempts.
+ ///
+ public global::System.TimeSpan? Delay { get; set; }
+ }
+
+
+ ///
+ /// Runtime hook interface for generated SDK lifecycle events.
+ ///
+ public interface IAutoSDKHook
+ {
+ ///
+ /// Runs before a request is sent.
+ ///
+ ///
+ global::System.Threading.Tasks.Task OnBeforeRequestAsync(
+ global::Ollama.AutoSDKHookContext context);
+
+ ///
+ /// Runs after a successful HTTP response is received.
+ ///
+ ///
+ global::System.Threading.Tasks.Task OnAfterSuccessAsync(
+ global::Ollama.AutoSDKHookContext context);
+
+ ///
+ /// Runs after an error response or transport failure is observed.
+ ///
+ ///
+ global::System.Threading.Tasks.Task OnAfterErrorAsync(
+ global::Ollama.AutoSDKHookContext context);
+ }
+
+ ///
+ /// Convenience base type for request hooks with no-op defaults.
+ ///
+ public abstract class AutoSDKHook : global::Ollama.IAutoSDKHook
+ {
+ ///
+ public virtual global::System.Threading.Tasks.Task OnBeforeRequestAsync(
+ global::Ollama.AutoSDKHookContext context)
+ {
+ return global::System.Threading.Tasks.Task.CompletedTask;
+ }
+
+ ///
+ public virtual global::System.Threading.Tasks.Task OnAfterSuccessAsync(
+ global::Ollama.AutoSDKHookContext context)
+ {
+ return global::System.Threading.Tasks.Task.CompletedTask;
+ }
+
+ ///
+ public virtual global::System.Threading.Tasks.Task OnAfterErrorAsync(
+ global::Ollama.AutoSDKHookContext context)
+ {
+ return global::System.Threading.Tasks.Task.CompletedTask;
+ }
+ }
+
+ ///
+ /// Runtime metadata passed to generated SDK hooks.
+ ///
+ public sealed class AutoSDKHookContext
+ {
+ ///
+ /// The source OpenAPI operation id or generated fallback id.
+ ///
+ public string OperationId { get; set; } = string.Empty;
+
+ ///
+ /// The generated C# method name.
+ ///
+ public string MethodName { get; set; } = string.Empty;
+
+ ///
+ /// The OpenAPI path template for the operation.
+ ///
+ public string PathTemplate { get; set; } = string.Empty;
+
+ ///
+ /// The HTTP method used for the request.
+ ///
+ public string HttpMethod { get; set; } = string.Empty;
+
+ ///
+ /// The client's resolved base URI.
+ ///
+ public global::System.Uri? BaseUri { get; set; }
+
+ ///
+ /// The outgoing HTTP request for the current attempt.
+ ///
+ public global::System.Net.Http.HttpRequestMessage Request { get; set; } = null!;
+
+ ///
+ /// The HTTP response when one was received.
+ ///
+ public global::System.Net.Http.HttpResponseMessage? Response { get; set; }
+
+ ///
+ /// The transport or processing exception when one was observed.
+ ///
+ public global::System.Exception? Exception { get; set; }
+
+ ///
+ /// The client-wide runtime options.
+ ///
+ public global::Ollama.AutoSDKClientOptions ClientOptions { get; set; } = null!;
+
+ ///
+ /// The per-request runtime options.
+ ///
+ public global::Ollama.AutoSDKRequestOptions? RequestOptions { get; set; }
+
+ ///
+ /// The current attempt number, starting at 1.
+ ///
+ public int Attempt { get; set; }
+
+ ///
+ /// The total number of attempts allowed for this request.
+ ///
+ public int MaxAttempts { get; set; }
+
+ ///
+ /// Indicates whether the generated client will retry after this hook invocation.
+ ///
+ public bool WillRetry { get; set; }
+
+ ///
+ /// The effective cancellation token for the current request attempt.
+ ///
+ public global::System.Threading.CancellationToken CancellationToken { get; set; }
+ }
+
+
+ internal static class AutoSDKRequestOptionsSupport
+ {
+ internal static global::Ollama.AutoSDKHookContext CreateHookContext(
+ string operationId,
+ string methodName,
+ string pathTemplate,
+ string httpMethod,
+ global::System.Uri? baseUri,
+ global::System.Net.Http.HttpRequestMessage request,
+ global::System.Net.Http.HttpResponseMessage? response,
+ global::System.Exception? exception,
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKRequestOptions? requestOptions,
+ int attempt,
+ int maxAttempts,
+ bool willRetry,
+ global::System.Threading.CancellationToken cancellationToken)
+ {
+ return new global::Ollama.AutoSDKHookContext
+ {
+ OperationId = operationId ?? string.Empty,
+ MethodName = methodName ?? string.Empty,
+ PathTemplate = pathTemplate ?? string.Empty,
+ HttpMethod = httpMethod ?? string.Empty,
+ BaseUri = baseUri,
+ Request = request,
+ Response = response,
+ Exception = exception,
+ ClientOptions = clientOptions,
+ RequestOptions = requestOptions,
+ Attempt = attempt,
+ MaxAttempts = maxAttempts,
+ WillRetry = willRetry,
+ CancellationToken = cancellationToken,
+ };
+ }
+
+ internal static global::System.Threading.Tasks.Task OnBeforeRequestAsync(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKHookContext context)
+ {
+ return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnBeforeRequestAsync(hookContext), context);
+ }
+
+ internal static global::System.Threading.Tasks.Task OnAfterSuccessAsync(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKHookContext context)
+ {
+ return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterSuccessAsync(hookContext), context);
+ }
+
+ internal static global::System.Threading.Tasks.Task OnAfterErrorAsync(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKHookContext context)
+ {
+ return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterErrorAsync(hookContext), context);
+ }
+
+ internal static bool GetReadResponseAsString(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKRequestOptions? requestOptions,
+ bool fallbackValue)
+ {
+ return requestOptions?.ReadResponseAsString ??
+ clientOptions.ReadResponseAsString ??
+ fallbackValue;
+ }
+
+ internal static global::System.Threading.CancellationTokenSource? CreateTimeoutCancellationTokenSource(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKRequestOptions? requestOptions,
+ global::System.Threading.CancellationToken cancellationToken)
+ {
+ var timeout = requestOptions?.Timeout ?? clientOptions.Timeout;
+ if (!timeout.HasValue || timeout.Value <= global::System.TimeSpan.Zero)
+ {
+ return null;
+ }
+
+ var cancellationTokenSource = global::System.Threading.CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
+ cancellationTokenSource.CancelAfter(timeout.Value);
+ return cancellationTokenSource;
+ }
+
+ internal static int GetMaxAttempts(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKRequestOptions? requestOptions,
+ bool supportsRetry)
+ {
+ if (!supportsRetry)
+ {
+ return 1;
+ }
+
+ var maxAttempts = requestOptions?.Retry?.MaxAttempts ??
+ clientOptions.Retry?.MaxAttempts ??
+ 1;
+ return maxAttempts < 1 ? 1 : maxAttempts;
+ }
+
+ internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::Ollama.AutoSDKRequestOptions? requestOptions,
+ global::System.Threading.CancellationToken cancellationToken)
+ {
+ var delay = requestOptions?.Retry?.Delay ??
+ clientOptions.Retry?.Delay;
+ if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero)
+ {
+ return;
+ }
+
+ await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false);
+ }
+
+ internal static bool ShouldRetryStatusCode(
+ global::System.Net.HttpStatusCode statusCode)
+ {
+ return (int)statusCode switch
+ {
+ 408 => true,
+ 429 => true,
+ 500 => true,
+ 502 => true,
+ 503 => true,
+ 504 => true,
+ _ => false,
+ };
+ }
+
+ internal static string AppendQueryParameters(
+ string path,
+ global::System.Collections.Generic.Dictionary clientParameters,
+ global::System.Collections.Generic.Dictionary? requestParameters)
+ {
+ var hasClientParameters = clientParameters != null && clientParameters.Count > 0;
+ var hasRequestParameters = requestParameters != null && requestParameters.Count > 0;
+ if (!hasClientParameters && !hasRequestParameters)
+ {
+ return path;
+ }
+
+ var builder = new global::System.Text.StringBuilder(path ?? string.Empty);
+ var hasQuery = builder.ToString().IndexOf("?", global::System.StringComparison.Ordinal) >= 0;
+ AppendParameters(builder, clientParameters, ref hasQuery);
+ AppendParameters(builder, requestParameters, ref hasQuery);
+ return builder.ToString();
+ }
+
+ internal static void ApplyHeaders(
+ global::System.Net.Http.HttpRequestMessage request,
+ global::System.Collections.Generic.Dictionary clientHeaders,
+ global::System.Collections.Generic.Dictionary? requestHeaders)
+ {
+ ApplyHeadersCore(request, clientHeaders);
+ ApplyHeadersCore(request, requestHeaders);
+ }
+
+ private static void AppendParameters(
+ global::System.Text.StringBuilder builder,
+ global::System.Collections.Generic.Dictionary? parameters,
+ ref bool hasQuery)
+ {
+ if (parameters == null || parameters.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var parameter in parameters)
+ {
+ builder.Append(hasQuery ? '&' : '?');
+ builder.Append(global::System.Uri.EscapeDataString(parameter.Key));
+ builder.Append('=');
+ builder.Append(global::System.Uri.EscapeDataString(parameter.Value ?? string.Empty));
+ hasQuery = true;
+ }
+ }
+
+ private static void ApplyHeadersCore(
+ global::System.Net.Http.HttpRequestMessage request,
+ global::System.Collections.Generic.Dictionary? headers)
+ {
+ if (headers == null || headers.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var header in headers)
+ {
+ request.Headers.Remove(header.Key);
+ request.Content?.Headers.Remove(header.Key);
+
+ if (!request.Headers.TryAddWithoutValidation(header.Key, header.Value ?? string.Empty) &&
+ request.Content != null)
+ {
+ request.Content.Headers.TryAddWithoutValidation(header.Key, header.Value ?? string.Empty);
+ }
+ }
+ }
+
+ private static async global::System.Threading.Tasks.Task InvokeHooksAsync(
+ global::Ollama.AutoSDKClientOptions clientOptions,
+ global::System.Func callback,
+ global::Ollama.AutoSDKHookContext context)
+ {
+ if (clientOptions.Hooks == null || clientOptions.Hooks.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var hook in clientOptions.Hooks)
+ {
+ if (hook == null)
+ {
+ continue;
+ }
+
+ await callback(hook, context).ConfigureAwait(false);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libs/Ollama/Generated/Ollama.PathBuilder.g.cs b/src/libs/Ollama/Generated/Ollama.PathBuilder.g.cs
index 8e50b21..1cad558 100644
--- a/src/libs/Ollama/Generated/Ollama.PathBuilder.g.cs
+++ b/src/libs/Ollama/Generated/Ollama.PathBuilder.g.cs
@@ -275,6 +275,11 @@ public class EndPointAuthorization
///
public string Type { get; set; } = string.Empty;
+ ///
+ ///
+ ///
+ public string SchemeId { get; set; } = string.Empty;
+
///
///
///
diff --git a/src/libs/Ollama/Generated/autosdk.generated-examples.json b/src/libs/Ollama/Generated/autosdk.generated-examples.json
new file mode 100644
index 0000000..d9cb0e7
--- /dev/null
+++ b/src/libs/Ollama/Generated/autosdk.generated-examples.json
@@ -0,0 +1,136 @@
+{
+ "Examples": [
+ {
+ "Order": 1,
+ "Title": "Generate a chat message",
+ "Slug": "chat",
+ "Description": "Generate the next chat message in a conversation between a user and an assistant.",
+ "Language": "http",
+ "Code": "### Generate a chat message\n# @name chat\nPOST {{host}}/api/chat\nContent-Type: application/json\nAccept: application/json, application/x-ndjson\n\n{\n \u0022model\u0022: \u0022string\u0022,\n \u0022messages\u0022: [\n {\n \u0022role\u0022: \u0022system\u0022,\n \u0022content\u0022: \u0022string\u0022,\n \u0022images\u0022: [],\n \u0022tool_calls\u0022: []\n }\n ],\n \u0022tools\u0022: [\n {\n \u0022type\u0022: \u0022function\u0022,\n \u0022function\u0022: {}\n }\n ],\n \u0022format\u0022: \u0022json\u0022,\n \u0022options\u0022: {\n \u0022seed\u0022: 0,\n \u0022temperature\u0022: 0,\n \u0022top_k\u0022: 0,\n \u0022top_p\u0022: 0,\n \u0022min_p\u0022: 0,\n \u0022stop\u0022: \u0022string\u0022,\n \u0022num_ctx\u0022: 0,\n \u0022num_predict\u0022: 0\n },\n \u0022stream\u0022: true,\n \u0022think\u0022: true,\n \u0022keep_alive\u0022: \u0022string\u0022,\n \u0022logprobs\u0022: true,\n \u0022top_logprobs\u0022: 0\n}\n\n## Responses\n# 200\n# Description: Chat response\n# Content-Type: application/json, application/x-ndjson",
+ "Format": "http",
+ "OperationId": "chat",
+ "Setup": null
+ },
+ {
+ "Order": 2,
+ "Title": "Copy a model",
+ "Slug": "copy",
+ "Description": "Generated from OpenAPI examples.",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.CopyRequest\u003E(\n @\u0022{\n \u0022\u0022source\u0022\u0022: \u0022\u0022gemma3\u0022\u0022,\n \u0022\u0022destination\u0022\u0022: \u0022\u0022gemma3-backup\u0022\u0022\n}\u0022)!;\n\nawait client.CopyAsync(\n request: request\n);",
+ "Format": "sdk",
+ "OperationId": "copy",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 3,
+ "Title": "Create a model",
+ "Slug": "create",
+ "Description": "Generated from OpenAPI examples.",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.CreateRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022mario\u0022\u0022,\n \u0022\u0022from\u0022\u0022: \u0022\u0022gemma3\u0022\u0022,\n \u0022\u0022system\u0022\u0022: \u0022\u0022You are Mario from Super Mario Bros.\u0022\u0022\n}\u0022)!;\n\nvar response = await client.CreateAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022status\u0022: \u0022success\u0022\n// }",
+ "Format": "sdk",
+ "OperationId": "create",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 4,
+ "Title": "Delete a model",
+ "Slug": "delete",
+ "Description": "Generated from OpenAPI examples.",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.DeleteRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022gemma3\u0022\u0022\n}\u0022)!;\n\nawait client.DeleteAsync(\n request: request\n);",
+ "Format": "sdk",
+ "OperationId": "delete",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 5,
+ "Title": "Generate embeddings",
+ "Slug": "embed",
+ "Description": "Creates vector embeddings representing the input text",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.EmbedRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022embeddinggemma\u0022\u0022,\n \u0022\u0022input\u0022\u0022: \u0022\u0022Generate embeddings for this text\u0022\u0022\n}\u0022)!;\n\nvar response = await client.EmbedAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022model\u0022: \u0022embeddinggemma\u0022,\n// \u0022embeddings\u0022: [\n// [\n// 0.010071029,\n// -0.0017594862,\n// 0.05007221,\n// 0.04692972,\n// 0.054916814,\n// 0.008599704,\n// 0.105441414,\n// -0.025878139,\n// 0.12958129,\n// 0.031952348\n// ]\n// ],\n// \u0022total_duration\u0022: 14143917,\n// \u0022load_duration\u0022: 1019500,\n// \u0022prompt_eval_count\u0022: 8\n// }",
+ "Format": "sdk",
+ "OperationId": "embed",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 6,
+ "Title": "Generate a response",
+ "Slug": "generate",
+ "Description": "Generates a response for the provided prompt",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.GenerateRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022gemma3\u0022\u0022,\n \u0022\u0022prompt\u0022\u0022: \u0022\u0022Why is the sky blue?\u0022\u0022\n}\u0022)!;\n\nvar response = await client.GenerateAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022model\u0022: \u0022gemma3\u0022,\n// \u0022created_at\u0022: \u00222025-10-17T23:14:07.414671Z\u0022,\n// \u0022response\u0022: \u0022Hello! How can I help you today?\u0022,\n// \u0022done\u0022: true,\n// \u0022done_reason\u0022: \u0022stop\u0022,\n// \u0022total_duration\u0022: 174560334,\n// \u0022load_duration\u0022: 101397084,\n// \u0022prompt_eval_count\u0022: 11,\n// \u0022prompt_eval_duration\u0022: 13074791,\n// \u0022eval_count\u0022: 18,\n// \u0022eval_duration\u0022: 52479709\n// }",
+ "Format": "sdk",
+ "OperationId": "generate",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 7,
+ "Title": "List models",
+ "Slug": "list",
+ "Description": "Fetch a list of models and their details",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\nvar response = await client.ListAsync();\n\n// Example response:\n// {\n// \u0022models\u0022: [\n// {\n// \u0022name\u0022: \u0022gemma3\u0022,\n// \u0022model\u0022: \u0022gemma3\u0022,\n// \u0022modified_at\u0022: \u00222025-10-03T23:34:03.409490317-07:00\u0022,\n// \u0022size\u0022: 3338801804,\n// \u0022digest\u0022: \u0022a2af6cc3eb7fa8be8504abaf9b04e88f17a119ec3f04a3addf55f92841195f5a\u0022,\n// \u0022details\u0022: {\n// \u0022format\u0022: \u0022gguf\u0022,\n// \u0022family\u0022: \u0022gemma\u0022,\n// \u0022families\u0022: [\n// \u0022gemma\u0022\n// ],\n// \u0022parameter_size\u0022: \u00224.3B\u0022,\n// \u0022quantization_level\u0022: \u0022Q4_K_M\u0022\n// }\n// }\n// ]\n// }",
+ "Format": "sdk",
+ "OperationId": "list",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 8,
+ "Title": "List running models",
+ "Slug": "ps",
+ "Description": "Retrieve a list of models that are currently running",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\nvar response = await client.PsAsync();\n\n// Example response:\n// {\n// \u0022models\u0022: [\n// {\n// \u0022name\u0022: \u0022gemma3\u0022,\n// \u0022model\u0022: \u0022gemma3\u0022,\n// \u0022size\u0022: 6591830464,\n// \u0022digest\u0022: \u0022a2af6cc3eb7fa8be8504abaf9b04e88f17a119ec3f04a3addf55f92841195f5a\u0022,\n// \u0022details\u0022: {\n// \u0022parent_model\u0022: \u0022\u0022,\n// \u0022format\u0022: \u0022gguf\u0022,\n// \u0022family\u0022: \u0022gemma3\u0022,\n// \u0022families\u0022: [\n// \u0022gemma3\u0022\n// ],\n// \u0022parameter_size\u0022: \u00224.3B\u0022,\n// \u0022quantization_level\u0022: \u0022Q4_K_M\u0022\n// },\n// \u0022expires_at\u0022: \u00222025-10-17T16:47:07.93355-07:00\u0022,\n// \u0022size_vram\u0022: 5333539264,\n// \u0022context_length\u0022: 4096\n// }\n// ]\n// }",
+ "Format": "sdk",
+ "OperationId": "ps",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 9,
+ "Title": "Pull a model",
+ "Slug": "pull",
+ "Description": "Generated from OpenAPI examples.",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.PullRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022gemma3\u0022\u0022\n}\u0022)!;\n\nvar response = await client.PullAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022status\u0022: \u0022success\u0022\n// }",
+ "Format": "sdk",
+ "OperationId": "pull",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 10,
+ "Title": "Push a model",
+ "Slug": "push",
+ "Description": "Generated from OpenAPI examples.",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.PushRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022my-username/my-model\u0022\u0022\n}\u0022)!;\n\nvar response = await client.PushAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022status\u0022: \u0022success\u0022\n// }",
+ "Format": "sdk",
+ "OperationId": "push",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 11,
+ "Title": "Show model details",
+ "Slug": "show",
+ "Description": "Generated from OpenAPI examples.",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ollama.ShowRequest\u003E(\n @\u0022{\n \u0022\u0022model\u0022\u0022: \u0022\u0022gemma3\u0022\u0022\n}\u0022)!;\n\nvar response = await client.ShowAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022parameters\u0022: \u0022temperature 0.7\\nnum_ctx 2048\u0022,\n// \u0022license\u0022: \u0022Gemma Terms of Use \\n\\nLast modified: February 21, 2024...\u0022,\n// \u0022capabilities\u0022: [\n// \u0022completion\u0022,\n// \u0022vision\u0022\n// ],\n// \u0022modified_at\u0022: \u00222025-08-14T15:49:43.634137516-07:00\u0022,\n// \u0022details\u0022: {\n// \u0022parent_model\u0022: \u0022\u0022,\n// \u0022format\u0022: \u0022gguf\u0022,\n// \u0022family\u0022: \u0022gemma3\u0022,\n// \u0022families\u0022: [\n// \u0022gemma3\u0022\n// ],\n// \u0022parameter_size\u0022: \u00224.3B\u0022,\n// \u0022quantization_level\u0022: \u0022Q4_K_M\u0022\n// },\n// \u0022model_info\u0022: {\n// \u0022gemma3.attention.head_count\u0022: 8,\n// \u0022gemma3.attention.head_count_kv\u0022: 4,\n// \u0022gemma3.attention.key_length\u0022: 256,\n// \u0022gemma3.attention.sliding_window\u0022: 1024,\n// \u0022gemma3.attention.value_length\u0022: 256,\n// \u0022gemma3.block_count\u0022: 34,\n// \u0022gemma3.context_length\u0022: 131072,\n// \u0022gemma3.embedding_length\u0022: 2560,\n// \u0022gemma3.feed_forward_length\u0022: 10240,\n// \u0022gemma3.mm.tokens_per_image\u0022: 256,\n// \u0022gemma3.vision.attention.head_count\u0022: 16,\n// \u0022gemma3.vision.attention.layer_norm_epsilon\u0022: 0.000001,\n// \u0022gemma3.vision.block_count\u0022: 27,\n// \u0022gemma3.vision.embedding_length\u0022: 1152,\n// \u0022gemma3.vision.feed_forward_length\u0022: 4304,\n// \u0022gemma3.vision.image_size\u0022: 896,\n// \u0022gemma3.vision.num_channels\u0022: 3,\n// \u0022gemma3.vision.patch_size\u0022: 14,\n// \u0022general.architecture\u0022: \u0022gemma3\u0022,\n// \u0022general.file_type\u0022: 15,\n// \u0022general.parameter_count\u0022: 4299915632,\n// \u0022general.quantization_version\u0022: 2,\n// \u0022tokenizer.ggml.add_bos_token\u0022: true,\n// \u0022tokenizer.ggml.add_eos_token\u0022: false,\n// \u0022tokenizer.ggml.add_padding_token\u0022: false,\n// \u0022tokenizer.ggml.add_unknown_token\u0022: false,\n// \u0022tokenizer.ggml.bos_token_id\u0022: 2,\n// \u0022tokenizer.ggml.eos_token_id\u0022: 1,\n// \u0022tokenizer.ggml.merges\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n// \u0022tokenizer.ggml.model\u0022: \u0022llama\u0022,\n// \u0022tokenizer.ggml.padding_token_id\u0022: 0,\n// \u0022tokenizer.ggml.pre\u0022: \u0022default\u0022,\n// \u0022tokenizer.ggml.scores\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n// \u0022tokenizer.ggml.token_type\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n// \u0022tokenizer.ggml.tokens\u0022: \u0022openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464\u0022,\n// \u0022tokenizer.ggml.unknown_token_id\u0022: 3\n// }\n// }",
+ "Format": "sdk",
+ "OperationId": "show",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ },
+ {
+ "Order": 12,
+ "Title": "Get version",
+ "Slug": "version",
+ "Description": "Retrieve the version of the Ollama",
+ "Language": "csharp",
+ "Code": "using var client = new OllamaClient();\nvar response = await client.VersionAsync();\n\n// Example response:\n// {\n// \u0022version\u0022: \u00220.12.6\u0022\n// }",
+ "Format": "sdk",
+ "OperationId": "version",
+ "Setup": "This example assumes \u0060using Ollama;\u0060 is in scope."
+ }
+ ]
+}
\ No newline at end of file