Skip to content

Commit

Permalink
Merge pull request #62 from tryAGI/bot/update-openapi_202410230147
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 23, 2024
2 parents b90f256 + d16e220 commit 81b9f17
Show file tree
Hide file tree
Showing 24 changed files with 504 additions and 359 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,47 @@ partial void ProcessGenerateChatCompletionResponse(
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
client: HttpClient);
PrepareGenerateChatCompletionArguments(
httpClient: _httpClient,
httpClient: HttpClient,
request: request);

var __pathBuilder = new PathBuilder(
path: "/chat",
baseUri: _httpClient.BaseAddress);
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
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));
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;
__httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: _httpClient,
request: httpRequest);
client: HttpClient,
request: __httpRequest);
PrepareGenerateChatCompletionRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
request: request);

using var response = await _httpClient.SendAsync(
request: httpRequest,
using var __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
client: HttpClient,
response: __response);
ProcessGenerateChatCompletionResponse(
httpClient: _httpClient,
httpResponseMessage: response);
response.EnsureSuccessStatusCode();
httpClient: HttpClient,
httpResponseMessage: __response);
__response.EnsureSuccessStatusCode();

using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var stream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var reader = new global::System.IO.StreamReader(stream);

while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
Expand Down Expand Up @@ -129,7 +129,7 @@ partial void ProcessGenerateChatCompletionResponse(
global::System.Collections.Generic.IList<global::Ollama.Tool>? tools = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var request = new global::Ollama.GenerateChatCompletionRequest
var __request = new global::Ollama.GenerateChatCompletionRequest
{
Model = model,
Messages = messages,
Expand All @@ -140,13 +140,13 @@ partial void ProcessGenerateChatCompletionResponse(
Tools = tools,
};

var enumerable = GenerateChatCompletionAsync(
request: request,
var __enumerable = GenerateChatCompletionAsync(
request: __request,
cancellationToken: cancellationToken);

await foreach (var response in enumerable)
await foreach (var __response in __enumerable)
{
yield return response;
yield return __response;
}
}
}
Expand Down
38 changes: 26 additions & 12 deletions src/libs/Ollama/Generated/Ollama.ChatClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ public sealed partial class ChatClient : global::Ollama.IChatClient, global::Sys
/// <summary>
/// Ollama server URL
/// </summary>
public const string BaseUrl = "http://localhost:11434/api";
public const string DefaultBaseUrl = "http://localhost:11434/api";

private readonly global::System.Net.Http.HttpClient _httpClient;
private global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization> _authorizations;
private bool _disposeHttpClient = true;

/// <inheritdoc/>
public global::System.Net.Http.HttpClient HttpClient { get; }

/// <inheritdoc/>
public System.Uri? BaseUri => HttpClient.BaseAddress;

/// <inheritdoc/>
public global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization> Authorizations { get; }

/// <summary>
///
Expand All @@ -29,25 +37,31 @@ public sealed partial class ChatClient : global::Ollama.IChatClient, global::Sys
/// 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.
/// </summary>
/// <param name="httpClient"></param>
/// <param name="baseUri"></param>
/// <param name="authorizations"></param>
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
/// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
/// <param name="authorizations">The authorizations to use for the requests.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public ChatClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>? authorizations = null)
global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>? authorizations = null,
bool disposeHttpClient = true)
{
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_authorizations = authorizations ?? new global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>();
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>();
_disposeHttpClient = disposeHttpClient;

Initialized(_httpClient);
Initialized(HttpClient);
}

/// <inheritdoc/>
public void Dispose()
{
_httpClient.Dispose();
if (_disposeHttpClient)
{
HttpClient.Dispose();
}
}

partial void Initialized(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,47 @@ partial void ProcessGenerateCompletionResponse(
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
client: HttpClient);
PrepareGenerateCompletionArguments(
httpClient: _httpClient,
httpClient: HttpClient,
request: request);

var __pathBuilder = new PathBuilder(
path: "/generate",
baseUri: _httpClient.BaseAddress);
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
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));
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;
__httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: _httpClient,
request: httpRequest);
client: HttpClient,
request: __httpRequest);
PrepareGenerateCompletionRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
request: request);

using var response = await _httpClient.SendAsync(
request: httpRequest,
using var __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
client: HttpClient,
response: __response);
ProcessGenerateCompletionResponse(
httpClient: _httpClient,
httpResponseMessage: response);
response.EnsureSuccessStatusCode();
httpClient: HttpClient,
httpResponseMessage: __response);
__response.EnsureSuccessStatusCode();

using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var stream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var reader = new global::System.IO.StreamReader(stream);

while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
Expand Down Expand Up @@ -151,7 +151,7 @@ partial void ProcessGenerateCompletionResponse(
int? keepAlive = default,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
{
var request = new global::Ollama.GenerateCompletionRequest
var __request = new global::Ollama.GenerateCompletionRequest
{
Model = model,
Prompt = prompt,
Expand All @@ -167,13 +167,13 @@ partial void ProcessGenerateCompletionResponse(
KeepAlive = keepAlive,
};

var enumerable = GenerateCompletionAsync(
request: request,
var __enumerable = GenerateCompletionAsync(
request: __request,
cancellationToken: cancellationToken);

await foreach (var response in enumerable)
await foreach (var __response in __enumerable)
{
yield return response;
yield return __response;
}
}
}
Expand Down
38 changes: 26 additions & 12 deletions src/libs/Ollama/Generated/Ollama.CompletionsClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ public sealed partial class CompletionsClient : global::Ollama.ICompletionsClien
/// <summary>
/// Ollama server URL
/// </summary>
public const string BaseUrl = "http://localhost:11434/api";
public const string DefaultBaseUrl = "http://localhost:11434/api";

private readonly global::System.Net.Http.HttpClient _httpClient;
private global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization> _authorizations;
private bool _disposeHttpClient = true;

/// <inheritdoc/>
public global::System.Net.Http.HttpClient HttpClient { get; }

/// <inheritdoc/>
public System.Uri? BaseUri => HttpClient.BaseAddress;

/// <inheritdoc/>
public global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization> Authorizations { get; }

/// <summary>
///
Expand All @@ -29,25 +37,31 @@ public sealed partial class CompletionsClient : global::Ollama.ICompletionsClien
/// 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.
/// </summary>
/// <param name="httpClient"></param>
/// <param name="baseUri"></param>
/// <param name="authorizations"></param>
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
/// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
/// <param name="authorizations">The authorizations to use for the requests.</param>
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
public CompletionsClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>? authorizations = null)
global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>? authorizations = null,
bool disposeHttpClient = true)
{
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_authorizations = authorizations ?? new global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>();
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization>();
_disposeHttpClient = disposeHttpClient;

Initialized(_httpClient);
Initialized(HttpClient);
}

/// <inheritdoc/>
public void Dispose()
{
_httpClient.Dispose();
if (_disposeHttpClient)
{
HttpClient.Dispose();
}
}

partial void Initialized(
Expand Down
Loading

0 comments on commit 81b9f17

Please sign in to comment.