-
Notifications
You must be signed in to change notification settings - Fork 93
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 #142 from JerrettDavis/feature/add-documentation
Added Documentation, Updated Access Modifiers, and Corrected Null Checking/Assertions
- Loading branch information
Showing
50 changed files
with
1,091 additions
and
234 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: docfx Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
actions: read | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
publish-docs: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Dotnet Setup | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- run: dotnet tool update -g docfx | ||
- run: docfx ./docfx.json | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: './_site' | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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 |
---|---|---|
|
@@ -396,4 +396,8 @@ FodyWeavers.xsd | |
|
||
# JetBrains Rider | ||
*.sln.iml | ||
/.idea | ||
/.idea | ||
|
||
# DocFX | ||
_site/ | ||
api/ |
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,55 @@ | ||
using FluentAssertions; | ||
using Microsoft.Extensions.AI; | ||
|
||
namespace OllamaSharp.FunctionalTests; | ||
|
||
public class ChatTests | ||
{ | ||
private readonly Uri _baseUri = new("http://localhost:11434"); | ||
private readonly string _model = "llama3.2:1b"; | ||
|
||
#pragma warning disable NUnit1032 | ||
private OllamaApiClient _client = null!; | ||
private Chat _chat = null!; | ||
#pragma warning restore NUnit1032 | ||
|
||
[SetUp] | ||
public async Task Setup() | ||
{ | ||
// Set up the test environment | ||
_client = new OllamaApiClient(_baseUri); | ||
_chat = new Chat(_client); | ||
|
||
await _client.PullIfNotExistsAsync(_model); | ||
} | ||
|
||
[TearDown] | ||
public Task Teardown() | ||
{ | ||
// Clean up the test environment | ||
((IChatClient?)_client)?.Dispose(); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
|
||
[Test] | ||
public async Task SendAsync_ShouldSucceed() | ||
{ | ||
// Arrange | ||
_client.SelectedModel = _model; | ||
|
||
// Act | ||
var response = await _chat | ||
.SendAsync("What is the ultimate answer to " + | ||
"life, the universe, and everything, as specified in " + | ||
"a Hitchhikers Guide to the Galaxy. " + | ||
"Provide only the answer.", | ||
CancellationToken.None) | ||
.StreamToEndAsync(); | ||
|
||
// Assert | ||
response.Should().NotBeNullOrEmpty(); | ||
response.Should().ContainAny("42", "forty-two", "forty two"); | ||
} | ||
} |
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 OllamaSharp.Models; | ||
|
||
namespace OllamaSharp.FunctionalTests; | ||
|
||
public static class Helpers | ||
{ | ||
public static async Task PullIfNotExistsAsync( | ||
this IOllamaApiClient client, | ||
string model) | ||
{ | ||
var modelExists = (await client.ListLocalModelsAsync()) | ||
.Any(m => m.Name == model); | ||
|
||
if (!modelExists) | ||
await client.PullModelAsync(new PullModelRequest { Model = model }) | ||
.ToListAsync(); | ||
} | ||
} |
Oops, something went wrong.