Amazon Bedrock model provider.
Install
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard | |
| Other |
README
π¦οΈπ LangChain
β‘ Building applications with LLMs through composability β‘
C# implementation of LangChain. We try to be as close to the original as possible in terms of abstractions, but are open to new entities.
While the SemanticKernel is good and we will use it wherever possible, we believe that it has many limitations and based on Microsoft technologies. We proceed from the position of the maximum choice of available options and are open to using third-party libraries within individual implementations.
I want to note:
- Iβm unlikely to be able to make serious progress alone, so my goal is to unite the efforts of C# developers to create a C# version of LangChain and control the quality of the final project
- I try to accept any Pull Request within 24 hours (of course, it depends, but I will try)
- I'm also looking for developers to join the core team. I will sponsor them whenever possible and also share any money received.
- I also respond quite quickly on Discord for any questions related to the project
Usage
You can use our wiki to get started: https://github.com/tryAGI/LangChain/wiki
Also see examples for example usage or tests.
// Price to run from zero(create embeddings and request to LLM): 0,015$
// Price to re-run if database is exists: 0,0004$
// Dependencies: LangChain, LangChain.Databases.Sqlite, LangChain.Sources.Pdf
var provider = new OpenAiProvider("OPENAI_API_KEY");
var llm = new Gpt35TurboModel(provider).UseConsoleForDebug();
var embeddings = new TextEmbeddingV3SmallModel(provider);
var bookURL =
"https://canonburyprimaryschool.co.uk/wp-content/uploads/2016/01/Joanne-K.-Rowling-Harry-Potter-Book-1-Harry-Potter-and-the-Philosophers-Stone-EnglishOnlineClub.com_.pdf";
var source = await PdfPigPdfSource.CreateFromUriAsync(new Uri(bookURL));
var index = await SQLiteVectorStore.GetOrCreateIndex(embeddings, source);
string promptText =
@"Use the following pieces of context to answer the question at the end. If the answer is not in context then just say that you don't know, don't try to make up an answer. Keep the answer as short as possible. Always quote the context in your answer.
{context}
Question: {text}
Helpful Answer:";
var chain =
Set("Who was drinking a unicorn blood?") // set the question
| RetrieveDocuments(index, amount: 5) // take 5 most similar documents
| StuffDocuments(outputKey: "context") // combine documents together and put them into context
| Template(promptText) // replace context and question in the prompt with their values
| LLM(llm); // send the result to the language model
var answer=await chain.Run("text"); // get chain result
Console.WriteLine("Answer:"+ answer); // print the result
// print usage
Console.WriteLine($"LLM usage: {llm.Usage}");
Console.WriteLine($"Embeddings usage: {embeddings.Usage}");
Contributors
Konstantin S.
π β οΈ π»
TesAnti
π β οΈ π»
Khoroshev Evgeniy
π β οΈ π»
SiegDuch
π
gunpal5
π β οΈ π»
Ketan Khare
π β οΈ π»
Roderic Bos
π β οΈ π»
Peter James
π β οΈ π»
Ty Augustine
π β οΈ π»
Eric Green
π β οΈ π»
Lyx52
π β οΈ π»
Support
Priority place for bugs: https://github.com/tryAGI/LangChain/issues
Priority place for ideas and general questions: https://github.com/tryAGI/LangChain/discussions
Discord: https://discord.gg/Ca2xhfBf3v
Changes from Previous Version
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.