-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from JerrettDavis/code-cleanup
Documentation Updates and Code Cleanup
- Loading branch information
Showing
16 changed files
with
666 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace OllamaSharp; | ||
|
||
/// <summary> | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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,67 @@ | ||
namespace OllamaSharp; | ||
|
||
/// <summary> | ||
/// Provides extension methods for working with collections. | ||
/// </summary> | ||
internal static class CollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the elements of the specified collection to the end of the list if the collection is not <c>null</c>. | ||
/// </summary> | ||
/// <typeparam name="T">The type of elements in the list and collection.</typeparam> | ||
/// <param name="list">The list to which the elements should be added.</param> | ||
/// <param name="items"> | ||
/// The collection whose elements should be added to the list. | ||
/// If <c>null</c>, no operations are performed. | ||
/// </param> | ||
/// <example> | ||
/// Example usage: | ||
/// <code> | ||
/// List<int> myList = new List<int> { 1, 2, 3 }; | ||
/// IEnumerable<int>? additionalItems = new List<int> { 4, 5, 6 }; | ||
/// myList.AddRangeIfNotNull(additionalItems); | ||
/// // myList now contains { 1, 2, 3, 4, 5, 6 } | ||
/// IEnumerable<int>? nullItems = null; | ||
/// myList.AddRangeIfNotNull(nullItems); | ||
/// // myList remains unchanged { 1, 2, 3, 4, 5, 6 } | ||
/// </code> | ||
/// </example> | ||
public static void AddRangeIfNotNull<T>(this List<T> list, IEnumerable<T>? items) | ||
{ | ||
if (items is not null) | ||
list.AddRange(items); | ||
} | ||
|
||
/// <summary> | ||
/// Executes the specified action for each item in the provided collection. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the elements in the collection.</typeparam> | ||
/// <param name="collection"> | ||
/// The enumerable collection whose elements the action will be performed upon. | ||
/// </param> | ||
/// <param name="action"> | ||
/// An <see cref="Action{T}"/> delegate to perform on each element of the collection. | ||
/// </param> | ||
/// <example> | ||
/// Example usage: | ||
/// <code> | ||
/// List<string> fruits = new List<string> { "apple", "banana", "cherry" }; | ||
/// fruits.ForEachItem(fruit => Console.WriteLine(fruit)); | ||
/// // Output: | ||
/// // apple | ||
/// // banana | ||
/// // cherry | ||
/// IEnumerable<int> numbers = new List<int> { 1, 2, 3 }; | ||
/// numbers.ForEachItem(number => Console.WriteLine(number * 2)); | ||
/// // Output: | ||
/// // 2 | ||
/// // 4 | ||
/// // 6 | ||
/// </code> | ||
/// </example> | ||
public static void ForEachItem<T>(this IEnumerable<T> collection, Action<T> action) | ||
{ | ||
foreach (var item in collection) | ||
action(item); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace OllamaSharp.Constants; | ||
|
||
/// <summary> | ||
/// Contains constant values used throughout the application. | ||
/// </summary> | ||
internal static class Application | ||
{ | ||
public const string Ollama = "ollama"; | ||
public const string KeepAlive = "keep_alive"; | ||
public const string Truncate = "truncate"; | ||
public const string LoadDuration = "load_duration"; | ||
public const string TotalDuration = "total_duration"; | ||
public const string PromptEvalDuration = "prompt_eval_duration"; | ||
public const string PromptEvalCount = "prompt_eval_count"; | ||
public const string EvalDuration = "eval_duration"; | ||
public const string EvalCount = "eval_count"; | ||
public const string Context = "context"; | ||
public const string Done = "done"; | ||
public const string Response = "response"; | ||
public const string CreatedAt = "created_at"; | ||
public const string Model = "model"; | ||
|
||
public const string Assistant = "assistant"; | ||
public const string System = "system"; | ||
public const string User = "user"; | ||
public const string Tool = "tool"; | ||
|
||
public const string Length = "length"; | ||
public const string Stop = "stop"; | ||
|
||
public const string Object = "object"; | ||
public const string Function = "function"; | ||
|
||
public const string Json = "json"; | ||
|
||
public const string NotApplicable = "n/a"; | ||
} |
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,26 @@ | ||
namespace OllamaSharp.Constants; | ||
|
||
/// <summary> | ||
/// Provides a collection of constant endpoint URLs used by the API in the OllamaSharp library. | ||
/// </summary> | ||
/// <remarks> | ||
/// <p> | ||
/// This static class contains various string constants that represent API endpoints. These constants are used primarily | ||
/// in API client implementations for making requests to specific functionality provided by the backend API. | ||
/// </p> | ||
/// </remarks> | ||
internal static class Endpoints | ||
{ | ||
public const string CreateModel = "api/create"; | ||
public const string DeleteModel = "api/delete"; | ||
public const string ListLocalModels = "api/tags"; | ||
public const string ListRunningModels = "api/ps"; | ||
public const string ShowModel = "api/show"; | ||
public const string CopyModel = "api/copy"; | ||
public const string PullModel = "api/pull"; | ||
public const string PushModel = "api/push"; | ||
public const string Embed = "api/embed"; | ||
public const string Chat = "api/chat"; | ||
public const string Version = "api/version"; | ||
public const string Generate = "api/generate"; | ||
} |
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,12 @@ | ||
namespace OllamaSharp.Constants; | ||
|
||
/// <summary> | ||
/// Provides predefined MIME type constants to be used across the application. | ||
/// <p> | ||
/// MIME types are used to specify the format of data being sent or received in HTTP requests. | ||
/// </p> | ||
/// </summary> | ||
internal static class MimeTypes | ||
{ | ||
public const string Json = "application/json"; | ||
} |
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
Oops, something went wrong.