![]() |
VOOZH | about |
dotnet add package ContextFlow --version 1.0.0
NuGet\Install-Package ContextFlow -Version 1.0.0
<PackageReference Include="ContextFlow" Version="1.0.0" />
<PackageVersion Include="ContextFlow" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="ContextFlow" />Project file
paket add ContextFlow --version 1.0.0
#r "nuget: ContextFlow, 1.0.0"
#:package ContextFlow@1.0.0
#addin nuget:?package=ContextFlow&version=1.0.0Install as a Cake Addin
#tool nuget:?package=ContextFlow&version=1.0.0Install as a Cake Tool
ContextFlow is a C# library that builds an abstraction above regular LLMs and enables more complex interaction with LLMs.
ContextFlow is infrastructure that
NuGet\Install-Package ContextFlow -Version 1.0.0LLMs are only as useful as how well they are used.
As LLMs become more competent, the programmatic environment in which they operate must expand to fulfill different needs.
The topmost class is the LLMRequest, which is constructed with an LLMRequestBuilder. All required data and configuration are dependency-injected into the request, which then handles the process of getting output and using defined extensions.
The required modules are
Prompt: Consisting of an action, and a variable number of string-based attachments.LLMConnection: A connection to the LLM that returns the output and optionally additional dataRequestConfig: Stores the extensions used and some behaviour.LLMConfig: Stores the LLM's settings (system message, frequency pentaly etc.) as well as constraints (maximum input tokens, maximum output tokens)Some modules have their async-counterparts: LLMRequestAsync, RequestConfigAsync, and LLMConnectionAsync
LLMConnectionException: Something went wrong on the LLM-connection sideOutputOverflow: The LLM's output was cut off because it reached the token limitÌnputOverflow: The input limit was reached. (This gets thrown before the request happens)The CFLogger-abstract class is a serilog-like interface. Conversely, the standard logger is a serilog-implementation. By default, it saves the messages into a file too.
Handles loading of the data. Must also implement a method that determines if a matching saved request exists. It's recommended to add an option to determine if only the prompt or also the llm-configuration should be considered when looking for a match.
Handles saving the data.
A FailStrategy handles a specific exception that occured, if it can. It gets the LLMRequest and optionally returns a RequestResult.
Nesting FailStrategies that handle the same exception is possible but disrecommended.
The returned object of both LLMRequest and LLMRequestAsync is a RequestResult. It contains the raw output, the reason why the LLM stopped its output, and an optional RequestAdditionalData-instance which got passed up from the LLMConnection
This result can be parsed (into a ParsedRequestResult).
Both RequestResult and it's parsed counterpart have an Actions/AsyncActions-property, that makes pipelining requests easier:
.Then(...) -> RequestResult: Executes the next step in a pipeline of requests. It takes a function that builds the next LLMRequest from the current result, applies it to itself, and completes the request.ThenConditional(...) -> RequestResult: Returns itself it the condition does not match, or if it does, it applies a function like the one in .Then(...)..ThenBranching(...) -> IEnumerable<RequestResult>: Like .Then(...) but the function builds a number of requests.ThenBranchingConditional(...) -> (IEnumerable<RequestResult>, IEnumerable<RequestResult>: Like .ThenBranching(...), but separates the results that pass a condition from those that don't.All synchronous actions that would experience a performance-gain from being asynchronous have that counterpart.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 388 | 11/1/2023 |