├── .github ├── dependabot.yml └── workflows │ ├── auto-merge.yml │ ├── auto-update.yml │ ├── dotnet.yml │ ├── mkdocs.yml │ └── pull-request.yml ├── .gitignore ├── LICENSE ├── Ollama.sln ├── README.md ├── assets └── nuget_icon.png ├── docs ├── css │ └── extra.css └── media │ └── icon128.png ├── global.json ├── mkdocs.yml └── src ├── Directory.Build.props ├── helpers ├── FixOpenApiSpec │ ├── FixOpenApiSpec.csproj │ └── Program.cs ├── GenerateDocs │ ├── GenerateDocs.csproj │ └── Program.cs └── TrimmingHelper │ ├── Program.cs │ └── TrimmingHelper.csproj ├── key.snk ├── libs ├── Directory.Build.props └── Ollama │ ├── Chat.cs │ ├── Extensions │ └── StringExtensions.cs │ ├── Generated │ ├── AnyOf.2.Json.g.cs │ ├── AnyOf.2.g.cs │ ├── JsonConverters.UnixTimestamp.g.cs │ ├── Ollama..JsonSerializerContext.g.cs │ ├── Ollama.ChatClient.GenerateChatCompletion.g.cs │ ├── Ollama.ChatClient.g.cs │ ├── Ollama.CompletionsClient.GenerateCompletion.g.cs │ ├── Ollama.CompletionsClient.g.cs │ ├── Ollama.EmbeddingsClient.GenerateEmbedding.g.cs │ ├── Ollama.EmbeddingsClient.g.cs │ ├── Ollama.Exceptions.g.cs │ ├── Ollama.IChatClient.GenerateChatCompletion.g.cs │ ├── Ollama.IChatClient.g.cs │ ├── Ollama.ICompletionsClient.GenerateCompletion.g.cs │ ├── Ollama.ICompletionsClient.g.cs │ ├── Ollama.IEmbeddingsClient.GenerateEmbedding.g.cs │ ├── Ollama.IEmbeddingsClient.g.cs │ ├── Ollama.IModelsClient.CheckBlob.g.cs │ ├── Ollama.IModelsClient.CopyModel.g.cs │ ├── Ollama.IModelsClient.CreateBlob.g.cs │ ├── Ollama.IModelsClient.CreateModel.g.cs │ ├── Ollama.IModelsClient.DeleteModel.g.cs │ ├── Ollama.IModelsClient.ListModels.g.cs │ ├── Ollama.IModelsClient.ListRunningModels.g.cs │ ├── Ollama.IModelsClient.PullModel.g.cs │ ├── Ollama.IModelsClient.PushModel.g.cs │ ├── Ollama.IModelsClient.ShowModelInfo.g.cs │ ├── Ollama.IModelsClient.g.cs │ ├── Ollama.IOllamaApiClient.GetVersion.g.cs │ ├── Ollama.IOllamaApiClient.g.cs │ ├── Ollama.JsonConverters.AnyOf2.g.cs │ ├── Ollama.JsonConverters.Capability.g.cs │ ├── Ollama.JsonConverters.CapabilityNullable.g.cs │ ├── Ollama.JsonConverters.CreateModelStatus.g.cs │ ├── Ollama.JsonConverters.CreateModelStatusEnum.g.cs │ ├── Ollama.JsonConverters.CreateModelStatusEnumNullable.g.cs │ ├── Ollama.JsonConverters.DoneReason.g.cs │ ├── Ollama.JsonConverters.DoneReasonEnum.g.cs │ ├── Ollama.JsonConverters.DoneReasonEnumNullable.g.cs │ ├── Ollama.JsonConverters.MessageRole.g.cs │ ├── Ollama.JsonConverters.MessageRoleNullable.g.cs │ ├── Ollama.JsonConverters.PullModelStatus.g.cs │ ├── Ollama.JsonConverters.PullModelStatusEnum.g.cs │ ├── Ollama.JsonConverters.PullModelStatusEnumNullable.g.cs │ ├── Ollama.JsonConverters.PushModelResponseStatus.g.cs │ ├── Ollama.JsonConverters.PushModelResponseStatusNullable.g.cs │ ├── Ollama.JsonConverters.ResponseFormat.g.cs │ ├── Ollama.JsonConverters.ResponseFormatEnum.g.cs │ ├── Ollama.JsonConverters.ResponseFormatEnumNullable.g.cs │ ├── Ollama.JsonConverters.ToolType.g.cs │ ├── Ollama.JsonConverters.ToolTypeNullable.g.cs │ ├── Ollama.JsonSerializerContextTypes.g.cs │ ├── Ollama.Models.Capability.g.cs │ ├── Ollama.Models.CopyModelRequest.Json.g.cs │ ├── Ollama.Models.CopyModelRequest.g.cs │ ├── Ollama.Models.CreateModelRequest.Json.g.cs │ ├── Ollama.Models.CreateModelRequest.g.cs │ ├── Ollama.Models.CreateModelResponse.Json.g.cs │ ├── Ollama.Models.CreateModelResponse.g.cs │ ├── Ollama.Models.CreateModelStatus.Json.g.cs │ ├── Ollama.Models.CreateModelStatus.g.cs │ ├── Ollama.Models.CreateModelStatusEnum.g.cs │ ├── Ollama.Models.DeleteModelRequest.Json.g.cs │ ├── Ollama.Models.DeleteModelRequest.g.cs │ ├── Ollama.Models.DoneReason.Json.g.cs │ ├── Ollama.Models.DoneReason.g.cs │ ├── Ollama.Models.DoneReasonEnum.g.cs │ ├── Ollama.Models.GenerateChatCompletionRequest.Json.g.cs │ ├── Ollama.Models.GenerateChatCompletionRequest.g.cs │ ├── Ollama.Models.GenerateChatCompletionResponse.Json.g.cs │ ├── Ollama.Models.GenerateChatCompletionResponse.g.cs │ ├── Ollama.Models.GenerateCompletionRequest.Json.g.cs │ ├── Ollama.Models.GenerateCompletionRequest.g.cs │ ├── Ollama.Models.GenerateCompletionResponse.Json.g.cs │ ├── Ollama.Models.GenerateCompletionResponse.g.cs │ ├── Ollama.Models.GenerateEmbeddingRequest.Json.g.cs │ ├── Ollama.Models.GenerateEmbeddingRequest.g.cs │ ├── Ollama.Models.GenerateEmbeddingResponse.Json.g.cs │ ├── Ollama.Models.GenerateEmbeddingResponse.g.cs │ ├── Ollama.Models.Message.Json.g.cs │ ├── Ollama.Models.Message.g.cs │ ├── Ollama.Models.MessageRole.g.cs │ ├── Ollama.Models.Model.Json.g.cs │ ├── Ollama.Models.Model.g.cs │ ├── Ollama.Models.ModelDetails.Json.g.cs │ ├── Ollama.Models.ModelDetails.g.cs │ ├── Ollama.Models.ModelInfo.Json.g.cs │ ├── Ollama.Models.ModelInfo.g.cs │ ├── Ollama.Models.ModelInfoProjectorInfo.Json.g.cs │ ├── Ollama.Models.ModelInfoProjectorInfo.g.cs │ ├── Ollama.Models.ModelInfoRequest.Json.g.cs │ ├── Ollama.Models.ModelInfoRequest.g.cs │ ├── Ollama.Models.ModelInformation.Json.g.cs │ ├── Ollama.Models.ModelInformation.g.cs │ ├── Ollama.Models.ModelsResponse.Json.g.cs │ ├── Ollama.Models.ModelsResponse.g.cs │ ├── Ollama.Models.ProcessModel.Json.g.cs │ ├── Ollama.Models.ProcessModel.g.cs │ ├── Ollama.Models.ProcessResponse.Json.g.cs │ ├── Ollama.Models.ProcessResponse.g.cs │ ├── Ollama.Models.PullModelRequest.Json.g.cs │ ├── Ollama.Models.PullModelRequest.g.cs │ ├── Ollama.Models.PullModelResponse.Json.g.cs │ ├── Ollama.Models.PullModelResponse.g.cs │ ├── Ollama.Models.PullModelStatus.Json.g.cs │ ├── Ollama.Models.PullModelStatus.g.cs │ ├── Ollama.Models.PullModelStatusEnum.g.cs │ ├── Ollama.Models.PushModelRequest.Json.g.cs │ ├── Ollama.Models.PushModelRequest.g.cs │ ├── Ollama.Models.PushModelResponse.Json.g.cs │ ├── Ollama.Models.PushModelResponse.g.cs │ ├── Ollama.Models.PushModelResponseStatus.g.cs │ ├── Ollama.Models.RequestOptions.Json.g.cs │ ├── Ollama.Models.RequestOptions.g.cs │ ├── Ollama.Models.ResponseFormat.Json.g.cs │ ├── Ollama.Models.ResponseFormat.g.cs │ ├── Ollama.Models.ResponseFormatEnum.g.cs │ ├── Ollama.Models.ResponseFormatEnum2.Json.g.cs │ ├── Ollama.Models.ResponseFormatEnum2.g.cs │ ├── Ollama.Models.Tensor.Json.g.cs │ ├── Ollama.Models.Tensor.g.cs │ ├── Ollama.Models.Tool.Json.g.cs │ ├── Ollama.Models.Tool.g.cs │ ├── Ollama.Models.ToolCall.Json.g.cs │ ├── Ollama.Models.ToolCall.g.cs │ ├── Ollama.Models.ToolCallFunction.Json.g.cs │ ├── Ollama.Models.ToolCallFunction.g.cs │ ├── Ollama.Models.ToolCallFunctionArgs.Json.g.cs │ ├── Ollama.Models.ToolCallFunctionArgs.g.cs │ ├── Ollama.Models.ToolFunction.Json.g.cs │ ├── Ollama.Models.ToolFunction.g.cs │ ├── Ollama.Models.ToolFunctionParams.Json.g.cs │ ├── Ollama.Models.ToolFunctionParams.g.cs │ ├── Ollama.Models.ToolType.g.cs │ ├── Ollama.Models.VersionResponse.Json.g.cs │ ├── Ollama.Models.VersionResponse.g.cs │ ├── Ollama.ModelsClient.CheckBlob.g.cs │ ├── Ollama.ModelsClient.CopyModel.g.cs │ ├── Ollama.ModelsClient.CreateBlob.g.cs │ ├── Ollama.ModelsClient.CreateModel.g.cs │ ├── Ollama.ModelsClient.DeleteModel.g.cs │ ├── Ollama.ModelsClient.ListModels.g.cs │ ├── Ollama.ModelsClient.ListRunningModels.g.cs │ ├── Ollama.ModelsClient.PullModel.g.cs │ ├── Ollama.ModelsClient.PushModel.g.cs │ ├── Ollama.ModelsClient.ShowModelInfo.g.cs │ ├── Ollama.ModelsClient.g.cs │ ├── Ollama.OllamaApiClient.GetVersion.g.cs │ ├── Ollama.OllamaApiClient.g.cs │ ├── Ollama.PathBuilder.g.cs │ └── Ollama.Polyfills.g.cs │ ├── JsonSerializerContextTypes.AdditionalTypes.cs │ ├── Message.cs │ ├── Ollama.csproj │ ├── OllamaApiClientExtensions.cs │ ├── PullModelResponseExtensions.cs │ ├── generate.sh │ └── openapi.yaml └── tests └── Ollama.IntegrationTests ├── Environment.cs ├── Ollama.IntegrationTests.csproj ├── Test.StructuredOutputInChat.cs ├── Tests.Chat.cs ├── Tests.Embeddings.cs ├── Tests.GetCompletion.cs ├── Tests.GetCompletionWithOptions.cs ├── Tests.ListModels.cs ├── Tests.PullModel.cs ├── Tests.ReaderLm.cs ├── Tests.Tools.cs ├── Tests.ToolsInChat.cs └── WeatherTools.cs /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "nuget" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | groups: 13 | all: 14 | patterns: 15 | - "*" 16 | ignore: 17 | - dependency-name: Microsoft.CodeAnalysis.CSharp 18 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: Auto-approve and auto-merge bot pull requests 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | 7 | permissions: 8 | contents: write 9 | pull-requests: write 10 | 11 | jobs: 12 | auto-merge: 13 | runs-on: ubuntu-latest 14 | if: ${{ github.event.pull_request.draft == false && (github.actor == 'dependabot[bot]' || github.actor == 'HavenDV') && github.repository_owner == 'tryAGI' }} 15 | steps: 16 | - name: Dependabot metadata 17 | if: ${{ github.actor == 'dependabot[bot]' }} 18 | id: metadata 19 | uses: dependabot/fetch-metadata@0fb21704c18a42ce5aa8d720ea4b912f5e6babef 20 | with: 21 | github-token: "${{ secrets.GITHUB_TOKEN }}" 22 | 23 | - name: Show sender 24 | run: echo ${{ github.event.pull_request.sender }} 25 | 26 | - name: Show triggering_actor 27 | run: echo ${{ github.triggering_actor }} 28 | 29 | - name: Approve a PR 30 | run: gh pr review --approve "$PR_URL" 31 | env: 32 | PR_URL: ${{ github.event.pull_request.html_url }} 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | 35 | - name: Enable auto-merge 36 | run: gh pr merge --auto --squash "$PR_URL" 37 | env: 38 | PR_URL: ${{ github.event.pull_request.html_url }} 39 | GH_TOKEN: ${{ secrets.PERSONAL_TOKEN || secrets.GITHUB_TOKEN }} 40 | -------------------------------------------------------------------------------- /.github/workflows/auto-update.yml: -------------------------------------------------------------------------------- 1 | name: Opens a new PR if there are OpenAPI updates 2 | on: 3 | schedule: 4 | - cron: '0 */3 * * *' 5 | 6 | permissions: 7 | contents: write 8 | pull-requests: write 9 | actions: write 10 | 11 | jobs: 12 | check-openapi-updates: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | 18 | - name: Setup Git user 19 | run: | 20 | git config --local user.email "bot@openai.com" 21 | git config --local user.name "github-actions[bot]" 22 | 23 | - name: Generate branch name 24 | id: branch 25 | run: echo "branch_name=bot/update-openapi_$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT 26 | 27 | - name: Create branch 28 | run: | 29 | git checkout -b ${{ steps.branch.outputs.branch_name }} origin/main 30 | git rebase main 31 | 32 | - name: Setup .NET 33 | uses: actions/setup-dotnet@v4 34 | with: 35 | dotnet-version: 9.0.x 36 | 37 | - name: Generate code 38 | run: | 39 | cd src/libs/Ollama 40 | chmod +x ./generate.sh 41 | ./generate.sh 42 | 43 | - name: Check for changes 44 | id: changes 45 | run: | 46 | CHANGED=$(git diff --name-only) 47 | if [ -z "$CHANGED" ]; then 48 | echo "has_changes=false" >> $GITHUB_OUTPUT 49 | else 50 | echo "has_changes=true" >> $GITHUB_OUTPUT 51 | fi 52 | 53 | - name: Push changes 54 | if: steps.changes.outputs.has_changes == 'true' 55 | run: | 56 | git add . 57 | git commit -m "feat: Updated OpenAPI spec" 58 | git push --force-with-lease -u origin ${{ steps.branch.outputs.branch_name }} 59 | 60 | - name: Wait for 15 seconds 61 | if: steps.changes.outputs.has_changes == 'true' 62 | run: sleep 15 63 | 64 | - name: Create pull request 65 | if: steps.changes.outputs.has_changes == 'true' 66 | run: gh pr create -B main -H ${{ steps.branch.outputs.branch_name }} --title 'feat:@coderabbitai' --body '@coderabbitai summary' 67 | env: 68 | GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} 69 | -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | on: 3 | push: 4 | branches: 5 | - main 6 | tags: 7 | - v* 8 | 9 | permissions: 10 | contents: write 11 | 12 | jobs: 13 | publish: 14 | name: Publish 15 | uses: HavenDV/workflows/.github/workflows/dotnet_build-test-publish.yml@main 16 | with: 17 | generate-build-number: false 18 | conventional-commits-publish-conditions: false 19 | enable-caching: false 20 | additional-test-arguments: '--logger GitHubActions' 21 | secrets: 22 | nuget-key: ${{ secrets.NUGET_KEY }} 23 | 24 | release: 25 | name: Release 26 | runs-on: ubuntu-latest 27 | needs: [publish] 28 | if: startsWith(github.ref, 'refs/tags/v') 29 | steps: 30 | - name: Checkout 31 | uses: actions/checkout@v4 32 | 33 | - name: Create release 34 | run: gh release create ${{ github.ref_name }} 35 | --title "${{ github.ref_name }}" 36 | --generate-notes 37 | env: 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/mkdocs.yml: -------------------------------------------------------------------------------- 1 | name: MKDocs Deploy 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths: 7 | - 'docs/**' 8 | - 'mkdocs.yml' 9 | - 'examples/**' 10 | - 'src/helpers/GenerateDocs/**' 11 | - '.github/workflows/mkdocs.yml' 12 | - 'src/tests/IntegrationTests/**' 13 | - 'README.md' 14 | 15 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 16 | permissions: 17 | contents: read 18 | pages: write 19 | id-token: write 20 | 21 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 22 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 23 | concurrency: 24 | group: "pages" 25 | cancel-in-progress: false 26 | 27 | jobs: 28 | build: 29 | runs-on: ubuntu-latest 30 | steps: 31 | - name: Checkout 32 | uses: actions/checkout@v4 33 | 34 | - name: Setup Pages 35 | uses: actions/configure-pages@v5 36 | 37 | - name: Setup .NET 38 | uses: actions/setup-dotnet@v4 39 | with: 40 | dotnet-version: 9.0.x 41 | 42 | - name: Generate docs 43 | run: dotnet run --project src/helpers/GenerateDocs/GenerateDocs.csproj . 44 | 45 | - name: Build with MkDocs 46 | run: | 47 | python -m venv myenv 48 | source myenv/bin/activate 49 | pip install mkdocs-material 50 | mkdocs build -d ./_site 51 | 52 | - name: Upload artifact 53 | uses: actions/upload-pages-artifact@v3 54 | 55 | deploy: 56 | environment: 57 | name: github-pages 58 | url: ${{ steps.deployment.outputs.page_url }} 59 | runs-on: ubuntu-latest 60 | needs: build 61 | steps: 62 | - name: Deploy to GitHub Pages 63 | id: deployment 64 | uses: actions/deploy-pages@v4 -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | test: 9 | name: Test 10 | if: github.event.pull_request.draft == false 11 | uses: HavenDV/workflows/.github/workflows/dotnet_build-test-publish.yml@main 12 | with: 13 | generate-build-number: false 14 | conventional-commits-publish-conditions: false 15 | enable-caching: false 16 | additional-test-arguments: '--logger GitHubActions' -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 tryAGI, Andreas Wäscher and David Miguel Lozano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /assets/nuget_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tryAGI/Ollama/5e8cae96a9ba24018f4ded0eb286088999ebfbac/assets/nuget_icon.png -------------------------------------------------------------------------------- /docs/css/extra.css: -------------------------------------------------------------------------------- 1 | /* Logo title */ 2 | .md-header__topic:first-child { 3 | font-weight: initial !important; 4 | } 5 | 6 | /* Code font size in
*/ 7 | details .linenos, details code { 8 | font-size: inherit !important; 9 | } 10 | 11 | /* Code block / tab in details */ 12 | details > summary + .highlight:last-child, details > summary + .tabbed-set:last-child { margin: 0 -0.6rem !important; } 13 | details > summary + .highlight:last-child > .highlighttable { margin: 0 !important; } 14 | 15 | /* Table full width */ 16 | .md-typeset__table { display: block !important; } 17 | .md-typeset table:not(.highlighttable) { display: table !important; } 18 | 19 | .md-typeset table:not([class]) th { 20 | min-width: 0rem; 21 | } 22 | 23 | .headerlink { transform: translateY(-2.5px); } 24 | 25 | .md-nav__link[for=__toc] .md-icon { margin-left: auto !important; } 26 | 27 | blockquote.page-time { 28 | margin: 20px 0 !important; 29 | border-left-color: #64b5f6 !important; /* Just change the color value and that's it*/ 30 | } 31 | blockquote.page-copyright { 32 | margin: 20px 0 !important; 33 | border-left-color: #ff1700 !important; /* Just change the color value and that's it*/ 34 | } 35 | blockquote.page-copyright i.md-icon { 36 | display: inline-block; 37 | margin-right: 5px; 38 | transform: translateY(3.5px); 39 | width: 18px; 40 | } 41 | 42 | #myBtn { 43 | display: none; 44 | position: fixed; 45 | bottom: 100px; 46 | right: 16px; 47 | z-index: 99; 48 | border: none; 49 | outline: none; 50 | color: #8590a6; 51 | cursor: pointer; 52 | padding: .7rem; 53 | border-radius: .4rem; 54 | } 55 | 56 | #myBtn:hover { 57 | background-color: #d3d3d3; 58 | } 59 | 60 | #color-button > button { 61 | cursor: pointer; 62 | transition: opacity .25s; 63 | display: inline-block; 64 | width: 6.5rem; 65 | margin-bottom: 0.2rem; 66 | padding: 1.2rem 0.4rem 0.2rem; 67 | font-size: 0.64rem; 68 | text-align: left; 69 | } 70 | 71 | #color-button > button[data-md-color-primary] { 72 | background-color: var(--md-primary-fg-color); 73 | color: var(--md-primary-bg-color); 74 | } 75 | #color-button > button[data-md-color-primary=white] { 76 | box-shadow: inset 0 0 0.05rem rgb(0 0 0 / 54%); 77 | } 78 | 79 | #color-button > button[data-md-color-accent] { 80 | background-color: var(--md-accent-fg-color); 81 | color: var(--md-code-bg-color); 82 | } 83 | 84 | mjx-container > img { 85 | width: 0; 86 | height: 0; 87 | } 88 | 89 | [data-md-color-scheme="slate"] { 90 | --md-primary-fg-color: #2e303e; 91 | --md-accent-fg-color: #00bda4; 92 | --md-typeset-a-color: #526cfe; 93 | } 94 | 95 | [data-md-color-scheme="slate"] .md-typeset img { 96 | background: white; 97 | filter: brightness(0.9); 98 | } 99 | 100 | [data-md-color-scheme="slate"] .md-typeset img[src$=".svg"] { 101 | border: 4px solid white; 102 | } -------------------------------------------------------------------------------- /docs/media/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tryAGI/Ollama/5e8cae96a9ba24018f4ded0eb286088999ebfbac/docs/media/icon128.png -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "rollForward": "latestMajor", 4 | "allowPrerelease": false 5 | } 6 | } -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Ollama .NET Documentation 2 | nav: 3 | - Overview: index.md 4 | # EXAMPLES # 5 | 6 | # - Quick Start: QuickStart.md 7 | # - Architecture: Architecture.md 8 | # - FAQ: FAQ.md 9 | # - Contributing Guide: ContributingGuide.md 10 | # - Tutorials: 11 | # - Configure the native library loading: Tutorials/NativeLibraryConfig.md 12 | # - Use executors: Tutorials/Executors.md 13 | # - Use ChatSession: Tutorials/ChatSession.md 14 | # - Understand LLamaContext: Tutorials/UnderstandLLamaContext.md 15 | # - Get embeddings: Tutorials/GetEmbeddings.md 16 | # - Quantize the model: Tutorials/Quantization.md 17 | # 18 | # - Advanced Tutorials: 19 | # - Customize the native library loading: AdvancedTutorials/CustomizeNativeLibraryLoading.md 20 | # 21 | # - Integrations: 22 | # - semantic-kernel integration: Integrations/semantic-kernel.md 23 | # - kernel-memory integration: Integrations/kernel-memory.md 24 | # - BotSharp integration: Integrations/BotSharp.md 25 | # - Langchain integration: Integrations/Langchain.md 26 | # 27 | # - Examples: 28 | # - Bacthed executor - multi-output to one input: Examples/BatchedExecutorFork.md 29 | # - Batched executor - basic guidance: Examples/BatchedExecutorGuidance.md 30 | # - Batched executor - rewinding to an earlier state: Examples/BatchedExecutorRewind.md 31 | 32 | theme: 33 | name: material 34 | static_templates: 35 | - 404.html 36 | language: 'en' 37 | palette: 38 | # Palette toggle for light mode 39 | - media: "(prefers-color-scheme: light)" 40 | scheme: default 41 | primary: white 42 | accent: red 43 | toggle: 44 | icon: material/weather-sunny 45 | name: Switch to dark mode 46 | 47 | # Palette toggle for dark mode 48 | - media: "(prefers-color-scheme: dark)" 49 | scheme: slate 50 | primary: blue 51 | accent: blue 52 | toggle: 53 | icon: material/weather-night 54 | name: Switch to light mode 55 | include_search_page: false 56 | search_index_only: true 57 | favicon: 'media/icon128.png' 58 | icon: 59 | logo: 'material/file-document' 60 | features: 61 | - content.action.edit 62 | - navigation.instant 63 | font: 64 | text: 'Fira Sans' 65 | code: 'Fira Mono' 66 | 67 | extra: 68 | version: 69 | provider: mike 70 | 71 | extra_css: 72 | - 'css/extra.css?v=14' 73 | 74 | markdown_extensions: 75 | - admonition 76 | - def_list 77 | - footnotes 78 | - meta 79 | - toc: 80 | permalink: "" 81 | slugify: !!python/name:pymdownx.slugs.uslugify 82 | - pymdownx.arithmatex: 83 | generic: true 84 | - pymdownx.caret 85 | - pymdownx.critic 86 | - pymdownx.details 87 | - pymdownx.emoji: 88 | emoji_generator: !!python/name:pymdownx.emoji.to_svg 89 | - pymdownx.highlight: 90 | linenums: true 91 | - pymdownx.inlinehilite 92 | - pymdownx.keys 93 | - pymdownx.magiclink 94 | - pymdownx.mark 95 | - pymdownx.snippets: 96 | check_paths: true 97 | - pymdownx.progressbar 98 | - pymdownx.smartsymbols 99 | - pymdownx.superfences: 100 | custom_fences: 101 | - name: math 102 | class: arithmatex 103 | format: !!python/name:pymdownx.arithmatex.fence_mathjax_format 104 | - pymdownx.tasklist: 105 | custom_checkbox: true 106 | - pymdownx.tilde 107 | - pymdownx.tabbed: 108 | alternate_style: true -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | preview 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/helpers/FixOpenApiSpec/FixOpenApiSpec.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | Exe 6 | preview 7 | enable 8 | enable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/helpers/FixOpenApiSpec/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.OpenApi; 2 | using Microsoft.OpenApi.Any; 3 | using Microsoft.OpenApi.Extensions; 4 | using Microsoft.OpenApi.Models; 5 | using Microsoft.OpenApi.Readers; 6 | 7 | var path = args[0]; 8 | var text = await File.ReadAllTextAsync(path); 9 | 10 | var openApiDocument = new OpenApiStringReader().Read(text, out var diagnostics); 11 | openApiDocument.Components.Schemas["GenerateCompletionRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true); 12 | openApiDocument.Components.Schemas["GenerateChatCompletionRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true); 13 | openApiDocument.Components.Schemas["CreateModelRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true); 14 | openApiDocument.Components.Schemas["PullModelRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true); 15 | openApiDocument.Components.Schemas["PushModelRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true); 16 | 17 | ConvertToAnyOf(openApiDocument.Components.Schemas["DoneReason"]!); 18 | ConvertToAnyOf(openApiDocument.Components.Schemas["CreateModelStatus"]!); 19 | ConvertToAnyOf(openApiDocument.Components.Schemas["PullModelStatus"]!); 20 | 21 | openApiDocument.Components.Schemas["PushModelResponse"]!.Properties["status"] = new OpenApiSchema 22 | { 23 | Description = "Status pushing the model.", 24 | AnyOf = new List 25 | { 26 | new() 27 | { 28 | Type = "string", 29 | }, 30 | new() 31 | { 32 | Type = "string", 33 | Enum = new List 34 | { 35 | new OpenApiString("retrieving manifest"), 36 | new OpenApiString("starting upload"), 37 | new OpenApiString("pushing manifest"), 38 | new OpenApiString("success"), 39 | }, 40 | }, 41 | }, 42 | }; 43 | 44 | var currentResponseFormat = openApiDocument.Components.Schemas["ResponseFormat"]!; 45 | openApiDocument.Components.Schemas["ResponseFormat"]!.OneOf = new List 46 | { 47 | new() 48 | { 49 | Type = currentResponseFormat.Type, 50 | Enum = currentResponseFormat.Enum, 51 | Description = "Enable JSON mode by setting the format parameter to 'json'. This will structure the response as valid JSON.", 52 | }, 53 | new() 54 | { 55 | Type = "object", 56 | Description = "A JSON Schema object that defines the structure of the response. The model will generate a response that matches this schema.", 57 | }, 58 | }; 59 | openApiDocument.Components.Schemas["ResponseFormat"].Enum = null; 60 | openApiDocument.Components.Schemas["ResponseFormat"].Type = null; 61 | openApiDocument.Components.Schemas["ResponseFormat"].Description = null; 62 | 63 | text = openApiDocument.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); 64 | _ = new OpenApiStringReader().Read(text, out diagnostics); 65 | 66 | if (diagnostics.Errors.Count > 0) 67 | { 68 | foreach (var error in diagnostics.Errors) 69 | { 70 | Console.WriteLine(error.Message); 71 | } 72 | // Return Exit code 1 73 | Environment.Exit(1); 74 | } 75 | 76 | await File.WriteAllTextAsync(path, text); 77 | return; 78 | 79 | static void ConvertToAnyOf(OpenApiSchema schema) 80 | { 81 | schema.Type = null; 82 | schema.AnyOf = new List 83 | { 84 | new() 85 | { 86 | Type = "string", 87 | }, 88 | new() 89 | { 90 | Type = "string", 91 | Enum = schema.Enum, 92 | }, 93 | }; 94 | schema.Enum = null; 95 | } -------------------------------------------------------------------------------- /src/helpers/GenerateDocs/GenerateDocs.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/helpers/GenerateDocs/Program.cs: -------------------------------------------------------------------------------- 1 | var solutionDirectory = args.ElementAtOrDefault(0) ?? Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "../../../../../..")); 2 | var sampleDirectory = Path.Combine(solutionDirectory, "src", "tests", "Ollama.IntegrationTests"); 3 | var mkDocsPath = Path.Combine(solutionDirectory, "mkdocs.yml"); 4 | 5 | var newDir = Path.Combine(solutionDirectory, "docs", "samples"); 6 | Directory.CreateDirectory(newDir); 7 | 8 | File.Copy( 9 | Path.Combine(solutionDirectory, "README.md"), 10 | Path.Combine(solutionDirectory, "docs", "index.md"), 11 | overwrite: true); 12 | 13 | Console.WriteLine($"Generating samples from {sampleDirectory}..."); 14 | foreach (var path in Directory.EnumerateFiles(sampleDirectory, "Tests.*.cs", SearchOption.AllDirectories)) 15 | { 16 | var code = await File.ReadAllTextAsync(path); 17 | 18 | var start = code.IndexOf("\n {", StringComparison.Ordinal); 19 | var end = code.IndexOf("\n }", StringComparison.Ordinal); 20 | code = code.Substring(start + 4, end - start + 4); 21 | 22 | var lines = code.Split('\n')[1..^2]; 23 | code = string.Join('\n', lines 24 | .Where(x => !x.Contains(".Should()")) 25 | .Select(x => x.Length > 8 ? x[8..] : string.Empty)); 26 | 27 | code = code 28 | .Replace( 29 | "await using var container = await Environment.PrepareAsync(EnvironmentType.Container);", 30 | "using var api = new OllamaApiClient();") 31 | .Replace( 32 | "await using var container = await Environment.PrepareAsync(EnvironmentType.Local, \"llama3.2\");", 33 | string.Empty) 34 | .Replace( 35 | "await using var container = await Environment.PrepareAsync(EnvironmentType.Container, \"llama3.2\");", 36 | @"using var api = new OllamaApiClient(); 37 | 38 | await apiClient.Models.PullModelAsync(""llama3.2"").EnsureSuccessAsync();") 39 | .Replace( 40 | "await using var container = await Environment.PrepareAsync(EnvironmentType.Local, \"reader-lm:latest\");", 41 | string.Empty) 42 | .Replace( 43 | "await using var container = await Environment.PrepareAsync(EnvironmentType.Container, \"reader-lm:latest\");", 44 | @"using var api = new OllamaApiClient(); 45 | 46 | await apiClient.Models.PullModelAsync(""reader-lm:latest"").EnsureSuccessAsync();") 47 | .Replace( 48 | "container.ApiClient", 49 | "api") 50 | ; 51 | 52 | var newPath = Path.Combine(newDir, $"{Path.GetExtension(Path.GetFileNameWithoutExtension(path)).TrimStart('.')}.md"); 53 | await File.WriteAllTextAsync(newPath, $@"```csharp 54 | {code} 55 | ```"); 56 | } 57 | 58 | var mkDocs = await File.ReadAllTextAsync(mkDocsPath); 59 | var newMkDocs = mkDocs.Replace( 60 | "# EXAMPLES #", 61 | $"- Examples:{string.Concat(Directory.EnumerateFiles(Path.Combine(solutionDirectory, "docs", "samples"), "*.md") 62 | .Select(x => $@" 63 | - {Path.GetFileNameWithoutExtension(x)}: samples/{Path.GetFileNameWithoutExtension(x)}.md"))}"); 64 | await File.WriteAllTextAsync(mkDocsPath, newMkDocs); 65 | 66 | -------------------------------------------------------------------------------- /src/helpers/TrimmingHelper/Program.cs: -------------------------------------------------------------------------------- 1 | Console.WriteLine("Build, rebuild or publish this app to see trimming warnings."); -------------------------------------------------------------------------------- /src/helpers/TrimmingHelper/TrimmingHelper.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | enable 7 | 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | win-x64 21 | osx-arm64 22 | 23 | true 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tryAGI/Ollama/5e8cae96a9ba24018f4ded0eb286088999ebfbac/src/key.snk -------------------------------------------------------------------------------- /src/libs/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | true 7 | $(MSBuildThisFileDirectory)../key.snk 8 | 9 | 10 | 11 | 12 | <_Parameter1>true 13 | 14 | 15 | 16 | 17 | true 18 | true 19 | tryAGI and contributors 20 | MIT 21 | nuget_icon.png 22 | README.md 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | v 32 | dev 33 | 34 | 35 | 36 | 37 | all 38 | runtime; build; native; contentfiles; analyzers; buildtransitive 39 | 40 | 41 | 42 | 43 | 44 | all 45 | runtime; build; native; contentfiles; analyzers; buildtransitive 46 | 47 | 48 | 49 | 50 | true 51 | latest 52 | All 53 | 54 | 55 | 56 | true 57 | true 58 | true 59 | false 60 | false 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/libs/Ollama/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | namespace Ollama; 3 | 4 | /// 5 | /// 6 | /// 7 | public static class StringExtensions 8 | { 9 | /// 10 | /// 11 | /// 12 | /// 13 | /// 14 | public static Message AsUserMessage(this string content) 15 | { 16 | return new Message 17 | { 18 | Role = MessageRole.User, 19 | Content = content, 20 | }; 21 | } 22 | 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | public static Message AsAssistantMessage(this string content) 29 | { 30 | return new Message 31 | { 32 | Role = MessageRole.Assistant, 33 | Content = content, 34 | }; 35 | } 36 | 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | public static Message AsSystemMessage(this string content) 43 | { 44 | return new Message 45 | { 46 | Role = MessageRole.System, 47 | Content = content, 48 | }; 49 | } 50 | 51 | /// 52 | /// 53 | /// 54 | /// 55 | /// 56 | public static Message AsToolMessage(this string content) 57 | { 58 | return new Message 59 | { 60 | Role = MessageRole.Tool, 61 | Content = content, 62 | }; 63 | } 64 | 65 | /// 66 | /// 67 | /// 68 | /// 69 | /// 70 | public static string AsJson(this object args) 71 | { 72 | return JsonSerializer.Serialize(args, SourceGenerationContext.Default.Object); 73 | } 74 | 75 | /// 76 | /// 77 | /// 78 | /// 79 | /// 80 | public static IList AsOllamaTools( 81 | this IList tools) 82 | { 83 | return tools 84 | .Select(x => new Tool 85 | { 86 | Type = ToolType.Function, 87 | Function = new ToolFunction 88 | { 89 | Name = x.Name!, 90 | Description = x.Description ?? string.Empty, 91 | Parameters = x.Parameters ?? new ToolFunctionParams(), 92 | }, 93 | }) 94 | .ToList(); 95 | } 96 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/JsonConverters.UnixTimestamp.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public class UnixTimestampJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::System.DateTimeOffset Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | if (reader.TokenType == global::System.Text.Json.JsonTokenType.Number) 15 | { 16 | if (reader.TryGetInt64(out long unixTimestamp)) 17 | { 18 | if (unixTimestamp >= -62135596800L && unixTimestamp <= 253402300799L) 19 | { 20 | return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestamp); 21 | } 22 | 23 | return global::System.DateTimeOffset.FromUnixTimeMilliseconds(unixTimestamp); 24 | } 25 | if (reader.TryGetInt32(out int unixTimestampInt)) 26 | { 27 | return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestampInt); 28 | } 29 | } 30 | 31 | return default; 32 | } 33 | 34 | /// 35 | public override void Write( 36 | global::System.Text.Json.Utf8JsonWriter writer, 37 | global::System.DateTimeOffset value, 38 | global::System.Text.Json.JsonSerializerOptions options) 39 | { 40 | long unixTimestamp = value.ToUnixTimeSeconds(); 41 | writer.WriteNumberValue(unixTimestamp); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama..JsonSerializerContext.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | #pragma warning disable CS0618 // Type or member is obsolete 5 | #pragma warning disable CS3016 // Arrays as attribute arguments is not CLS-compliant 6 | 7 | namespace Ollama 8 | { 9 | /// 10 | /// 11 | /// 12 | [global::System.Text.Json.Serialization.JsonSourceGenerationOptions( 13 | DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, 14 | Converters = new global::System.Type[] 15 | { 16 | typeof(global::Ollama.JsonConverters.ResponseFormatEnumJsonConverter), 17 | typeof(global::Ollama.JsonConverters.ResponseFormatEnumNullableJsonConverter), 18 | typeof(global::Ollama.JsonConverters.MessageRoleJsonConverter), 19 | typeof(global::Ollama.JsonConverters.MessageRoleNullableJsonConverter), 20 | typeof(global::Ollama.JsonConverters.ToolTypeJsonConverter), 21 | typeof(global::Ollama.JsonConverters.ToolTypeNullableJsonConverter), 22 | typeof(global::Ollama.JsonConverters.DoneReasonEnumJsonConverter), 23 | typeof(global::Ollama.JsonConverters.DoneReasonEnumNullableJsonConverter), 24 | typeof(global::Ollama.JsonConverters.CreateModelStatusEnumJsonConverter), 25 | typeof(global::Ollama.JsonConverters.CreateModelStatusEnumNullableJsonConverter), 26 | typeof(global::Ollama.JsonConverters.CapabilityJsonConverter), 27 | typeof(global::Ollama.JsonConverters.CapabilityNullableJsonConverter), 28 | typeof(global::Ollama.JsonConverters.PullModelStatusEnumJsonConverter), 29 | typeof(global::Ollama.JsonConverters.PullModelStatusEnumNullableJsonConverter), 30 | typeof(global::Ollama.JsonConverters.PushModelResponseStatusJsonConverter), 31 | typeof(global::Ollama.JsonConverters.PushModelResponseStatusNullableJsonConverter), 32 | typeof(global::Ollama.JsonConverters.ResponseFormatJsonConverter), 33 | typeof(global::Ollama.JsonConverters.DoneReasonJsonConverter), 34 | typeof(global::Ollama.JsonConverters.CreateModelStatusJsonConverter), 35 | typeof(global::Ollama.JsonConverters.PullModelStatusJsonConverter), 36 | typeof(global::Ollama.JsonConverters.AnyOfJsonConverter), 37 | typeof(global::Ollama.JsonConverters.UnixTimestampJsonConverter), 38 | })] 39 | 40 | [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ollama.JsonSerializerContextTypes))] 41 | public sealed partial class SourceGenerationContext : global::System.Text.Json.Serialization.JsonSerializerContext 42 | { 43 | } 44 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.ChatClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Given a list of messages comprising a conversation, the model will return a response.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public sealed partial class ChatClient : global::Ollama.IChatClient, global::System.IDisposable 12 | { 13 | /// 14 | /// Ollama server URL 15 | /// 16 | public const string DefaultBaseUrl = "http://localhost:11434/api"; 17 | 18 | private bool _disposeHttpClient = true; 19 | 20 | /// 21 | public global::System.Net.Http.HttpClient HttpClient { get; } 22 | 23 | /// 24 | public System.Uri? BaseUri => HttpClient.BaseAddress; 25 | 26 | /// 27 | public global::System.Collections.Generic.List Authorizations { get; } 28 | 29 | /// 30 | public bool ReadResponseAsString { get; set; } 31 | #if DEBUG 32 | = true; 33 | #endif 34 | /// 35 | /// 36 | /// 37 | public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Ollama.SourceGenerationContext.Default; 38 | 39 | 40 | /// 41 | /// Creates a new instance of the ChatClient. 42 | /// If no httpClient is provided, a new one will be created. 43 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 44 | /// 45 | /// The HttpClient instance. If not provided, a new one will be created. 46 | /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. 47 | /// The authorizations to use for the requests. 48 | /// Dispose the HttpClient when the instance is disposed. True by default. 49 | public ChatClient( 50 | global::System.Net.Http.HttpClient? httpClient = null, 51 | global::System.Uri? baseUri = null, 52 | global::System.Collections.Generic.List? authorizations = null, 53 | bool disposeHttpClient = true) 54 | { 55 | HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); 56 | HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); 57 | Authorizations = authorizations ?? new global::System.Collections.Generic.List(); 58 | _disposeHttpClient = disposeHttpClient; 59 | 60 | Initialized(HttpClient); 61 | } 62 | 63 | /// 64 | public void Dispose() 65 | { 66 | if (_disposeHttpClient) 67 | { 68 | HttpClient.Dispose(); 69 | } 70 | } 71 | 72 | partial void Initialized( 73 | global::System.Net.Http.HttpClient client); 74 | partial void PrepareArguments( 75 | global::System.Net.Http.HttpClient client); 76 | partial void PrepareRequest( 77 | global::System.Net.Http.HttpClient client, 78 | global::System.Net.Http.HttpRequestMessage request); 79 | partial void ProcessResponse( 80 | global::System.Net.Http.HttpClient client, 81 | global::System.Net.Http.HttpResponseMessage response); 82 | partial void ProcessResponseContent( 83 | global::System.Net.Http.HttpClient client, 84 | global::System.Net.Http.HttpResponseMessage response, 85 | ref string content); 86 | } 87 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.CompletionsClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Given a prompt, the model will generate a completion.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public sealed partial class CompletionsClient : global::Ollama.ICompletionsClient, global::System.IDisposable 12 | { 13 | /// 14 | /// Ollama server URL 15 | /// 16 | public const string DefaultBaseUrl = "http://localhost:11434/api"; 17 | 18 | private bool _disposeHttpClient = true; 19 | 20 | /// 21 | public global::System.Net.Http.HttpClient HttpClient { get; } 22 | 23 | /// 24 | public System.Uri? BaseUri => HttpClient.BaseAddress; 25 | 26 | /// 27 | public global::System.Collections.Generic.List Authorizations { get; } 28 | 29 | /// 30 | public bool ReadResponseAsString { get; set; } 31 | #if DEBUG 32 | = true; 33 | #endif 34 | /// 35 | /// 36 | /// 37 | public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Ollama.SourceGenerationContext.Default; 38 | 39 | 40 | /// 41 | /// Creates a new instance of the CompletionsClient. 42 | /// If no httpClient is provided, a new one will be created. 43 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 44 | /// 45 | /// The HttpClient instance. If not provided, a new one will be created. 46 | /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. 47 | /// The authorizations to use for the requests. 48 | /// Dispose the HttpClient when the instance is disposed. True by default. 49 | public CompletionsClient( 50 | global::System.Net.Http.HttpClient? httpClient = null, 51 | global::System.Uri? baseUri = null, 52 | global::System.Collections.Generic.List? authorizations = null, 53 | bool disposeHttpClient = true) 54 | { 55 | HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); 56 | HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); 57 | Authorizations = authorizations ?? new global::System.Collections.Generic.List(); 58 | _disposeHttpClient = disposeHttpClient; 59 | 60 | Initialized(HttpClient); 61 | } 62 | 63 | /// 64 | public void Dispose() 65 | { 66 | if (_disposeHttpClient) 67 | { 68 | HttpClient.Dispose(); 69 | } 70 | } 71 | 72 | partial void Initialized( 73 | global::System.Net.Http.HttpClient client); 74 | partial void PrepareArguments( 75 | global::System.Net.Http.HttpClient client); 76 | partial void PrepareRequest( 77 | global::System.Net.Http.HttpClient client, 78 | global::System.Net.Http.HttpRequestMessage request); 79 | partial void ProcessResponse( 80 | global::System.Net.Http.HttpClient client, 81 | global::System.Net.Http.HttpResponseMessage response); 82 | partial void ProcessResponseContent( 83 | global::System.Net.Http.HttpClient client, 84 | global::System.Net.Http.HttpResponseMessage response, 85 | ref string content); 86 | } 87 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.EmbeddingsClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Get a vector representation of a given input.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public sealed partial class EmbeddingsClient : global::Ollama.IEmbeddingsClient, global::System.IDisposable 12 | { 13 | /// 14 | /// Ollama server URL 15 | /// 16 | public const string DefaultBaseUrl = "http://localhost:11434/api"; 17 | 18 | private bool _disposeHttpClient = true; 19 | 20 | /// 21 | public global::System.Net.Http.HttpClient HttpClient { get; } 22 | 23 | /// 24 | public System.Uri? BaseUri => HttpClient.BaseAddress; 25 | 26 | /// 27 | public global::System.Collections.Generic.List Authorizations { get; } 28 | 29 | /// 30 | public bool ReadResponseAsString { get; set; } 31 | #if DEBUG 32 | = true; 33 | #endif 34 | /// 35 | /// 36 | /// 37 | public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Ollama.SourceGenerationContext.Default; 38 | 39 | 40 | /// 41 | /// Creates a new instance of the EmbeddingsClient. 42 | /// If no httpClient is provided, a new one will be created. 43 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 44 | /// 45 | /// The HttpClient instance. If not provided, a new one will be created. 46 | /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. 47 | /// The authorizations to use for the requests. 48 | /// Dispose the HttpClient when the instance is disposed. True by default. 49 | public EmbeddingsClient( 50 | global::System.Net.Http.HttpClient? httpClient = null, 51 | global::System.Uri? baseUri = null, 52 | global::System.Collections.Generic.List? authorizations = null, 53 | bool disposeHttpClient = true) 54 | { 55 | HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); 56 | HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); 57 | Authorizations = authorizations ?? new global::System.Collections.Generic.List(); 58 | _disposeHttpClient = disposeHttpClient; 59 | 60 | Initialized(HttpClient); 61 | } 62 | 63 | /// 64 | public void Dispose() 65 | { 66 | if (_disposeHttpClient) 67 | { 68 | HttpClient.Dispose(); 69 | } 70 | } 71 | 72 | partial void Initialized( 73 | global::System.Net.Http.HttpClient client); 74 | partial void PrepareArguments( 75 | global::System.Net.Http.HttpClient client); 76 | partial void PrepareRequest( 77 | global::System.Net.Http.HttpClient client, 78 | global::System.Net.Http.HttpRequestMessage request); 79 | partial void ProcessResponse( 80 | global::System.Net.Http.HttpClient client, 81 | global::System.Net.Http.HttpResponseMessage response); 82 | partial void ProcessResponseContent( 83 | global::System.Net.Http.HttpClient client, 84 | global::System.Net.Http.HttpResponseMessage response, 85 | ref string content); 86 | } 87 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IChatClient.GenerateChatCompletion.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IChatClient 6 | { 7 | /// 8 | /// Generate the next message in a chat with a provided model.
9 | /// This is a streaming endpoint, so there will be a series of responses. The final response object will include statistics and additional data from the request. 10 | ///
11 | /// 12 | /// The token to cancel the operation with 13 | /// 14 | global::System.Collections.Generic.IAsyncEnumerable GenerateChatCompletionAsync( 15 | global::Ollama.GenerateChatCompletionRequest request, 16 | global::System.Threading.CancellationToken cancellationToken = default); 17 | 18 | /// 19 | /// Generate the next message in a chat with a provided model.
20 | /// This is a streaming endpoint, so there will be a series of responses. The final response object will include statistics and additional data from the request. 21 | ///
22 | /// 23 | /// The model name.
24 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
25 | /// Example: llama3.2 26 | /// 27 | /// 28 | /// The messages of the chat, this can be used to keep a chat memory 29 | /// 30 | /// 31 | /// If `false` the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.
32 | /// Default Value: true 33 | /// 34 | /// 35 | /// 36 | /// How long (in minutes) to keep the model loaded in memory.
37 | /// - If set to a positive duration (e.g. 20), the model will stay loaded for the provided duration.
38 | /// - If set to a negative duration (e.g. -1), the model will stay loaded indefinitely.
39 | /// - If set to 0, the model will be unloaded immediately once finished.
40 | /// - If not set, the model will stay loaded for 5 minutes by default 41 | /// 42 | /// 43 | /// A list of tools the model may call. 44 | /// 45 | /// 46 | /// Additional model parameters listed in the documentation for the Modelfile such as `temperature`. 47 | /// 48 | /// 49 | /// Think controls whether thinking/reasoning models will think before
50 | /// responding. Needs to be a pointer so we can distinguish between false
51 | /// (request that thinking _not_ be used) and unset (use the old behavior
52 | /// before this option was introduced). 53 | /// 54 | /// The token to cancel the operation with 55 | /// 56 | global::System.Collections.Generic.IAsyncEnumerable GenerateChatCompletionAsync( 57 | string model, 58 | global::System.Collections.Generic.IList messages, 59 | bool? stream = default, 60 | global::Ollama.ResponseFormat? format = default, 61 | int? keepAlive = default, 62 | global::System.Collections.Generic.IList? tools = default, 63 | global::Ollama.RequestOptions? options = default, 64 | bool? think = default, 65 | global::System.Threading.CancellationToken cancellationToken = default); 66 | } 67 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IChatClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Given a list of messages comprising a conversation, the model will return a response.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public partial interface IChatClient : global::System.IDisposable 12 | { 13 | /// 14 | /// The HttpClient instance. 15 | /// 16 | public global::System.Net.Http.HttpClient HttpClient { get; } 17 | 18 | /// 19 | /// The base URL for the API. 20 | /// 21 | public System.Uri? BaseUri { get; } 22 | 23 | /// 24 | /// The authorizations to use for the requests. 25 | /// 26 | public global::System.Collections.Generic.List Authorizations { get; } 27 | 28 | /// 29 | /// Gets or sets a value indicating whether the response content should be read as a string. 30 | /// True by default in debug builds, false otherwise. 31 | /// 32 | public bool ReadResponseAsString { get; set; } 33 | 34 | /// 35 | /// 36 | /// 37 | global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } 38 | 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.ICompletionsClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Given a prompt, the model will generate a completion.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public partial interface ICompletionsClient : global::System.IDisposable 12 | { 13 | /// 14 | /// The HttpClient instance. 15 | /// 16 | public global::System.Net.Http.HttpClient HttpClient { get; } 17 | 18 | /// 19 | /// The base URL for the API. 20 | /// 21 | public System.Uri? BaseUri { get; } 22 | 23 | /// 24 | /// The authorizations to use for the requests. 25 | /// 26 | public global::System.Collections.Generic.List Authorizations { get; } 27 | 28 | /// 29 | /// Gets or sets a value indicating whether the response content should be read as a string. 30 | /// True by default in debug builds, false otherwise. 31 | /// 32 | public bool ReadResponseAsString { get; set; } 33 | 34 | /// 35 | /// 36 | /// 37 | global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } 38 | 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IEmbeddingsClient.GenerateEmbedding.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IEmbeddingsClient 6 | { 7 | /// 8 | /// Generate embeddings from a model. 9 | /// 10 | /// 11 | /// The token to cancel the operation with 12 | /// 13 | global::System.Threading.Tasks.Task GenerateEmbeddingAsync( 14 | global::Ollama.GenerateEmbeddingRequest request, 15 | global::System.Threading.CancellationToken cancellationToken = default); 16 | 17 | /// 18 | /// Generate embeddings from a model. 19 | /// 20 | /// 21 | /// The model name.
22 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
23 | /// Example: llama3.2 24 | /// 25 | /// 26 | /// Text to generate embeddings for.
27 | /// Example: Here is an article about llamas... 28 | /// 29 | /// 30 | /// Additional model parameters listed in the documentation for the Modelfile such as `temperature`. 31 | /// 32 | /// 33 | /// How long (in minutes) to keep the model loaded in memory.
34 | /// - If set to a positive duration (e.g. 20), the model will stay loaded for the provided duration.
35 | /// - If set to a negative duration (e.g. -1), the model will stay loaded indefinitely.
36 | /// - If set to 0, the model will be unloaded immediately once finished.
37 | /// - If not set, the model will stay loaded for 5 minutes by default 38 | /// 39 | /// The token to cancel the operation with 40 | /// 41 | global::System.Threading.Tasks.Task GenerateEmbeddingAsync( 42 | string model, 43 | string prompt, 44 | global::Ollama.RequestOptions? options = default, 45 | int? keepAlive = default, 46 | global::System.Threading.CancellationToken cancellationToken = default); 47 | } 48 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IEmbeddingsClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Get a vector representation of a given input.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public partial interface IEmbeddingsClient : global::System.IDisposable 12 | { 13 | /// 14 | /// The HttpClient instance. 15 | /// 16 | public global::System.Net.Http.HttpClient HttpClient { get; } 17 | 18 | /// 19 | /// The base URL for the API. 20 | /// 21 | public System.Uri? BaseUri { get; } 22 | 23 | /// 24 | /// The authorizations to use for the requests. 25 | /// 26 | public global::System.Collections.Generic.List Authorizations { get; } 27 | 28 | /// 29 | /// Gets or sets a value indicating whether the response content should be read as a string. 30 | /// True by default in debug builds, false otherwise. 31 | /// 32 | public bool ReadResponseAsString { get; set; } 33 | 34 | /// 35 | /// 36 | /// 37 | global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } 38 | 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.CheckBlob.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Ensures that the file blob used for a FROM or ADAPTER field exists on the server.
9 | /// This is checking your Ollama server and not Ollama.ai. 10 | ///
11 | /// 12 | /// The token to cancel the operation with 13 | /// 14 | global::System.Threading.Tasks.Task CheckBlobAsync( 15 | string digest, 16 | global::System.Threading.CancellationToken cancellationToken = default); 17 | } 18 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.CopyModel.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Creates a model with another name from an existing model. 9 | /// 10 | /// 11 | /// The token to cancel the operation with 12 | /// 13 | global::System.Threading.Tasks.Task CopyModelAsync( 14 | global::Ollama.CopyModelRequest request, 15 | global::System.Threading.CancellationToken cancellationToken = default); 16 | 17 | /// 18 | /// Creates a model with another name from an existing model. 19 | /// 20 | /// 21 | /// Name of the model to copy.
22 | /// Example: llama3.2 23 | /// 24 | /// 25 | /// Name of the new model.
26 | /// Example: llama3-backup 27 | /// 28 | /// The token to cancel the operation with 29 | /// 30 | global::System.Threading.Tasks.Task CopyModelAsync( 31 | string source, 32 | string destination, 33 | global::System.Threading.CancellationToken cancellationToken = default); 34 | } 35 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.CreateBlob.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Create a blob from a file. Returns the server file path. 9 | /// 10 | /// 11 | /// 12 | /// The token to cancel the operation with 13 | /// 14 | global::System.Threading.Tasks.Task CreateBlobAsync( 15 | string digest, 16 | byte[] request, 17 | global::System.Threading.CancellationToken cancellationToken = default); 18 | 19 | /// 20 | /// Create a blob from a file. Returns the server file path. 21 | /// 22 | /// 23 | /// The token to cancel the operation with 24 | /// 25 | global::System.Threading.Tasks.Task CreateBlobAsync( 26 | string digest, 27 | global::System.Threading.CancellationToken cancellationToken = default); 28 | } 29 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.CreateModel.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Create a model from a Modelfile.
9 | /// It is recommended to set `modelfile` to the content of the Modelfile rather than just set `path`. This is a requirement for remote create. Remote model creation should also create any file blobs, fields such as `FROM` and `ADAPTER`, explicitly with the server using Create a Blob and the value to the path indicated in the response. 10 | ///
11 | /// 12 | /// The token to cancel the operation with 13 | /// 14 | global::System.Collections.Generic.IAsyncEnumerable CreateModelAsync( 15 | global::Ollama.CreateModelRequest request, 16 | global::System.Threading.CancellationToken cancellationToken = default); 17 | 18 | /// 19 | /// Create a model from a Modelfile.
20 | /// It is recommended to set `modelfile` to the content of the Modelfile rather than just set `path`. This is a requirement for remote create. Remote model creation should also create any file blobs, fields such as `FROM` and `ADAPTER`, explicitly with the server using Create a Blob and the value to the path indicated in the response. 21 | ///
22 | /// 23 | /// The model name.
24 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
25 | /// Example: mario 26 | /// 27 | /// 28 | /// The contents of the Modelfile.
29 | /// Example: FROM llama3\nSYSTEM You are mario from Super Mario Bros. 30 | /// 31 | /// 32 | /// Path to the Modelfile (optional) 33 | /// 34 | /// 35 | /// The quantization level of the model. 36 | /// 37 | /// 38 | /// If `false` the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.
39 | /// Default Value: true 40 | /// 41 | /// The token to cancel the operation with 42 | /// 43 | global::System.Collections.Generic.IAsyncEnumerable CreateModelAsync( 44 | string model, 45 | string modelfile, 46 | string? path = default, 47 | string? quantize = default, 48 | bool? stream = default, 49 | global::System.Threading.CancellationToken cancellationToken = default); 50 | } 51 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.DeleteModel.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Delete a model and its data. 9 | /// 10 | /// 11 | /// The token to cancel the operation with 12 | /// 13 | global::System.Threading.Tasks.Task DeleteModelAsync( 14 | global::Ollama.DeleteModelRequest request, 15 | global::System.Threading.CancellationToken cancellationToken = default); 16 | 17 | /// 18 | /// Delete a model and its data. 19 | /// 20 | /// 21 | /// The model name.
22 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
23 | /// Example: llama3:13b 24 | /// 25 | /// The token to cancel the operation with 26 | /// 27 | global::System.Threading.Tasks.Task DeleteModelAsync( 28 | string model, 29 | global::System.Threading.CancellationToken cancellationToken = default); 30 | } 31 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.ListModels.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// List models that are available locally. 9 | /// 10 | /// The token to cancel the operation with 11 | /// 12 | global::System.Threading.Tasks.Task ListModelsAsync( 13 | global::System.Threading.CancellationToken cancellationToken = default); 14 | } 15 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.ListRunningModels.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// List models that are running. 9 | /// 10 | /// The token to cancel the operation with 11 | /// 12 | global::System.Threading.Tasks.Task ListRunningModelsAsync( 13 | global::System.Threading.CancellationToken cancellationToken = default); 14 | } 15 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.PullModel.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Download a model from the ollama library.
9 | /// Cancelled pulls are resumed from where they left off, and multiple calls will share the same download progress. 10 | ///
11 | /// 12 | /// The token to cancel the operation with 13 | /// 14 | global::System.Collections.Generic.IAsyncEnumerable PullModelAsync( 15 | global::Ollama.PullModelRequest request, 16 | global::System.Threading.CancellationToken cancellationToken = default); 17 | 18 | /// 19 | /// Download a model from the ollama library.
20 | /// Cancelled pulls are resumed from where they left off, and multiple calls will share the same download progress. 21 | ///
22 | /// 23 | /// The model name.
24 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
25 | /// Example: llama3.2 26 | /// 27 | /// 28 | /// Allow insecure connections to the library.
29 | /// Only use this if you are pulling from your own library during development.
30 | /// Default Value: false 31 | /// 32 | /// 33 | /// Ollama username. 34 | /// 35 | /// 36 | /// Ollama password. 37 | /// 38 | /// 39 | /// If `false` the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.
40 | /// Default Value: true 41 | /// 42 | /// The token to cancel the operation with 43 | /// 44 | global::System.Collections.Generic.IAsyncEnumerable PullModelAsync( 45 | string model, 46 | bool? insecure = default, 47 | string? username = default, 48 | string? password = default, 49 | bool? stream = default, 50 | global::System.Threading.CancellationToken cancellationToken = default); 51 | } 52 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.PushModel.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Upload a model to a model library.
9 | /// Requires registering for ollama.ai and adding a public key first. 10 | ///
11 | /// 12 | /// The token to cancel the operation with 13 | /// 14 | global::System.Collections.Generic.IAsyncEnumerable PushModelAsync( 15 | global::Ollama.PushModelRequest request, 16 | global::System.Threading.CancellationToken cancellationToken = default); 17 | 18 | /// 19 | /// Upload a model to a model library.
20 | /// Requires registering for ollama.ai and adding a public key first. 21 | ///
22 | /// 23 | /// The name of the model to push in the form of <namespace>/<model>:<tag>.
24 | /// Example: mattw/pygmalion:latest 25 | /// 26 | /// 27 | /// Allow insecure connections to the library.
28 | /// Only use this if you are pushing to your library during development.
29 | /// Default Value: false 30 | /// 31 | /// 32 | /// Ollama username. 33 | /// 34 | /// 35 | /// Ollama password. 36 | /// 37 | /// 38 | /// If `false` the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.
39 | /// Default Value: true 40 | /// 41 | /// The token to cancel the operation with 42 | /// 43 | global::System.Collections.Generic.IAsyncEnumerable PushModelAsync( 44 | string model, 45 | bool? insecure = default, 46 | string? username = default, 47 | string? password = default, 48 | bool? stream = default, 49 | global::System.Threading.CancellationToken cancellationToken = default); 50 | } 51 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.ShowModelInfo.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IModelsClient 6 | { 7 | /// 8 | /// Show details about a model including modelfile, template, parameters, license, and system prompt. 9 | /// 10 | /// 11 | /// The token to cancel the operation with 12 | /// 13 | global::System.Threading.Tasks.Task ShowModelInfoAsync( 14 | global::Ollama.ModelInfoRequest request, 15 | global::System.Threading.CancellationToken cancellationToken = default); 16 | 17 | /// 18 | /// Show details about a model including modelfile, template, parameters, license, and system prompt. 19 | /// 20 | /// 21 | /// The model name.
22 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
23 | /// Example: llama3.2 24 | /// 25 | /// The token to cancel the operation with 26 | /// 27 | global::System.Threading.Tasks.Task ShowModelInfoAsync( 28 | string model, 29 | global::System.Threading.CancellationToken cancellationToken = default); 30 | } 31 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IModelsClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// List and describe the various models available.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public partial interface IModelsClient : global::System.IDisposable 12 | { 13 | /// 14 | /// The HttpClient instance. 15 | /// 16 | public global::System.Net.Http.HttpClient HttpClient { get; } 17 | 18 | /// 19 | /// The base URL for the API. 20 | /// 21 | public System.Uri? BaseUri { get; } 22 | 23 | /// 24 | /// The authorizations to use for the requests. 25 | /// 26 | public global::System.Collections.Generic.List Authorizations { get; } 27 | 28 | /// 29 | /// Gets or sets a value indicating whether the response content should be read as a string. 30 | /// True by default in debug builds, false otherwise. 31 | /// 32 | public bool ReadResponseAsString { get; set; } 33 | 34 | /// 35 | /// 36 | /// 37 | global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } 38 | 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IOllamaApiClient.GetVersion.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama 4 | { 5 | public partial interface IOllamaApiClient 6 | { 7 | /// 8 | /// Returns the version of the Ollama server.
9 | /// This endpoint returns the version of the Ollama server. 10 | ///
11 | /// The token to cancel the operation with 12 | /// 13 | global::System.Threading.Tasks.Task GetVersionAsync( 14 | global::System.Threading.CancellationToken cancellationToken = default); 15 | } 16 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.IOllamaApiClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// API Spec for Ollama API. Please see https://github.com/jmorganca/ollama/blob/main/docs/api.md for more details.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public partial interface IOllamaApiClient : global::System.IDisposable 12 | { 13 | /// 14 | /// The HttpClient instance. 15 | /// 16 | public global::System.Net.Http.HttpClient HttpClient { get; } 17 | 18 | /// 19 | /// The base URL for the API. 20 | /// 21 | public System.Uri? BaseUri { get; } 22 | 23 | /// 24 | /// The authorizations to use for the requests. 25 | /// 26 | public global::System.Collections.Generic.List Authorizations { get; } 27 | 28 | /// 29 | /// Gets or sets a value indicating whether the response content should be read as a string. 30 | /// True by default in debug builds, false otherwise. 31 | /// 32 | public bool ReadResponseAsString { get; set; } 33 | 34 | /// 35 | /// 36 | /// 37 | global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } 38 | 39 | 40 | /// 41 | /// Given a prompt, the model will generate a completion. 42 | /// 43 | public CompletionsClient Completions { get; } 44 | 45 | /// 46 | /// Given a list of messages comprising a conversation, the model will return a response. 47 | /// 48 | public ChatClient Chat { get; } 49 | 50 | /// 51 | /// Get a vector representation of a given input. 52 | /// 53 | public EmbeddingsClient Embeddings { get; } 54 | 55 | /// 56 | /// List and describe the various models available. 57 | /// 58 | public ModelsClient Models { get; } 59 | 60 | } 61 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.Capability.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class CapabilityJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.Capability Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.CapabilityExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.Capability)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.Capability); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.Capability value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.CapabilityExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.CapabilityNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class CapabilityNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.Capability? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.CapabilityExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.Capability)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.Capability?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.Capability? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.CapabilityExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.CreateModelStatusEnum.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class CreateModelStatusEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.CreateModelStatusEnum Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.CreateModelStatusEnumExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.CreateModelStatusEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.CreateModelStatusEnum); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.CreateModelStatusEnum value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.CreateModelStatusEnumExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.CreateModelStatusEnumNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class CreateModelStatusEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.CreateModelStatusEnum? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.CreateModelStatusEnumExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.CreateModelStatusEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.CreateModelStatusEnum?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.CreateModelStatusEnum? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.CreateModelStatusEnumExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.DoneReasonEnum.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class DoneReasonEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.DoneReasonEnum Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.DoneReasonEnumExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.DoneReasonEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.DoneReasonEnum); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.DoneReasonEnum value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.DoneReasonEnumExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.DoneReasonEnumNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class DoneReasonEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.DoneReasonEnum? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.DoneReasonEnumExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.DoneReasonEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.DoneReasonEnum?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.DoneReasonEnum? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.DoneReasonEnumExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.MessageRole.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class MessageRoleJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.MessageRole Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.MessageRoleExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.MessageRole)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.MessageRole); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.MessageRole value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.MessageRoleExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.MessageRoleNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class MessageRoleNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.MessageRole? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.MessageRoleExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.MessageRole)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.MessageRole?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.MessageRole? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.MessageRoleExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.PullModelStatusEnum.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class PullModelStatusEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.PullModelStatusEnum Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.PullModelStatusEnumExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.PullModelStatusEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.PullModelStatusEnum); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.PullModelStatusEnum value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.PullModelStatusEnumExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.PullModelStatusEnumNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class PullModelStatusEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.PullModelStatusEnum? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.PullModelStatusEnumExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.PullModelStatusEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.PullModelStatusEnum?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.PullModelStatusEnum? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.PullModelStatusEnumExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.PushModelResponseStatus.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class PushModelResponseStatusJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.PushModelResponseStatus Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.PushModelResponseStatusExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.PushModelResponseStatus)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.PushModelResponseStatus); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.PushModelResponseStatus value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.PushModelResponseStatusExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.PushModelResponseStatusNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class PushModelResponseStatusNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.PushModelResponseStatus? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.PushModelResponseStatusExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.PushModelResponseStatus)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.PushModelResponseStatus?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.PushModelResponseStatus? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.PushModelResponseStatusExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.ResponseFormatEnum.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class ResponseFormatEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.ResponseFormatEnum Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.ResponseFormatEnumExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.ResponseFormatEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.ResponseFormatEnum); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.ResponseFormatEnum value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.ResponseFormatEnumExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.ResponseFormatEnumNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class ResponseFormatEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.ResponseFormatEnum? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.ResponseFormatEnumExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.ResponseFormatEnum)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.ResponseFormatEnum?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.ResponseFormatEnum? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.ResponseFormatEnumExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.ToolType.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class ToolTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.ToolType Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.ToolTypeExtensions.ToEnum(stringValue) ?? default; 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.ToolType)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.ToolType); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.ToolType value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | writer.WriteStringValue(global::Ollama.ToolTypeExtensions.ToValueString(value)); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.JsonConverters.ToolTypeNullable.g.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | namespace Ollama.JsonConverters 4 | { 5 | /// 6 | public sealed class ToolTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter 7 | { 8 | /// 9 | public override global::Ollama.ToolType? Read( 10 | ref global::System.Text.Json.Utf8JsonReader reader, 11 | global::System.Type typeToConvert, 12 | global::System.Text.Json.JsonSerializerOptions options) 13 | { 14 | switch (reader.TokenType) 15 | { 16 | case global::System.Text.Json.JsonTokenType.String: 17 | { 18 | var stringValue = reader.GetString(); 19 | if (stringValue != null) 20 | { 21 | return global::Ollama.ToolTypeExtensions.ToEnum(stringValue); 22 | } 23 | 24 | break; 25 | } 26 | case global::System.Text.Json.JsonTokenType.Number: 27 | { 28 | var numValue = reader.GetInt32(); 29 | return (global::Ollama.ToolType)numValue; 30 | } 31 | case global::System.Text.Json.JsonTokenType.Null: 32 | { 33 | return default(global::Ollama.ToolType?); 34 | } 35 | default: 36 | throw new global::System.ArgumentOutOfRangeException(nameof(reader)); 37 | } 38 | 39 | return default; 40 | } 41 | 42 | /// 43 | public override void Write( 44 | global::System.Text.Json.Utf8JsonWriter writer, 45 | global::Ollama.ToolType? value, 46 | global::System.Text.Json.JsonSerializerOptions options) 47 | { 48 | writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); 49 | 50 | if (value == null) 51 | { 52 | writer.WriteNullValue(); 53 | } 54 | else 55 | { 56 | writer.WriteStringValue(global::Ollama.ToolTypeExtensions.ToValueString(value.Value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.Capability.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Capability of a model. 8 | /// 9 | public enum Capability 10 | { 11 | /// 12 | /// 13 | /// 14 | Completion, 15 | /// 16 | /// 17 | /// 18 | Tools, 19 | /// 20 | /// 21 | /// 22 | Insert, 23 | /// 24 | /// 25 | /// 26 | Vision, 27 | /// 28 | /// 29 | /// 30 | Embedding, 31 | /// 32 | /// 33 | /// 34 | Thinking, 35 | } 36 | 37 | /// 38 | /// Enum extensions to do fast conversions without the reflection. 39 | /// 40 | public static class CapabilityExtensions 41 | { 42 | /// 43 | /// Converts an enum to a string. 44 | /// 45 | public static string ToValueString(this Capability value) 46 | { 47 | return value switch 48 | { 49 | Capability.Completion => "completion", 50 | Capability.Tools => "tools", 51 | Capability.Insert => "insert", 52 | Capability.Vision => "vision", 53 | Capability.Embedding => "embedding", 54 | Capability.Thinking => "thinking", 55 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 56 | }; 57 | } 58 | /// 59 | /// Converts an string to a enum. 60 | /// 61 | public static Capability? ToEnum(string value) 62 | { 63 | return value switch 64 | { 65 | "completion" => Capability.Completion, 66 | "tools" => Capability.Tools, 67 | "insert" => Capability.Insert, 68 | "vision" => Capability.Vision, 69 | "embedding" => Capability.Embedding, 70 | "thinking" => Capability.Thinking, 71 | _ => null, 72 | }; 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.CopyModelRequest.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Request class for copying a model. 8 | /// 9 | public sealed partial class CopyModelRequest 10 | { 11 | /// 12 | /// Name of the model to copy.
13 | /// Example: llama3.2 14 | ///
15 | /// llama3.2 16 | [global::System.Text.Json.Serialization.JsonPropertyName("source")] 17 | [global::System.Text.Json.Serialization.JsonRequired] 18 | public required string Source { get; set; } 19 | 20 | /// 21 | /// Name of the new model.
22 | /// Example: llama3-backup 23 | ///
24 | /// llama3-backup 25 | [global::System.Text.Json.Serialization.JsonPropertyName("destination")] 26 | [global::System.Text.Json.Serialization.JsonRequired] 27 | public required string Destination { get; set; } 28 | 29 | /// 30 | /// Additional properties that are not explicitly defined in the schema 31 | /// 32 | [global::System.Text.Json.Serialization.JsonExtensionData] 33 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 34 | 35 | /// 36 | /// Initializes a new instance of the class. 37 | /// 38 | /// 39 | /// Name of the model to copy.
40 | /// Example: llama3.2 41 | /// 42 | /// 43 | /// Name of the new model.
44 | /// Example: llama3-backup 45 | /// 46 | #if NET7_0_OR_GREATER 47 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 48 | #endif 49 | public CopyModelRequest( 50 | string source, 51 | string destination) 52 | { 53 | this.Source = source ?? throw new global::System.ArgumentNullException(nameof(source)); 54 | this.Destination = destination ?? throw new global::System.ArgumentNullException(nameof(destination)); 55 | } 56 | 57 | /// 58 | /// Initializes a new instance of the class. 59 | /// 60 | public CopyModelRequest() 61 | { 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.CreateModelResponse.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Response object for creating a model. When finished, `status` is `success`. 8 | /// 9 | public sealed partial class CreateModelResponse 10 | { 11 | /// 12 | /// Status creating the model 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("status")] 15 | [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ollama.JsonConverters.CreateModelStatusJsonConverter))] 16 | public global::Ollama.CreateModelStatus? Status { get; set; } 17 | 18 | /// 19 | /// Additional properties that are not explicitly defined in the schema 20 | /// 21 | [global::System.Text.Json.Serialization.JsonExtensionData] 22 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | /// 28 | /// Status creating the model 29 | /// 30 | #if NET7_0_OR_GREATER 31 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 32 | #endif 33 | public CreateModelResponse( 34 | global::Ollama.CreateModelStatus? status) 35 | { 36 | this.Status = status; 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | public CreateModelResponse() 43 | { 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.CreateModelStatusEnum.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// 8 | /// 9 | public enum CreateModelStatusEnum 10 | { 11 | /// 12 | /// 13 | /// 14 | CreatingSystemLayer, 15 | /// 16 | /// 17 | /// 18 | ParsingModelfile, 19 | /// 20 | /// 21 | /// 22 | Success, 23 | } 24 | 25 | /// 26 | /// Enum extensions to do fast conversions without the reflection. 27 | /// 28 | public static class CreateModelStatusEnumExtensions 29 | { 30 | /// 31 | /// Converts an enum to a string. 32 | /// 33 | public static string ToValueString(this CreateModelStatusEnum value) 34 | { 35 | return value switch 36 | { 37 | CreateModelStatusEnum.CreatingSystemLayer => "creating system layer", 38 | CreateModelStatusEnum.ParsingModelfile => "parsing modelfile", 39 | CreateModelStatusEnum.Success => "success", 40 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 41 | }; 42 | } 43 | /// 44 | /// Converts an string to a enum. 45 | /// 46 | public static CreateModelStatusEnum? ToEnum(string value) 47 | { 48 | return value switch 49 | { 50 | "creating system layer" => CreateModelStatusEnum.CreatingSystemLayer, 51 | "parsing modelfile" => CreateModelStatusEnum.ParsingModelfile, 52 | "success" => CreateModelStatusEnum.Success, 53 | _ => null, 54 | }; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.DeleteModelRequest.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Request class for deleting a model. 8 | /// 9 | public sealed partial class DeleteModelRequest 10 | { 11 | /// 12 | /// The model name.
13 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
14 | /// Example: llama3:13b 15 | ///
16 | /// llama3:13b 17 | [global::System.Text.Json.Serialization.JsonPropertyName("model")] 18 | [global::System.Text.Json.Serialization.JsonRequired] 19 | public required string Model { get; set; } 20 | 21 | /// 22 | /// Additional properties that are not explicitly defined in the schema 23 | /// 24 | [global::System.Text.Json.Serialization.JsonExtensionData] 25 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 26 | 27 | /// 28 | /// Initializes a new instance of the class. 29 | /// 30 | /// 31 | /// The model name.
32 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
33 | /// Example: llama3:13b 34 | /// 35 | #if NET7_0_OR_GREATER 36 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 37 | #endif 38 | public DeleteModelRequest( 39 | string model) 40 | { 41 | this.Model = model ?? throw new global::System.ArgumentNullException(nameof(model)); 42 | } 43 | 44 | /// 45 | /// Initializes a new instance of the class. 46 | /// 47 | public DeleteModelRequest() 48 | { 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.DoneReasonEnum.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// 8 | /// 9 | public enum DoneReasonEnum 10 | { 11 | /// 12 | /// 13 | /// 14 | Stop, 15 | /// 16 | /// 17 | /// 18 | Length, 19 | /// 20 | /// 21 | /// 22 | Load, 23 | } 24 | 25 | /// 26 | /// Enum extensions to do fast conversions without the reflection. 27 | /// 28 | public static class DoneReasonEnumExtensions 29 | { 30 | /// 31 | /// Converts an enum to a string. 32 | /// 33 | public static string ToValueString(this DoneReasonEnum value) 34 | { 35 | return value switch 36 | { 37 | DoneReasonEnum.Stop => "stop", 38 | DoneReasonEnum.Length => "length", 39 | DoneReasonEnum.Load => "load", 40 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 41 | }; 42 | } 43 | /// 44 | /// Converts an string to a enum. 45 | /// 46 | public static DoneReasonEnum? ToEnum(string value) 47 | { 48 | return value switch 49 | { 50 | "stop" => DoneReasonEnum.Stop, 51 | "length" => DoneReasonEnum.Length, 52 | "load" => DoneReasonEnum.Load, 53 | _ => null, 54 | }; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.GenerateEmbeddingResponse.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Returns the embedding information. 8 | /// 9 | public sealed partial class GenerateEmbeddingResponse 10 | { 11 | /// 12 | /// The embedding for the prompt.
13 | /// Example: [0.5670403838157654, 0.009260174818336964, ...] 14 | ///
15 | /// [0.5670403838157654, 0.009260174818336964, ...] 16 | [global::System.Text.Json.Serialization.JsonPropertyName("embedding")] 17 | public global::System.Collections.Generic.IList? Embedding { get; set; } 18 | 19 | /// 20 | /// Additional properties that are not explicitly defined in the schema 21 | /// 22 | [global::System.Text.Json.Serialization.JsonExtensionData] 23 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 24 | 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// 29 | /// The embedding for the prompt.
30 | /// Example: [0.5670403838157654, 0.009260174818336964, ...] 31 | /// 32 | #if NET7_0_OR_GREATER 33 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 34 | #endif 35 | public GenerateEmbeddingResponse( 36 | global::System.Collections.Generic.IList? embedding) 37 | { 38 | this.Embedding = embedding; 39 | } 40 | 41 | /// 42 | /// Initializes a new instance of the class. 43 | /// 44 | public GenerateEmbeddingResponse() 45 | { 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.Message.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// A message in the chat endpoint 8 | /// 9 | public sealed partial class Message 10 | { 11 | /// 12 | /// The role of the message 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("role")] 15 | [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ollama.JsonConverters.MessageRoleJsonConverter))] 16 | [global::System.Text.Json.Serialization.JsonRequired] 17 | public required global::Ollama.MessageRole Role { get; set; } 18 | 19 | /// 20 | /// The content of the message
21 | /// Example: Why is the sky blue? 22 | ///
23 | /// Why is the sky blue? 24 | [global::System.Text.Json.Serialization.JsonPropertyName("content")] 25 | [global::System.Text.Json.Serialization.JsonRequired] 26 | public required string Content { get; set; } 27 | 28 | /// 29 | /// Contains the text that was inside thinking tags in the original model output when `think` is enabled. 30 | /// 31 | [global::System.Text.Json.Serialization.JsonPropertyName("thinking")] 32 | public string? Thinking { get; set; } 33 | 34 | /// 35 | /// (optional) a list of Base64-encoded images to include in the message (for multimodal models such as llava) 36 | /// 37 | [global::System.Text.Json.Serialization.JsonPropertyName("images")] 38 | public global::System.Collections.Generic.IList? Images { get; set; } 39 | 40 | /// 41 | /// A list of tools the model wants to call. 42 | /// 43 | [global::System.Text.Json.Serialization.JsonPropertyName("tool_calls")] 44 | public global::System.Collections.Generic.IList? ToolCalls { get; set; } 45 | 46 | /// 47 | /// Additional properties that are not explicitly defined in the schema 48 | /// 49 | [global::System.Text.Json.Serialization.JsonExtensionData] 50 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 51 | 52 | /// 53 | /// Initializes a new instance of the class. 54 | /// 55 | /// 56 | /// The role of the message 57 | /// 58 | /// 59 | /// The content of the message
60 | /// Example: Why is the sky blue? 61 | /// 62 | /// 63 | /// Contains the text that was inside thinking tags in the original model output when `think` is enabled. 64 | /// 65 | /// 66 | /// (optional) a list of Base64-encoded images to include in the message (for multimodal models such as llava) 67 | /// 68 | /// 69 | /// A list of tools the model wants to call. 70 | /// 71 | #if NET7_0_OR_GREATER 72 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 73 | #endif 74 | public Message( 75 | global::Ollama.MessageRole role, 76 | string content, 77 | string? thinking, 78 | global::System.Collections.Generic.IList? images, 79 | global::System.Collections.Generic.IList? toolCalls) 80 | { 81 | this.Role = role; 82 | this.Content = content ?? throw new global::System.ArgumentNullException(nameof(content)); 83 | this.Thinking = thinking; 84 | this.Images = images; 85 | this.ToolCalls = toolCalls; 86 | } 87 | 88 | /// 89 | /// Initializes a new instance of the class. 90 | /// 91 | public Message() 92 | { 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.MessageRole.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// The role of the message 8 | /// 9 | public enum MessageRole 10 | { 11 | /// 12 | /// 13 | /// 14 | System, 15 | /// 16 | /// 17 | /// 18 | User, 19 | /// 20 | /// 21 | /// 22 | Assistant, 23 | /// 24 | /// 25 | /// 26 | Tool, 27 | } 28 | 29 | /// 30 | /// Enum extensions to do fast conversions without the reflection. 31 | /// 32 | public static class MessageRoleExtensions 33 | { 34 | /// 35 | /// Converts an enum to a string. 36 | /// 37 | public static string ToValueString(this MessageRole value) 38 | { 39 | return value switch 40 | { 41 | MessageRole.System => "system", 42 | MessageRole.User => "user", 43 | MessageRole.Assistant => "assistant", 44 | MessageRole.Tool => "tool", 45 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 46 | }; 47 | } 48 | /// 49 | /// Converts an string to a enum. 50 | /// 51 | public static MessageRole? ToEnum(string value) 52 | { 53 | return value switch 54 | { 55 | "system" => MessageRole.System, 56 | "user" => MessageRole.User, 57 | "assistant" => MessageRole.Assistant, 58 | "tool" => MessageRole.Tool, 59 | _ => null, 60 | }; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.Model.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// A model available locally. 8 | /// 9 | public sealed partial class Model 10 | { 11 | /// 12 | /// The model name.
13 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
14 | /// Example: llama3.2 15 | ///
16 | /// llama3.2 17 | [global::System.Text.Json.Serialization.JsonPropertyName("model")] 18 | public string? Model1 { get; set; } 19 | 20 | /// 21 | /// Model modification date. 22 | /// 23 | [global::System.Text.Json.Serialization.JsonPropertyName("modified_at")] 24 | public global::System.DateTime? ModifiedAt { get; set; } 25 | 26 | /// 27 | /// Size of the model on disk.
28 | /// Example: 7323310500L 29 | ///
30 | /// 7323310500L 31 | [global::System.Text.Json.Serialization.JsonPropertyName("size")] 32 | public long? Size { get; set; } 33 | 34 | /// 35 | /// The model's digest.
36 | /// Example: sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 37 | ///
38 | /// sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 39 | [global::System.Text.Json.Serialization.JsonPropertyName("digest")] 40 | public string? Digest { get; set; } 41 | 42 | /// 43 | /// Details about a model. 44 | /// 45 | [global::System.Text.Json.Serialization.JsonPropertyName("details")] 46 | public global::Ollama.ModelDetails? Details { get; set; } 47 | 48 | /// 49 | /// Additional properties that are not explicitly defined in the schema 50 | /// 51 | [global::System.Text.Json.Serialization.JsonExtensionData] 52 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 53 | 54 | /// 55 | /// Initializes a new instance of the class. 56 | /// 57 | /// 58 | /// The model name.
59 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
60 | /// Example: llama3.2 61 | /// 62 | /// 63 | /// Model modification date. 64 | /// 65 | /// 66 | /// Size of the model on disk.
67 | /// Example: 7323310500L 68 | /// 69 | /// 70 | /// The model's digest.
71 | /// Example: sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 72 | /// 73 | /// 74 | /// Details about a model. 75 | /// 76 | #if NET7_0_OR_GREATER 77 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 78 | #endif 79 | public Model( 80 | string? model1, 81 | global::System.DateTime? modifiedAt, 82 | long? size, 83 | string? digest, 84 | global::Ollama.ModelDetails? details) 85 | { 86 | this.Model1 = model1; 87 | this.ModifiedAt = modifiedAt; 88 | this.Size = size; 89 | this.Digest = digest; 90 | this.Details = details; 91 | } 92 | 93 | /// 94 | /// Initializes a new instance of the class. 95 | /// 96 | public Model() 97 | { 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ModelDetails.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Details about a model. 8 | /// 9 | public sealed partial class ModelDetails 10 | { 11 | /// 12 | /// The parent model of the model. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("parent_model")] 15 | public string? ParentModel { get; set; } 16 | 17 | /// 18 | /// The format of the model. 19 | /// 20 | [global::System.Text.Json.Serialization.JsonPropertyName("format")] 21 | public string? Format { get; set; } 22 | 23 | /// 24 | /// The family of the model. 25 | /// 26 | [global::System.Text.Json.Serialization.JsonPropertyName("family")] 27 | public string? Family { get; set; } 28 | 29 | /// 30 | /// The families of the model. 31 | /// 32 | [global::System.Text.Json.Serialization.JsonPropertyName("families")] 33 | public global::System.Collections.Generic.IList? Families { get; set; } 34 | 35 | /// 36 | /// The size of the model's parameters. 37 | /// 38 | [global::System.Text.Json.Serialization.JsonPropertyName("parameter_size")] 39 | public string? ParameterSize { get; set; } 40 | 41 | /// 42 | /// The quantization level of the model. 43 | /// 44 | [global::System.Text.Json.Serialization.JsonPropertyName("quantization_level")] 45 | public string? QuantizationLevel { get; set; } 46 | 47 | /// 48 | /// Additional properties that are not explicitly defined in the schema 49 | /// 50 | [global::System.Text.Json.Serialization.JsonExtensionData] 51 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 52 | 53 | /// 54 | /// Initializes a new instance of the class. 55 | /// 56 | /// 57 | /// The parent model of the model. 58 | /// 59 | /// 60 | /// The format of the model. 61 | /// 62 | /// 63 | /// The family of the model. 64 | /// 65 | /// 66 | /// The families of the model. 67 | /// 68 | /// 69 | /// The size of the model's parameters. 70 | /// 71 | /// 72 | /// The quantization level of the model. 73 | /// 74 | #if NET7_0_OR_GREATER 75 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 76 | #endif 77 | public ModelDetails( 78 | string? parentModel, 79 | string? format, 80 | string? family, 81 | global::System.Collections.Generic.IList? families, 82 | string? parameterSize, 83 | string? quantizationLevel) 84 | { 85 | this.ParentModel = parentModel; 86 | this.Format = format; 87 | this.Family = family; 88 | this.Families = families; 89 | this.ParameterSize = parameterSize; 90 | this.QuantizationLevel = quantizationLevel; 91 | } 92 | 93 | /// 94 | /// Initializes a new instance of the class. 95 | /// 96 | public ModelDetails() 97 | { 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ModelInfoProjectorInfo.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Projector info. 8 | /// 9 | public sealed partial class ModelInfoProjectorInfo 10 | { 11 | 12 | /// 13 | /// Additional properties that are not explicitly defined in the schema 14 | /// 15 | [global::System.Text.Json.Serialization.JsonExtensionData] 16 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ModelInfoRequest.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Request class for the show model info endpoint. 8 | /// 9 | public sealed partial class ModelInfoRequest 10 | { 11 | /// 12 | /// The model name.
13 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
14 | /// Example: llama3.2 15 | ///
16 | /// llama3.2 17 | [global::System.Text.Json.Serialization.JsonPropertyName("model")] 18 | [global::System.Text.Json.Serialization.JsonRequired] 19 | public required string Model { get; set; } 20 | 21 | /// 22 | /// Additional properties that are not explicitly defined in the schema 23 | /// 24 | [global::System.Text.Json.Serialization.JsonExtensionData] 25 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 26 | 27 | /// 28 | /// Initializes a new instance of the class. 29 | /// 30 | /// 31 | /// The model name.
32 | /// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.
33 | /// Example: llama3.2 34 | /// 35 | #if NET7_0_OR_GREATER 36 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 37 | #endif 38 | public ModelInfoRequest( 39 | string model) 40 | { 41 | this.Model = model ?? throw new global::System.ArgumentNullException(nameof(model)); 42 | } 43 | 44 | /// 45 | /// Initializes a new instance of the class. 46 | /// 47 | public ModelInfoRequest() 48 | { 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ModelInformation.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Details about a model. 8 | /// 9 | public sealed partial class ModelInformation 10 | { 11 | /// 12 | /// The architecture of the model. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("general.architecture")] 15 | public string? GeneralArchitecture { get; set; } 16 | 17 | /// 18 | /// The file type of the model. 19 | /// 20 | [global::System.Text.Json.Serialization.JsonPropertyName("general.file_type")] 21 | public int? GeneralFileType { get; set; } 22 | 23 | /// 24 | /// The number of parameters in the model. 25 | /// 26 | [global::System.Text.Json.Serialization.JsonPropertyName("general.parameter_count")] 27 | public long? GeneralParameterCount { get; set; } 28 | 29 | /// 30 | /// The number of parameters in the model. 31 | /// 32 | [global::System.Text.Json.Serialization.JsonPropertyName("general.quantization_version")] 33 | public int? GeneralQuantizationVersion { get; set; } 34 | 35 | /// 36 | /// Additional properties that are not explicitly defined in the schema 37 | /// 38 | [global::System.Text.Json.Serialization.JsonExtensionData] 39 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 40 | 41 | /// 42 | /// Initializes a new instance of the class. 43 | /// 44 | /// 45 | /// The architecture of the model. 46 | /// 47 | /// 48 | /// The file type of the model. 49 | /// 50 | /// 51 | /// The number of parameters in the model. 52 | /// 53 | /// 54 | /// The number of parameters in the model. 55 | /// 56 | #if NET7_0_OR_GREATER 57 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 58 | #endif 59 | public ModelInformation( 60 | string? generalArchitecture, 61 | int? generalFileType, 62 | long? generalParameterCount, 63 | int? generalQuantizationVersion) 64 | { 65 | this.GeneralArchitecture = generalArchitecture; 66 | this.GeneralFileType = generalFileType; 67 | this.GeneralParameterCount = generalParameterCount; 68 | this.GeneralQuantizationVersion = generalQuantizationVersion; 69 | } 70 | 71 | /// 72 | /// Initializes a new instance of the class. 73 | /// 74 | public ModelInformation() 75 | { 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ModelsResponse.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Response class for the list models endpoint. 8 | /// 9 | public sealed partial class ModelsResponse 10 | { 11 | /// 12 | /// List of models available locally. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("models")] 15 | public global::System.Collections.Generic.IList? Models { get; set; } 16 | 17 | /// 18 | /// Additional properties that are not explicitly defined in the schema 19 | /// 20 | [global::System.Text.Json.Serialization.JsonExtensionData] 21 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// 27 | /// List of models available locally. 28 | /// 29 | #if NET7_0_OR_GREATER 30 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 31 | #endif 32 | public ModelsResponse( 33 | global::System.Collections.Generic.IList? models) 34 | { 35 | this.Models = models; 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of the class. 40 | /// 41 | public ModelsResponse() 42 | { 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ProcessResponse.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Response class for the list running models endpoint. 8 | /// 9 | public sealed partial class ProcessResponse 10 | { 11 | /// 12 | /// List of running models. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("models")] 15 | public global::System.Collections.Generic.IList? Models { get; set; } 16 | 17 | /// 18 | /// Additional properties that are not explicitly defined in the schema 19 | /// 20 | [global::System.Text.Json.Serialization.JsonExtensionData] 21 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// 27 | /// List of running models. 28 | /// 29 | #if NET7_0_OR_GREATER 30 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 31 | #endif 32 | public ProcessResponse( 33 | global::System.Collections.Generic.IList? models) 34 | { 35 | this.Models = models; 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of the class. 40 | /// 41 | public ProcessResponse() 42 | { 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.PullModelResponse.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Response class for pulling a model.
8 | /// The first object is the manifest. Then there is a series of downloading responses. Until any of the download is completed, the `completed` key may not be included.
9 | /// The number of files to be downloaded depends on the number of layers specified in the manifest. 10 | ///
11 | public sealed partial class PullModelResponse 12 | { 13 | /// 14 | /// Status pulling the model.
15 | /// Example: pulling manifest 16 | ///
17 | /// pulling manifest 18 | [global::System.Text.Json.Serialization.JsonPropertyName("status")] 19 | [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ollama.JsonConverters.PullModelStatusJsonConverter))] 20 | public global::Ollama.PullModelStatus? Status { get; set; } 21 | 22 | /// 23 | /// The model's digest.
24 | /// Example: sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 25 | ///
26 | /// sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 27 | [global::System.Text.Json.Serialization.JsonPropertyName("digest")] 28 | public string? Digest { get; set; } 29 | 30 | /// 31 | /// Total size of the model.
32 | /// Example: 2142590208L 33 | ///
34 | /// 2142590208L 35 | [global::System.Text.Json.Serialization.JsonPropertyName("total")] 36 | public long? Total { get; set; } 37 | 38 | /// 39 | /// Total bytes transferred.
40 | /// Example: 2142590208L 41 | ///
42 | /// 2142590208L 43 | [global::System.Text.Json.Serialization.JsonPropertyName("completed")] 44 | public long? Completed { get; set; } 45 | 46 | /// 47 | /// Additional properties that are not explicitly defined in the schema 48 | /// 49 | [global::System.Text.Json.Serialization.JsonExtensionData] 50 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 51 | 52 | /// 53 | /// Initializes a new instance of the class. 54 | /// 55 | /// 56 | /// Status pulling the model.
57 | /// Example: pulling manifest 58 | /// 59 | /// 60 | /// The model's digest.
61 | /// Example: sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 62 | /// 63 | /// 64 | /// Total size of the model.
65 | /// Example: 2142590208L 66 | /// 67 | /// 68 | /// Total bytes transferred.
69 | /// Example: 2142590208L 70 | /// 71 | #if NET7_0_OR_GREATER 72 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 73 | #endif 74 | public PullModelResponse( 75 | global::Ollama.PullModelStatus? status, 76 | string? digest, 77 | long? total, 78 | long? completed) 79 | { 80 | this.Status = status; 81 | this.Digest = digest; 82 | this.Total = total; 83 | this.Completed = completed; 84 | } 85 | 86 | /// 87 | /// Initializes a new instance of the class. 88 | /// 89 | public PullModelResponse() 90 | { 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.PullModelStatusEnum.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// 8 | /// 9 | public enum PullModelStatusEnum 10 | { 11 | /// 12 | /// 13 | /// 14 | PullingManifest, 15 | /// 16 | /// 17 | /// 18 | DownloadingDigestname, 19 | /// 20 | /// 21 | /// 22 | VerifyingSha256Digest, 23 | /// 24 | /// 25 | /// 26 | WritingManifest, 27 | /// 28 | /// 29 | /// 30 | RemovingAnyUnusedLayers, 31 | /// 32 | /// 33 | /// 34 | Success, 35 | } 36 | 37 | /// 38 | /// Enum extensions to do fast conversions without the reflection. 39 | /// 40 | public static class PullModelStatusEnumExtensions 41 | { 42 | /// 43 | /// Converts an enum to a string. 44 | /// 45 | public static string ToValueString(this PullModelStatusEnum value) 46 | { 47 | return value switch 48 | { 49 | PullModelStatusEnum.PullingManifest => "pulling manifest", 50 | PullModelStatusEnum.DownloadingDigestname => "downloading digestname", 51 | PullModelStatusEnum.VerifyingSha256Digest => "verifying sha256 digest", 52 | PullModelStatusEnum.WritingManifest => "writing manifest", 53 | PullModelStatusEnum.RemovingAnyUnusedLayers => "removing any unused layers", 54 | PullModelStatusEnum.Success => "success", 55 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 56 | }; 57 | } 58 | /// 59 | /// Converts an string to a enum. 60 | /// 61 | public static PullModelStatusEnum? ToEnum(string value) 62 | { 63 | return value switch 64 | { 65 | "pulling manifest" => PullModelStatusEnum.PullingManifest, 66 | "downloading digestname" => PullModelStatusEnum.DownloadingDigestname, 67 | "verifying sha256 digest" => PullModelStatusEnum.VerifyingSha256Digest, 68 | "writing manifest" => PullModelStatusEnum.WritingManifest, 69 | "removing any unused layers" => PullModelStatusEnum.RemovingAnyUnusedLayers, 70 | "success" => PullModelStatusEnum.Success, 71 | _ => null, 72 | }; 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.PushModelRequest.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Request class for pushing a model. 8 | /// 9 | public sealed partial class PushModelRequest 10 | { 11 | /// 12 | /// The name of the model to push in the form of <namespace>/<model>:<tag>.
13 | /// Example: mattw/pygmalion:latest 14 | ///
15 | /// mattw/pygmalion:latest 16 | [global::System.Text.Json.Serialization.JsonPropertyName("model")] 17 | [global::System.Text.Json.Serialization.JsonRequired] 18 | public required string Model { get; set; } 19 | 20 | /// 21 | /// Allow insecure connections to the library.
22 | /// Only use this if you are pushing to your library during development.
23 | /// Default Value: false 24 | ///
25 | [global::System.Text.Json.Serialization.JsonPropertyName("insecure")] 26 | public bool? Insecure { get; set; } 27 | 28 | /// 29 | /// Ollama username. 30 | /// 31 | [global::System.Text.Json.Serialization.JsonPropertyName("username")] 32 | public string? Username { get; set; } 33 | 34 | /// 35 | /// Ollama password. 36 | /// 37 | [global::System.Text.Json.Serialization.JsonPropertyName("password")] 38 | public string? Password { get; set; } 39 | 40 | /// 41 | /// If `false` the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.
42 | /// Default Value: true 43 | ///
44 | [global::System.Text.Json.Serialization.JsonPropertyName("stream")] 45 | public bool? Stream { get; set; } 46 | 47 | /// 48 | /// Additional properties that are not explicitly defined in the schema 49 | /// 50 | [global::System.Text.Json.Serialization.JsonExtensionData] 51 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 52 | 53 | /// 54 | /// Initializes a new instance of the class. 55 | /// 56 | /// 57 | /// The name of the model to push in the form of <namespace>/<model>:<tag>.
58 | /// Example: mattw/pygmalion:latest 59 | /// 60 | /// 61 | /// Allow insecure connections to the library.
62 | /// Only use this if you are pushing to your library during development.
63 | /// Default Value: false 64 | /// 65 | /// 66 | /// Ollama username. 67 | /// 68 | /// 69 | /// Ollama password. 70 | /// 71 | /// 72 | /// If `false` the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.
73 | /// Default Value: true 74 | /// 75 | #if NET7_0_OR_GREATER 76 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 77 | #endif 78 | public PushModelRequest( 79 | string model, 80 | bool? insecure, 81 | string? username, 82 | string? password, 83 | bool? stream) 84 | { 85 | this.Model = model ?? throw new global::System.ArgumentNullException(nameof(model)); 86 | this.Insecure = insecure; 87 | this.Username = username; 88 | this.Password = password; 89 | this.Stream = stream; 90 | } 91 | 92 | /// 93 | /// Initializes a new instance of the class. 94 | /// 95 | public PushModelRequest() 96 | { 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.PushModelResponse.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #pragma warning disable CS0618 // Type or member is obsolete 3 | 4 | #nullable enable 5 | 6 | namespace Ollama 7 | { 8 | /// 9 | /// Response class for pushing a model. 10 | /// 11 | public sealed partial class PushModelResponse 12 | { 13 | /// 14 | /// Status pushing the model. 15 | /// 16 | [global::System.Text.Json.Serialization.JsonPropertyName("status")] 17 | [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ollama.JsonConverters.AnyOfJsonConverter))] 18 | public global::Ollama.AnyOf? Status { get; set; } 19 | 20 | /// 21 | /// the model's digest
22 | /// Example: sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 23 | ///
24 | /// sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 25 | [global::System.Text.Json.Serialization.JsonPropertyName("digest")] 26 | public string? Digest { get; set; } 27 | 28 | /// 29 | /// total size of the model
30 | /// Example: 2142590208L 31 | ///
32 | /// 2142590208L 33 | [global::System.Text.Json.Serialization.JsonPropertyName("total")] 34 | public long? Total { get; set; } 35 | 36 | /// 37 | /// Total bytes transferred.
38 | /// Example: 2142590208L 39 | ///
40 | /// 2142590208L 41 | [global::System.Text.Json.Serialization.JsonPropertyName("completed")] 42 | public long? Completed { get; set; } 43 | 44 | /// 45 | /// Additional properties that are not explicitly defined in the schema 46 | /// 47 | [global::System.Text.Json.Serialization.JsonExtensionData] 48 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 49 | 50 | /// 51 | /// Initializes a new instance of the class. 52 | /// 53 | /// 54 | /// Status pushing the model. 55 | /// 56 | /// 57 | /// the model's digest
58 | /// Example: sha256:bc07c81de745696fdf5afca05e065818a8149fb0c77266fb584d9b2cba3711a 59 | /// 60 | /// 61 | /// total size of the model
62 | /// Example: 2142590208L 63 | /// 64 | /// 65 | /// Total bytes transferred.
66 | /// Example: 2142590208L 67 | /// 68 | #if NET7_0_OR_GREATER 69 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 70 | #endif 71 | public PushModelResponse( 72 | global::Ollama.AnyOf? status, 73 | string? digest, 74 | long? total, 75 | long? completed) 76 | { 77 | this.Status = status; 78 | this.Digest = digest; 79 | this.Total = total; 80 | this.Completed = completed; 81 | } 82 | 83 | /// 84 | /// Initializes a new instance of the class. 85 | /// 86 | public PushModelResponse() 87 | { 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.PushModelResponseStatus.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// 8 | /// 9 | public enum PushModelResponseStatus 10 | { 11 | /// 12 | /// 13 | /// 14 | RetrievingManifest, 15 | /// 16 | /// 17 | /// 18 | StartingUpload, 19 | /// 20 | /// 21 | /// 22 | PushingManifest, 23 | /// 24 | /// 25 | /// 26 | Success, 27 | } 28 | 29 | /// 30 | /// Enum extensions to do fast conversions without the reflection. 31 | /// 32 | public static class PushModelResponseStatusExtensions 33 | { 34 | /// 35 | /// Converts an enum to a string. 36 | /// 37 | public static string ToValueString(this PushModelResponseStatus value) 38 | { 39 | return value switch 40 | { 41 | PushModelResponseStatus.RetrievingManifest => "retrieving manifest", 42 | PushModelResponseStatus.StartingUpload => "starting upload", 43 | PushModelResponseStatus.PushingManifest => "pushing manifest", 44 | PushModelResponseStatus.Success => "success", 45 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 46 | }; 47 | } 48 | /// 49 | /// Converts an string to a enum. 50 | /// 51 | public static PushModelResponseStatus? ToEnum(string value) 52 | { 53 | return value switch 54 | { 55 | "retrieving manifest" => PushModelResponseStatus.RetrievingManifest, 56 | "starting upload" => PushModelResponseStatus.StartingUpload, 57 | "pushing manifest" => PushModelResponseStatus.PushingManifest, 58 | "success" => PushModelResponseStatus.Success, 59 | _ => null, 60 | }; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ResponseFormatEnum.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Enable JSON mode by setting the format parameter to 'json'. This will structure the response as valid JSON. 8 | /// 9 | public enum ResponseFormatEnum 10 | { 11 | /// 12 | /// 13 | /// 14 | Json, 15 | } 16 | 17 | /// 18 | /// Enum extensions to do fast conversions without the reflection. 19 | /// 20 | public static class ResponseFormatEnumExtensions 21 | { 22 | /// 23 | /// Converts an enum to a string. 24 | /// 25 | public static string ToValueString(this ResponseFormatEnum value) 26 | { 27 | return value switch 28 | { 29 | ResponseFormatEnum.Json => "json", 30 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 31 | }; 32 | } 33 | /// 34 | /// Converts an string to a enum. 35 | /// 36 | public static ResponseFormatEnum? ToEnum(string value) 37 | { 38 | return value switch 39 | { 40 | "json" => ResponseFormatEnum.Json, 41 | _ => null, 42 | }; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ResponseFormatEnum2.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// A JSON Schema object that defines the structure of the response. The model will generate a response that matches this schema. 8 | /// 9 | public sealed partial class ResponseFormatEnum2 10 | { 11 | 12 | /// 13 | /// Additional properties that are not explicitly defined in the schema 14 | /// 15 | [global::System.Text.Json.Serialization.JsonExtensionData] 16 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.Tensor.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// Metadata for a given tensor. 8 | /// 9 | public sealed partial class Tensor 10 | { 11 | /// 12 | /// The name of the tensor. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("name")] 15 | public string? Name { get; set; } 16 | 17 | /// 18 | /// The type of the tensor. 19 | /// 20 | [global::System.Text.Json.Serialization.JsonPropertyName("type")] 21 | public string? Type { get; set; } 22 | 23 | /// 24 | /// The shape of the tensor. 25 | /// 26 | [global::System.Text.Json.Serialization.JsonPropertyName("shape")] 27 | public global::System.Collections.Generic.IList? Shape { get; set; } 28 | 29 | /// 30 | /// Additional properties that are not explicitly defined in the schema 31 | /// 32 | [global::System.Text.Json.Serialization.JsonExtensionData] 33 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 34 | 35 | /// 36 | /// Initializes a new instance of the class. 37 | /// 38 | /// 39 | /// The name of the tensor. 40 | /// 41 | /// 42 | /// The type of the tensor. 43 | /// 44 | /// 45 | /// The shape of the tensor. 46 | /// 47 | #if NET7_0_OR_GREATER 48 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 49 | #endif 50 | public Tensor( 51 | string? name, 52 | string? type, 53 | global::System.Collections.Generic.IList? shape) 54 | { 55 | this.Name = name; 56 | this.Type = type; 57 | this.Shape = shape; 58 | } 59 | 60 | /// 61 | /// Initializes a new instance of the class. 62 | /// 63 | public Tensor() 64 | { 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.Tool.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// A tool the model may call. 8 | /// 9 | public sealed partial class Tool 10 | { 11 | /// 12 | /// The type of tool.
13 | /// Default Value: function 14 | ///
15 | [global::System.Text.Json.Serialization.JsonPropertyName("type")] 16 | [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ollama.JsonConverters.ToolTypeJsonConverter))] 17 | public global::Ollama.ToolType? Type { get; set; } 18 | 19 | /// 20 | /// A function that the model may call. 21 | /// 22 | [global::System.Text.Json.Serialization.JsonPropertyName("function")] 23 | public global::Ollama.ToolFunction? Function { get; set; } 24 | 25 | /// 26 | /// Additional properties that are not explicitly defined in the schema 27 | /// 28 | [global::System.Text.Json.Serialization.JsonExtensionData] 29 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// 35 | /// The type of tool.
36 | /// Default Value: function 37 | /// 38 | /// 39 | /// A function that the model may call. 40 | /// 41 | #if NET7_0_OR_GREATER 42 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 43 | #endif 44 | public Tool( 45 | global::Ollama.ToolType? type, 46 | global::Ollama.ToolFunction? function) 47 | { 48 | this.Type = type; 49 | this.Function = function; 50 | } 51 | 52 | /// 53 | /// Initializes a new instance of the class. 54 | /// 55 | public Tool() 56 | { 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ToolCall.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// The tool the model wants to call. 8 | /// 9 | public sealed partial class ToolCall 10 | { 11 | /// 12 | /// The function the model wants to call. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("function")] 15 | public global::Ollama.ToolCallFunction? Function { get; set; } 16 | 17 | /// 18 | /// Additional properties that are not explicitly defined in the schema 19 | /// 20 | [global::System.Text.Json.Serialization.JsonExtensionData] 21 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// 27 | /// The function the model wants to call. 28 | /// 29 | #if NET7_0_OR_GREATER 30 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 31 | #endif 32 | public ToolCall( 33 | global::Ollama.ToolCallFunction? function) 34 | { 35 | this.Function = function; 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of the class. 40 | /// 41 | public ToolCall() 42 | { 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ToolCallFunction.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// The function the model wants to call. 8 | /// 9 | public sealed partial class ToolCallFunction 10 | { 11 | /// 12 | /// The name of the function to be called. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("name")] 15 | [global::System.Text.Json.Serialization.JsonRequired] 16 | public required string Name { get; set; } 17 | 18 | /// 19 | /// The arguments to pass to the function. 20 | /// 21 | [global::System.Text.Json.Serialization.JsonPropertyName("arguments")] 22 | [global::System.Text.Json.Serialization.JsonRequired] 23 | public required object Arguments { get; set; } 24 | 25 | /// 26 | /// Additional properties that are not explicitly defined in the schema 27 | /// 28 | [global::System.Text.Json.Serialization.JsonExtensionData] 29 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// 35 | /// The name of the function to be called. 36 | /// 37 | /// 38 | /// The arguments to pass to the function. 39 | /// 40 | #if NET7_0_OR_GREATER 41 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 42 | #endif 43 | public ToolCallFunction( 44 | string name, 45 | object arguments) 46 | { 47 | this.Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); 48 | this.Arguments = arguments ?? throw new global::System.ArgumentNullException(nameof(arguments)); 49 | } 50 | 51 | /// 52 | /// Initializes a new instance of the class. 53 | /// 54 | public ToolCallFunction() 55 | { 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ToolCallFunctionArgs.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// The arguments to pass to the function. 8 | /// 9 | public sealed partial class ToolCallFunctionArgs 10 | { 11 | 12 | /// 13 | /// Additional properties that are not explicitly defined in the schema 14 | /// 15 | [global::System.Text.Json.Serialization.JsonExtensionData] 16 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ToolFunction.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// A function that the model may call. 8 | /// 9 | public sealed partial class ToolFunction 10 | { 11 | /// 12 | /// The name of the function to be called. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("name")] 15 | [global::System.Text.Json.Serialization.JsonRequired] 16 | public required string Name { get; set; } 17 | 18 | /// 19 | /// A description of what the function does, used by the model to choose when and how to call the function. 20 | /// 21 | [global::System.Text.Json.Serialization.JsonPropertyName("description")] 22 | [global::System.Text.Json.Serialization.JsonRequired] 23 | public required string Description { get; set; } 24 | 25 | /// 26 | /// The parameters the functions accepts, described as a JSON Schema object. 27 | /// 28 | [global::System.Text.Json.Serialization.JsonPropertyName("parameters")] 29 | [global::System.Text.Json.Serialization.JsonRequired] 30 | public required object Parameters { get; set; } 31 | 32 | /// 33 | /// Additional properties that are not explicitly defined in the schema 34 | /// 35 | [global::System.Text.Json.Serialization.JsonExtensionData] 36 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 37 | 38 | /// 39 | /// Initializes a new instance of the class. 40 | /// 41 | /// 42 | /// The name of the function to be called. 43 | /// 44 | /// 45 | /// A description of what the function does, used by the model to choose when and how to call the function. 46 | /// 47 | /// 48 | /// The parameters the functions accepts, described as a JSON Schema object. 49 | /// 50 | #if NET7_0_OR_GREATER 51 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 52 | #endif 53 | public ToolFunction( 54 | string name, 55 | string description, 56 | object parameters) 57 | { 58 | this.Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); 59 | this.Description = description ?? throw new global::System.ArgumentNullException(nameof(description)); 60 | this.Parameters = parameters ?? throw new global::System.ArgumentNullException(nameof(parameters)); 61 | } 62 | 63 | /// 64 | /// Initializes a new instance of the class. 65 | /// 66 | public ToolFunction() 67 | { 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ToolFunctionParams.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// The parameters the functions accepts, described as a JSON Schema object. 8 | /// 9 | public sealed partial class ToolFunctionParams 10 | { 11 | 12 | /// 13 | /// Additional properties that are not explicitly defined in the schema 14 | /// 15 | [global::System.Text.Json.Serialization.JsonExtensionData] 16 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.ToolType.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// The type of tool.
8 | /// Default Value: function 9 | ///
10 | public enum ToolType 11 | { 12 | /// 13 | /// 14 | /// 15 | Function, 16 | } 17 | 18 | /// 19 | /// Enum extensions to do fast conversions without the reflection. 20 | /// 21 | public static class ToolTypeExtensions 22 | { 23 | /// 24 | /// Converts an enum to a string. 25 | /// 26 | public static string ToValueString(this ToolType value) 27 | { 28 | return value switch 29 | { 30 | ToolType.Function => "function", 31 | _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), 32 | }; 33 | } 34 | /// 35 | /// Converts an string to a enum. 36 | /// 37 | public static ToolType? ToEnum(string value) 38 | { 39 | return value switch 40 | { 41 | "function" => ToolType.Function, 42 | _ => null, 43 | }; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Models.VersionResponse.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// The response class for the version endpoint. 8 | /// 9 | public sealed partial class VersionResponse 10 | { 11 | /// 12 | /// The version of the Ollama server. 13 | /// 14 | [global::System.Text.Json.Serialization.JsonPropertyName("version")] 15 | public string? Version { get; set; } 16 | 17 | /// 18 | /// Additional properties that are not explicitly defined in the schema 19 | /// 20 | [global::System.Text.Json.Serialization.JsonExtensionData] 21 | public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// 27 | /// The version of the Ollama server. 28 | /// 29 | #if NET7_0_OR_GREATER 30 | [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] 31 | #endif 32 | public VersionResponse( 33 | string? version) 34 | { 35 | this.Version = version; 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of the class. 40 | /// 41 | public VersionResponse() 42 | { 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.ModelsClient.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #nullable enable 3 | 4 | namespace Ollama 5 | { 6 | /// 7 | /// List and describe the various models available.
8 | /// If no httpClient is provided, a new one will be created.
9 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 10 | ///
11 | public sealed partial class ModelsClient : global::Ollama.IModelsClient, global::System.IDisposable 12 | { 13 | /// 14 | /// Ollama server URL 15 | /// 16 | public const string DefaultBaseUrl = "http://localhost:11434/api"; 17 | 18 | private bool _disposeHttpClient = true; 19 | 20 | /// 21 | public global::System.Net.Http.HttpClient HttpClient { get; } 22 | 23 | /// 24 | public System.Uri? BaseUri => HttpClient.BaseAddress; 25 | 26 | /// 27 | public global::System.Collections.Generic.List Authorizations { get; } 28 | 29 | /// 30 | public bool ReadResponseAsString { get; set; } 31 | #if DEBUG 32 | = true; 33 | #endif 34 | /// 35 | /// 36 | /// 37 | public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Ollama.SourceGenerationContext.Default; 38 | 39 | 40 | /// 41 | /// Creates a new instance of the ModelsClient. 42 | /// If no httpClient is provided, a new one will be created. 43 | /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. 44 | /// 45 | /// The HttpClient instance. If not provided, a new one will be created. 46 | /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. 47 | /// The authorizations to use for the requests. 48 | /// Dispose the HttpClient when the instance is disposed. True by default. 49 | public ModelsClient( 50 | global::System.Net.Http.HttpClient? httpClient = null, 51 | global::System.Uri? baseUri = null, 52 | global::System.Collections.Generic.List? authorizations = null, 53 | bool disposeHttpClient = true) 54 | { 55 | HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); 56 | HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); 57 | Authorizations = authorizations ?? new global::System.Collections.Generic.List(); 58 | _disposeHttpClient = disposeHttpClient; 59 | 60 | Initialized(HttpClient); 61 | } 62 | 63 | /// 64 | public void Dispose() 65 | { 66 | if (_disposeHttpClient) 67 | { 68 | HttpClient.Dispose(); 69 | } 70 | } 71 | 72 | partial void Initialized( 73 | global::System.Net.Http.HttpClient client); 74 | partial void PrepareArguments( 75 | global::System.Net.Http.HttpClient client); 76 | partial void PrepareRequest( 77 | global::System.Net.Http.HttpClient client, 78 | global::System.Net.Http.HttpRequestMessage request); 79 | partial void ProcessResponse( 80 | global::System.Net.Http.HttpClient client, 81 | global::System.Net.Http.HttpResponseMessage response); 82 | partial void ProcessResponseContent( 83 | global::System.Net.Http.HttpClient client, 84 | global::System.Net.Http.HttpResponseMessage response, 85 | ref string content); 86 | } 87 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Generated/Ollama.Polyfills.g.cs: -------------------------------------------------------------------------------- 1 | 2 | #if !NET6_0_OR_GREATER 3 | #nullable enable 4 | 5 | namespace Ollama 6 | { 7 | /// 8 | /// 9 | /// 10 | public static partial class AutoSdkPolyfills 11 | { 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | public static global::System.Threading.Tasks.Task ReadAsStringAsync( 19 | this global::System.Net.Http.HttpContent content, 20 | global::System.Threading.CancellationToken cancellationToken) 21 | { 22 | content = content ?? throw new global::System.ArgumentNullException(nameof(content)); 23 | return content.ReadAsStringAsync(); 24 | } 25 | /// 26 | /// 27 | /// 28 | /// 29 | /// 30 | /// 31 | public static global::System.Threading.Tasks.Task ReadAsStreamAsync( 32 | this global::System.Net.Http.HttpContent content, 33 | global::System.Threading.CancellationToken cancellationToken) 34 | { 35 | content = content ?? throw new global::System.ArgumentNullException(nameof(content)); 36 | return content.ReadAsStreamAsync(); 37 | } 38 | /// 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | public static global::System.Threading.Tasks.Task ReadAsByteArrayAsync( 45 | this global::System.Net.Http.HttpContent content, 46 | global::System.Threading.CancellationToken cancellationToken) 47 | { 48 | content = content ?? throw new global::System.ArgumentNullException(nameof(content)); 49 | return content.ReadAsByteArrayAsync(); 50 | } 51 | } 52 | } 53 | #endif -------------------------------------------------------------------------------- /src/libs/Ollama/JsonSerializerContextTypes.AdditionalTypes.cs: -------------------------------------------------------------------------------- 1 | using CSharpToJsonSchema; 2 | 3 | namespace Ollama; 4 | 5 | public partial class JsonSerializerContextTypes 6 | { 7 | /// 8 | /// 9 | /// 10 | public OpenApiSchema? OpenApiSchema { get; set; } 11 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Message.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama; 2 | 3 | public partial class Message 4 | { 5 | /// 6 | /// 7 | /// 8 | /// 9 | /// 10 | public static implicit operator Message(string content) 11 | { 12 | return ToMessage(content); 13 | } 14 | 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | public static Message ToMessage(string content) 21 | { 22 | return new Message 23 | { 24 | Role = MessageRole.User, 25 | Content = content, 26 | }; 27 | } 28 | } -------------------------------------------------------------------------------- /src/libs/Ollama/Ollama.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0;net4.6.2;net8.0;net9.0 5 | $(NoWarn);CA2016;CA2227;CA1002;CA1303;CA1305 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Generated C# SDK based on Ollama OpenAPI specification. 15 | api;client;sdk;dotnet;swagger;openapi;specification;ollama;generated 16 | 17 | 18 | 19 | 20 | 21 | all 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/libs/Ollama/PullModelResponseExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama; 2 | 3 | /// 4 | /// 5 | /// 6 | public static class PullModelResponseExtensions 7 | { 8 | /// 9 | /// 10 | /// 11 | /// 12 | /// 13 | /// 14 | public static double GetPercent(this PullModelResponse response) 15 | { 16 | response = response ?? throw new ArgumentNullException(nameof(response)); 17 | 18 | if (response.Total == null || response.Completed == null) 19 | { 20 | return 0; 21 | } 22 | 23 | return response.Total.Value == 0 24 | ? 100.0 25 | : response.Completed.Value * 100.0 / response.Total.Value; 26 | } 27 | } -------------------------------------------------------------------------------- /src/libs/Ollama/generate.sh: -------------------------------------------------------------------------------- 1 | dotnet tool install --global autosdk.cli --prerelease 2 | rm -rf Generated 3 | curl -o openapi.yaml https://raw.githubusercontent.com/davidmigloz/langchain_dart/main/packages/ollama_dart/oas/ollama-curated.yaml 4 | dotnet run --project ../../helpers/FixOpenApiSpec openapi.yaml 5 | if [ $? -ne 0 ]; then 6 | echo "Failed, exiting..." 7 | exit 1 8 | fi 9 | autosdk generate openapi.yaml \ 10 | --namespace Ollama \ 11 | --clientClassName OllamaApiClient \ 12 | --targetFramework net8.0 \ 13 | --output Generated \ 14 | --exclude-deprecated-operations 15 | #openapi-generator generate \ 16 | # -i openapi.yaml \ 17 | # -g csharp \ 18 | # -o generichost \ 19 | # --package-name Ollama \ 20 | # --additional-properties library=generichost,nullableReferenceTypes=true,targetFramework='netstandard2.0;net47;net6.0;net8.0' 21 | #openapi-generator generate \ 22 | # -i openapi.yaml \ 23 | # -g csharp \ 24 | # -o httpclient \ 25 | # --package-name Ollama \ 26 | # --additional-properties library=httpclient,nullableReferenceTypes=true,targetFramework='netstandard2.0;net47;net6.0;net8.0' -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Environment.cs: -------------------------------------------------------------------------------- 1 | using DotNet.Testcontainers.Builders; 2 | using DotNet.Testcontainers.Containers; 3 | 4 | namespace Ollama.IntegrationTests; 5 | 6 | public sealed class Environment : IAsyncDisposable 7 | { 8 | public required EnvironmentType? Type { get; init; } 9 | public IContainer? Container { get; init; } 10 | public required OllamaApiClient ApiClient { get; init; } 11 | 12 | public async ValueTask DisposeAsync() 13 | { 14 | ApiClient.Dispose(); 15 | if (Container != null) 16 | { 17 | await Container.DisposeAsync(); 18 | } 19 | } 20 | 21 | public static async Task PrepareAsync(string model = "", EnvironmentType? environmentType = null) 22 | { 23 | environmentType ??= InferEnvironment(); 24 | switch (environmentType) 25 | { 26 | case EnvironmentType.Local: 27 | { 28 | // set OLLAMA_HOST=10.10.5.85:11434 29 | // ollama serve 30 | var apiClient = new OllamaApiClient( 31 | httpClient: new HttpClient 32 | { 33 | Timeout = TimeSpan.FromMinutes(10), 34 | }, 35 | baseUri: new Uri("http://127.0.0.1:11434/api")); // baseUri: new Uri("http://10.10.5.85:11434/api") 36 | 37 | if (!string.IsNullOrEmpty(model)) 38 | { 39 | await apiClient.Models.PullModelAsync(model).EnsureSuccessAsync(); 40 | } 41 | 42 | return new Environment 43 | { 44 | Type = environmentType, 45 | ApiClient = apiClient, 46 | }; 47 | } 48 | case EnvironmentType.Container: 49 | { 50 | var container = new ContainerBuilder() 51 | .WithImage("ollama/ollama") 52 | .WithPortBinding(hostPort: 11434, containerPort: 11434) 53 | .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(11434)) 54 | .Build(); 55 | 56 | await container.StartAsync(); 57 | 58 | var apiClient = new OllamaApiClient(); 59 | if (!string.IsNullOrEmpty(model)) 60 | { 61 | await apiClient.Models.PullModelAsync(model).EnsureSuccessAsync(); 62 | } 63 | 64 | return new Environment 65 | { 66 | Type = environmentType, 67 | Container = container, 68 | ApiClient = apiClient, 69 | }; 70 | } 71 | default: 72 | throw new ArgumentOutOfRangeException(nameof(environmentType), environmentType, null); 73 | } 74 | } 75 | private static EnvironmentType InferEnvironment() 76 | { 77 | #if DEBUG 78 | return EnvironmentType.Local; 79 | #else 80 | return EnvironmentType.Container; 81 | #endif 82 | } 83 | 84 | } 85 | 86 | public enum EnvironmentType 87 | { 88 | Local, 89 | Container, 90 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Ollama.IntegrationTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | 6 | 7 | 8 | 9 | all 10 | runtime; build; native; contentfiles; analyzers; buildtransitive 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Test.StructuredOutputInChat.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Text.Json; 3 | using System.Text.Json.Serialization; 4 | namespace Ollama.IntegrationTests; 5 | 6 | public partial class Tests 7 | { 8 | [TestMethod] 9 | public async Task StructuredOutputInChat() 10 | { 11 | await using var container = await Environment.PrepareAsync("llama3.2"); 12 | 13 | var chat = container.ApiClient.Chat( 14 | model: "llama3.2", 15 | systemMessage: "You are a helpful weather assistant." 16 | ); 17 | 18 | // can also use NewtonSoft.Json.Schema or some other auto schema generation library 19 | var schemaObject = JsonSerializer.Deserialize(@"{ 20 | ""description"": ""The response to a query about the weather"", 21 | ""type"": ""object"", 22 | ""required"": [""Temperature"", ""Location"", ""Unit""], 23 | ""properties"": { 24 | ""Temperature"": { 25 | ""type"": ""integer"" 26 | }, 27 | ""Location"": { 28 | ""type"": ""string"" 29 | }, 30 | ""Unit"": { 31 | ""type"": ""string"", 32 | ""enum"": [""Celsius"", ""Fahrenheit""] 33 | } 34 | } 35 | }"); 36 | 37 | try 38 | { 39 | Console.WriteLine($"schemaObject: {schemaObject}"); 40 | chat.ResponseFormat = new ResponseFormat(schemaObject); 41 | var response = await chat.SendAsync("What is the current temperature in Dubai, UAE in Celsius? (hint: it's 25C in Dubai right now)"); 42 | Console.WriteLine(response); 43 | var queryResponse = JsonSerializer.Deserialize(response.Content); 44 | queryResponse.Should().NotBeNull(); 45 | queryResponse.Temperature.Should().Be(25); 46 | queryResponse.Location.Should().Contain("Dubai"); 47 | } 48 | finally 49 | { 50 | Console.WriteLine(chat.PrintMessages()); 51 | } 52 | } 53 | 54 | [JsonConverter(typeof(JsonStringEnumConverter))] 55 | public enum TemperatureUnit 56 | { 57 | Celsius, 58 | Fahrenheit 59 | } 60 | 61 | public class QueryResponse { 62 | 63 | public int Temperature { get; set; } 64 | public TemperatureUnit Unit { get; set; } 65 | public string Location { get; set; } = string.Empty; 66 | } 67 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.Chat.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | [TestClass] 4 | public partial class Tests 5 | { 6 | [TestMethod] 7 | public async Task Chat() 8 | { 9 | await using var container = await Environment.PrepareAsync("llama3.2"); 10 | 11 | var chat = container.ApiClient.Chat("llama3.2"); 12 | var message = await chat.SendAsync("answer 5 random words"); 13 | 14 | Console.WriteLine(message.Content); 15 | } 16 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.Embeddings.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task Embeddings() 7 | { 8 | await using var container = await Environment.PrepareAsync( "all-minilm"); 9 | 10 | var embeddingResponse = await container.ApiClient.Embeddings.GenerateEmbeddingAsync( 11 | model:"all-minilm", 12 | prompt: "hello"); 13 | 14 | embeddingResponse.Embedding.Should().NotBeNullOrEmpty(); 15 | } 16 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.GetCompletion.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task GetCompletion() 7 | { 8 | await using var container = await Environment.PrepareAsync("llama3.2"); 9 | 10 | IList? context = null; 11 | var enumerable = container.ApiClient.Completions.GenerateCompletionAsync("llama3.2", "answer 5 random words"); 12 | await foreach (var response in enumerable) 13 | { 14 | Console.WriteLine($"> {response.Response}"); 15 | 16 | context = response.Context; 17 | } 18 | 19 | var lastResponse = await container.ApiClient.Completions.GenerateCompletionAsync("llama3.2", "answer 123", stream: false, context: context).WaitAsync(); 20 | Console.WriteLine(lastResponse.Response); 21 | } 22 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.GetCompletionWithOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task GetCompletionWithOptions() 7 | { 8 | await using var container = await Environment.PrepareAsync("llama3.2"); 9 | 10 | var response = await container.ApiClient.Completions.GenerateCompletionAsync(new GenerateCompletionRequest 11 | { 12 | Model = "llama3.2", 13 | Prompt = "answer me just \"123\"", 14 | Stream = true, 15 | Options = new RequestOptions 16 | { 17 | Temperature = 0, 18 | }, 19 | }); 20 | Console.WriteLine(response.Response); 21 | } 22 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.ListModels.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task ListModels() 7 | { 8 | await using var container = await Environment.PrepareAsync(environmentType: EnvironmentType.Container); 9 | 10 | var models = await container.ApiClient.Models.ListModelsAsync(); 11 | models.Models.Should().BeNullOrEmpty(); 12 | 13 | await container.ApiClient.Models.PullModelAsync("all-minilm").EnsureSuccessAsync(); 14 | 15 | models = await container.ApiClient.Models.ListModelsAsync(); 16 | models.Models.Should().NotBeNull(); 17 | models.Models.Should().HaveCount(1); 18 | models.Models![0].Model1.Should().Be("all-minilm:latest"); 19 | } 20 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.PullModel.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task PullModel() 7 | { 8 | await using var container = await Environment.PrepareAsync(environmentType: EnvironmentType.Container); 9 | 10 | await foreach (var response in container.ApiClient.Models.PullModelAsync("all-minilm")) 11 | { 12 | Console.WriteLine($"{response.Status?.Object}. Progress: {response.Completed}/{response.Total}"); 13 | } 14 | 15 | var responses = await container.ApiClient.Models.PullModelAsync("all-minilm"); 16 | responses[^1].EnsureSuccess(); 17 | 18 | await container.ApiClient.Models.PullModelAsync("all-minilm").EnsureSuccessAsync(); 19 | } 20 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.ReaderLm.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task ReaderLm() 7 | { 8 | await using var container = await Environment.PrepareAsync("reader-lm:latest"); 9 | 10 | var enumerable = container.ApiClient.Completions.GenerateCompletionAsync( 11 | "reader-lm:latest", 12 | """ 13 | 14 | 15 |

Why is the sky blue?

16 |

The sky appears blue because of the way light from the sun is reflected by the atmosphere. The atmosphere is made up of gases, including nitrogen and oxygen, which scatter light in all directions. This scattering causes the sunlight to appear as a rainbow of colors, with red light scattered more than other colors. 17 |

18 | 19 | 20 | """); 21 | await foreach (var response in enumerable) 22 | { 23 | Console.Write(response.Response); 24 | } 25 | 26 | // ### Why is the sky blue? 27 | // 28 | // The sky appears blue because of the way light from the sun is reflected by the atmosphere. The atmosphere is made up of gases, including nitrogen and oxygen, which scatter light in all directions. This scattering causes the sunlight to appear as a rainbow of colors, with red light scattered more than other colors. 29 | } 30 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.Tools.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task Tools() 7 | { 8 | await using var container = await Environment.PrepareAsync("llama3.2"); 9 | 10 | var messages = new List 11 | { 12 | "You are a helpful weather assistant.".AsSystemMessage(), 13 | "What is the current temperature in Dubai, UAE in Celsius?".AsUserMessage(), 14 | }; 15 | const string model = "llama3.2"; 16 | 17 | try 18 | { 19 | var service = new WeatherService(); 20 | var tools = service.AsTools().AsOllamaTools(); 21 | var response = await container.ApiClient.Chat.GenerateChatCompletionAsync( 22 | model, 23 | messages, 24 | stream: false, 25 | tools: tools).WaitAsync(); 26 | 27 | messages.Add(response.Message); 28 | 29 | response.Message.ToolCalls.Should().NotBeNullOrEmpty(because: "Expected a function call."); 30 | 31 | foreach (var call in response.Message.ToolCalls!) 32 | { 33 | var json = await service.CallAsync( 34 | functionName: call.Function?.Name ?? string.Empty, 35 | argumentsAsJson: call.Function?.Arguments.AsJson() ?? string.Empty); 36 | messages.Add(json.AsToolMessage()); 37 | } 38 | 39 | response = await container.ApiClient.Chat.GenerateChatCompletionAsync( 40 | model, 41 | messages, 42 | stream: false, 43 | tools: tools).WaitAsync(); 44 | messages.Add(response.Message); 45 | } 46 | finally 47 | { 48 | Console.WriteLine(Ollama.Chat.PrintMessages(messages)); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/Tests.ToolsInChat.cs: -------------------------------------------------------------------------------- 1 | namespace Ollama.IntegrationTests; 2 | 3 | public partial class Tests 4 | { 5 | [TestMethod] 6 | public async Task ToolsInChat() 7 | { 8 | await using var container = await Environment.PrepareAsync("llama3.2"); 9 | 10 | var chat = container.ApiClient.Chat( 11 | model: "llama3.2", 12 | systemMessage: "You are a helpful weather assistant.", 13 | autoCallTools: true); 14 | 15 | var service = new WeatherService(); 16 | chat.AddToolService(service.AsTools().AsOllamaTools(), service.AsCalls()); 17 | 18 | try 19 | { 20 | _ = await chat.SendAsync("What is the current temperature in Dubai, UAE in Celsius?"); 21 | } 22 | finally 23 | { 24 | Console.WriteLine(chat.PrintMessages()); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/tests/Ollama.IntegrationTests/WeatherTools.cs: -------------------------------------------------------------------------------- 1 | using CSharpToJsonSchema; 2 | using DescriptionAttribute = System.ComponentModel.DescriptionAttribute; 3 | 4 | namespace Ollama.IntegrationTests; 5 | 6 | public enum Unit 7 | { 8 | Celsius, 9 | Fahrenheit, 10 | } 11 | 12 | public class Weather 13 | { 14 | public string Location { get; set; } = string.Empty; 15 | public double Temperature { get; set; } 16 | public Unit Unit { get; set; } 17 | public string Description { get; set; } = string.Empty; 18 | } 19 | 20 | [GenerateJsonSchema] 21 | public interface IWeatherTools 22 | { 23 | [Description("Get the current weather in a given location")] 24 | public Weather GetCurrentWeather( 25 | [Description("The city and state, e.g. San Francisco, CA")] string location, 26 | Unit unit = Unit.Celsius); 27 | 28 | [Description("Get the current weather in a given location")] 29 | public Task GetCurrentWeatherAsync( 30 | [Description("The city and state, e.g. San Francisco, CA")] string location, 31 | Unit unit = Unit.Celsius, 32 | CancellationToken cancellationToken = default); 33 | } 34 | 35 | public class WeatherService : IWeatherTools 36 | { 37 | public Weather GetCurrentWeather(string location, Unit unit = Unit.Celsius) 38 | { 39 | return new Weather 40 | { 41 | Location = location, 42 | Temperature = 22.0, 43 | Unit = unit, 44 | Description = "Sunny", 45 | }; 46 | } 47 | 48 | public Task GetCurrentWeatherAsync(string location, Unit unit = Unit.Celsius, CancellationToken cancellationToken = default) 49 | { 50 | return Task.FromResult(new Weather 51 | { 52 | Location = location, 53 | Temperature = 22.0, 54 | Unit = unit, 55 | Description = "Sunny", 56 | }); 57 | } 58 | } --------------------------------------------------------------------------------