-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update openapi specification [merge date may 2] (box/box-openap…
- Loading branch information
1 parent
9ca1b99
commit fcf8c8e
Showing
21 changed files
with
415 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{ "engineHash": "afd7974", "specHash": "1698c95", "version": "0.3.0" } | ||
{ "engineHash": "afd7974", "specHash": "63d1af0", "version": "0.3.0" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Unions; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using DictionaryExtensions; | ||
using Serializer; | ||
using Fetch; | ||
using Box.Sdk.Gen.Schemas; | ||
using Box.Sdk.Gen; | ||
|
||
namespace Box.Sdk.Gen.Managers { | ||
public class AiManager : IAiManager { | ||
public IAuthentication? Auth { get; set; } = default; | ||
|
||
public NetworkSession NetworkSession { get; set; } | ||
|
||
public AiManager(NetworkSession networkSession = default) { | ||
NetworkSession = networkSession ?? new NetworkSession(); | ||
} | ||
/// <summary> | ||
/// Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context. | ||
/// </summary> | ||
/// <param name="requestBody"> | ||
/// Request body of createAiAsk method | ||
/// </param> | ||
/// <param name="headers"> | ||
/// Headers of createAiAsk method | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// Token used for request cancellation. | ||
/// </param> | ||
public async System.Threading.Tasks.Task<AiResponse> CreateAiAskAsync(AiAsk requestBody, CreateAiAskHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) { | ||
headers = headers ?? new CreateAiAskHeaders(); | ||
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { }, headers.ExtraHeaders)); | ||
FetchResponse response = await HttpClientAdapter.FetchAsync(string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/v2/ai/ask"), new FetchOptions(method: "POST", headers: headersMap, data: SimpleJsonSerializer.Serialize(requestBody), contentType: "application/json", responseFormat: "json", auth: this.Auth, networkSession: this.NetworkSession, cancellationToken: cancellationToken)).ConfigureAwait(false); | ||
return SimpleJsonSerializer.Deserialize<AiResponse>(response.Data); | ||
} | ||
|
||
/// <summary> | ||
/// Sends an AI request to supported LLMs and returns an answer specifically focused on the creation of new text. | ||
/// </summary> | ||
/// <param name="requestBody"> | ||
/// Request body of createAiTextGen method | ||
/// </param> | ||
/// <param name="headers"> | ||
/// Headers of createAiTextGen method | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// Token used for request cancellation. | ||
/// </param> | ||
public async System.Threading.Tasks.Task<AiResponse> CreateAiTextGenAsync(AiTextGen requestBody, CreateAiTextGenHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) { | ||
headers = headers ?? new CreateAiTextGenHeaders(); | ||
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { }, headers.ExtraHeaders)); | ||
FetchResponse response = await HttpClientAdapter.FetchAsync(string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/v2/ai/text_gen"), new FetchOptions(method: "POST", headers: headersMap, data: SimpleJsonSerializer.Serialize(requestBody), contentType: "application/json", responseFormat: "json", auth: this.Auth, networkSession: this.NetworkSession, cancellationToken: cancellationToken)).ConfigureAwait(false); | ||
return SimpleJsonSerializer.Deserialize<AiResponse>(response.Data); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Unions; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using Box.Sdk.Gen.Schemas; | ||
using Box.Sdk.Gen; | ||
|
||
namespace Box.Sdk.Gen.Managers { | ||
public class CreateAiAskHeaders { | ||
/// <summary> | ||
/// Extra headers that will be included in the HTTP request. | ||
/// </summary> | ||
public Dictionary<string, string?> ExtraHeaders { get; set; } | ||
|
||
public CreateAiAskHeaders(Dictionary<string, string?> extraHeaders = default) { | ||
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Unions; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using Box.Sdk.Gen.Schemas; | ||
using Box.Sdk.Gen; | ||
|
||
namespace Box.Sdk.Gen.Managers { | ||
public class CreateAiTextGenHeaders { | ||
/// <summary> | ||
/// Extra headers that will be included in the HTTP request. | ||
/// </summary> | ||
public Dictionary<string, string?> ExtraHeaders { get; set; } | ||
|
||
public CreateAiTextGenHeaders(Dictionary<string, string?> extraHeaders = default) { | ||
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Unions; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using Box.Sdk.Gen.Schemas; | ||
using Box.Sdk.Gen; | ||
|
||
namespace Box.Sdk.Gen.Managers { | ||
public interface IAiManager { | ||
public IAuthentication? Auth { get; set; } | ||
|
||
public NetworkSession NetworkSession { get; set; } | ||
|
||
public System.Threading.Tasks.Task<AiResponse> CreateAiAskAsync(AiAsk requestBody, CreateAiAskHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null); | ||
|
||
public System.Threading.Tasks.Task<AiResponse> CreateAiTextGenAsync(AiTextGen requestBody, CreateAiTextGenHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Unions; | ||
using System.Text.Json.Serialization; | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Generic; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
public class AiAsk { | ||
/// <summary> | ||
/// The mode specifies if this request is for a single or multiple items. | ||
/// </summary> | ||
[JsonPropertyName("mode")] | ||
public AiAskModeField Mode { get; set; } | ||
|
||
/// <summary> | ||
/// The prompt provided by the client to be answered by the LLM. | ||
/// </summary> | ||
[JsonPropertyName("prompt")] | ||
public string Prompt { get; set; } | ||
|
||
/// <summary> | ||
/// The items to be processed by the LLM, often files. | ||
/// </summary> | ||
[JsonPropertyName("items")] | ||
public IReadOnlyList<AiAskItemsField> Items { get; set; } | ||
|
||
public AiAsk(AiAskModeField mode, string prompt, IReadOnlyList<AiAskItemsField> items) { | ||
Mode = mode; | ||
Prompt = prompt; | ||
Items = items; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Unions; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
public class AiAskItemsField { | ||
/// <summary> | ||
/// The id of the item | ||
/// </summary> | ||
[JsonPropertyName("id")] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// The type of the item | ||
/// </summary> | ||
[JsonPropertyName("type")] | ||
public AiAskItemsTypeField Type { get; set; } | ||
|
||
/// <summary> | ||
/// The content of the item, often the text representation. | ||
/// </summary> | ||
[JsonPropertyName("content")] | ||
public string? Content { get; set; } = default; | ||
|
||
public AiAskItemsField(string id, AiAskItemsTypeField type = AiAskItemsTypeField.File) { | ||
Id = id; | ||
Type = type; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.ComponentModel; | ||
using Serializer; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
[JsonConverter(typeof(StringEnumConverter<AiAskItemsTypeField>))] | ||
public enum AiAskItemsTypeField { | ||
[Description("file")] | ||
File | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.ComponentModel; | ||
using Serializer; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
[JsonConverter(typeof(StringEnumConverter<AiAskModeField>))] | ||
public enum AiAskModeField { | ||
[Description("multiple_item_qa")] | ||
MultipleItemQa, | ||
[Description("single_item_qa")] | ||
SingleItemQa | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Unions; | ||
using System.Text.Json.Serialization; | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Generic; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
public class AiResponse { | ||
/// <summary> | ||
/// The answer provided by the LLM. | ||
/// </summary> | ||
[JsonPropertyName("answer")] | ||
public string Answer { get; set; } | ||
|
||
/// <summary> | ||
/// The ISO date formatted timestamp of when the answer to the prompt was created. | ||
/// </summary> | ||
[JsonPropertyName("created_at")] | ||
public System.DateTimeOffset CreatedAt { get; set; } | ||
|
||
/// <summary> | ||
/// The reason the response finishes. | ||
/// </summary> | ||
[JsonPropertyName("completion_reason")] | ||
public string? CompletionReason { get; set; } = default; | ||
|
||
public AiResponse(string answer, System.DateTimeOffset createdAt) { | ||
Answer = answer; | ||
CreatedAt = createdAt; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Unions; | ||
using System.Text.Json.Serialization; | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Generic; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
public class AiTextGen { | ||
/// <summary> | ||
/// The prompt provided by the client to be answered by the LLM. | ||
/// </summary> | ||
[JsonPropertyName("prompt")] | ||
public string Prompt { get; set; } | ||
|
||
/// <summary> | ||
/// The items to be processed by the LLM, often files. | ||
/// </summary> | ||
[JsonPropertyName("items")] | ||
public IReadOnlyList<AiTextGenItemsField> Items { get; set; } | ||
|
||
/// <summary> | ||
/// The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response. | ||
/// </summary> | ||
[JsonPropertyName("dialogue_history")] | ||
public IReadOnlyList<AiTextGenDialogueHistoryField>? DialogueHistory { get; set; } = default; | ||
|
||
public AiTextGen(string prompt, IReadOnlyList<AiTextGenItemsField> items) { | ||
Prompt = prompt; | ||
Items = items; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Unions; | ||
using System.Text.Json.Serialization; | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Generic; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
public class AiTextGenDialogueHistoryField { | ||
/// <summary> | ||
/// The prompt previously provided by the client and answered by the LLM. | ||
/// </summary> | ||
[JsonPropertyName("prompt")] | ||
public string? Prompt { get; set; } = default; | ||
|
||
/// <summary> | ||
/// The answer previously provided by the LLM. | ||
/// </summary> | ||
[JsonPropertyName("answer")] | ||
public string? Answer { get; set; } = default; | ||
|
||
/// <summary> | ||
/// The ISO date formatted timestamp of when the previous answer to the prompt was created. | ||
/// </summary> | ||
[JsonPropertyName("created_at")] | ||
public System.DateTimeOffset? CreatedAt { get; set; } = default; | ||
|
||
public AiTextGenDialogueHistoryField() { | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Unions; | ||
using System.Text.Json.Serialization; | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Generic; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
public class AiTextGenItemsField { | ||
/// <summary> | ||
/// The id of the item. | ||
/// </summary> | ||
[JsonPropertyName("id")] | ||
public string? Id { get; set; } = default; | ||
|
||
/// <summary> | ||
/// The type of the item. | ||
/// </summary> | ||
[JsonPropertyName("type")] | ||
public AiTextGenItemsTypeField? Type { get; set; } = default; | ||
|
||
/// <summary> | ||
/// The content to use as context for generating new text or editing existing text. | ||
/// </summary> | ||
[JsonPropertyName("content")] | ||
public string? Content { get; set; } = default; | ||
|
||
public AiTextGenItemsField() { | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.ComponentModel; | ||
using Serializer; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Box.Sdk.Gen.Schemas { | ||
[JsonConverter(typeof(StringEnumConverter<AiTextGenItemsTypeField>))] | ||
public enum AiTextGenItemsTypeField { | ||
[Description("file")] | ||
File | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.