-
Notifications
You must be signed in to change notification settings - Fork 85
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 #147 from awaescher/docs
Merge JD's docs
- Loading branch information
Showing
48 changed files
with
1,600 additions
and
852 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
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,9 @@ | ||
.flex-row { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.flex-column { | ||
display: flex; | ||
flex-direction: column; | ||
} |
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,10 @@ | ||
export default { | ||
defaultTheme: 'dark', | ||
iconLinks: [ | ||
{ | ||
icon: 'github', | ||
href: 'https://github.com/awaescher/OllamaSharp', | ||
title: 'GitHub' | ||
} | ||
] | ||
} |
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,52 @@ | ||
{ | ||
"metadata": [ | ||
{ | ||
"src": [ | ||
{ | ||
"src": "./src", | ||
"files": [ | ||
"**/*.csproj" | ||
] | ||
} | ||
], | ||
"dest": "api" | ||
} | ||
], | ||
"build": { | ||
"content": [ | ||
{ | ||
"files": [ | ||
"**/*.{md,yml}" | ||
], | ||
"exclude": [ | ||
"_site/**" | ||
] | ||
} | ||
], | ||
"markdownEngineProperties": { | ||
"markdigExtensions": [ | ||
"CustomContainers" | ||
] | ||
}, | ||
"resource": [ | ||
{ | ||
"files": [ | ||
"images/**" | ||
] | ||
} | ||
], | ||
"output": "_site", | ||
"template": [ | ||
"default", | ||
"modern", | ||
"doc-template" | ||
], | ||
"globalMetadata": { | ||
"_appName": "OllamaSharp", | ||
"_appTitle": "OllamaSharp", | ||
"_appLogoPath": "images/0.png", | ||
"_enableSearch": true, | ||
"pdf": true | ||
} | ||
} | ||
} |
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,64 @@ | ||
# Getting Started | ||
|
||
[OllamaSharp](https://github.com/awaescher/OllamaSharp) provides .NET bindings for the Ollama API, simplifying interactions with Ollama both locally and remotely. It provides asynchronous streaming, progress reporting and convenience classes and functions to simplify common use cases. | ||
|
||
Getting started with OllamaSharp only requires a running Ollama server and a supported version of [.NET](https://dotnet.microsoft.com/en-us/download). | ||
|
||
## Prerequisites | ||
|
||
- [Ollama](https://ollama.com/) | ||
- [.NET](https://dotnet.microsoft.com/en-us/download) | ||
|
||
## Pulling a model | ||
|
||
To use Ollama, you will need to specify a large language model to talk with. You can download a model from the [Ollama model hub](https://ollama.com/models). Below is a code snippet illustrating how to connect to an Ollama server and pull a model from there: | ||
|
||
```csharp | ||
using OllamaSharp; | ||
|
||
// if you are running Ollama locally on the default port: | ||
var uri = new Uri("http://localhost:11434"); | ||
var ollama = new OllamaApiClient(uri); | ||
|
||
// pull the model, and print the status of the pull operation. | ||
await foreach (var status in ollama.PullModelAsync("llama3.2-vision")) | ||
Console.WriteLine($"{status.Percent}% {status.Status}"); | ||
|
||
Console.WriteLine("Model pulled successfully."); | ||
``` | ||
|
||
This should result in an output like this: | ||
|
||
``` | ||
100% pulling manifest | ||
100% pulling 11f274007f09 | ||
100% pulling ece5e659647a | ||
100% pulling 715415638c9c | ||
100% pulling 0b4284c1f870 | ||
100% pulling fefc914e46e6 | ||
100% pulling fbd313562bb7 | ||
100% verifying sha256 digest | ||
100% writing manifest | ||
100% success | ||
Model pulled successfully. | ||
``` | ||
|
||
## Taking to a model | ||
|
||
After obtaining a model, you can begin interacting with Ollama. The following code snippet demonstrates how to connect to an Ollama server, load a model, and initiate a conversation: | ||
|
||
```csharp | ||
using OllamaSharp; | ||
|
||
var uri = new Uri("http://localhost:11434"); | ||
var model = "llama3.2-vision"; | ||
|
||
var ollama = new OllamaApiClient(uri, model); | ||
|
||
var request = "Write a deep, beautiful song for me about AI and the future."; | ||
|
||
await foreach (var stream in ollama.GenerateAsync(request)) | ||
Console.Write(stream.Response); | ||
``` | ||
|
||
The model's answer should be streamed directly into your Console window. |
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,5 @@ | ||
# Introduction | ||
|
||
[Ollama](https://ollama.com/) is a [Go](https://go.dev/)-based, open-source server for interacting with local large language models using Georgi Gerganov's [llama.cpp](https://github.com/ggerganov/llama.cpp) library. Ollama provides first-class support for various models, including [llama3.2](https://ollama.com/library/llama3.2), [phi3.5](https://ollama.com/library/phi3.5), [mistral](https://ollama.com/library/mistral), and many more. It provides support for pulling, running, creating, pushing, and interacting with models. | ||
|
||
[OllamaSharp](https://github.com/awaescher/OllamaSharp) provides .NET bindings for the Ollama API, simplifying interactions with Ollama both locally and remotely. It provides asynchronous streaming, progress reporting and convenience classes and functions to simplify common use cases. |
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,4 @@ | ||
- name: Introduction | ||
href: introduction.md | ||
- name: Getting Started | ||
href: getting-started.md |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,53 @@ | ||
--- | ||
_layout: landing | ||
--- | ||
|
||
::::flex-row | ||
|
||
:::col | ||
|
||
![Ollama Logo](images/[email protected]) ➕ ![.NET Logo](images/[email protected]) | ||
|
||
# Build AI-powered applications with Ollama and .NET 🦙 | ||
|
||
OllamaSharp provides .NET bindings for the [Ollama API](https://github.com/jmorganca/ollama/blob/main/docs/api.md), simplifying interactions with Ollama both locally and remotely. | ||
|
||
Provides support for interacting with Ollama directly, or through the [Microsoft.Extensions.AI](https://devblogs.microsoft.com/dotnet/introducing-microsoft-extensions-ai-preview/) | ||
and [Microsoft Semantic Kernel](https://github.com/microsoft/semantic-kernel/pull/7362) libraries. | ||
::: | ||
:::col | ||
|
||
### Add OllamaSharp to your project | ||
```bash | ||
dotnet add package OllamaSharp | ||
``` | ||
|
||
### Start talking to Ollama | ||
```csharp | ||
using OllamaSharp; | ||
|
||
var uri = new Uri("http://localhost:11434"); | ||
var ollama = new OllamaApiClient(uri, "llama3.2"); | ||
|
||
// messages including their roles and tool calls will automatically | ||
// be tracked within the chat object and are accessible via the Messages property | ||
var chat = new Chat(ollama); | ||
|
||
Console.WriteLine("You're now talking with Ollama. Hit Ctrl+C to exit."); | ||
|
||
while (true) | ||
{ | ||
Console.Write("You: "); | ||
var input = Console.ReadLine(); | ||
|
||
Console.Write("Assistant: "); | ||
await foreach (var stream in chat.SendAsync(message)) | ||
Console.Write(stream); | ||
|
||
Console.WriteLine(""); | ||
} | ||
``` | ||
|
||
::: | ||
|
||
:::: |
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
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.