tryAGI / LangChain

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.
https://tryagi.gitbook.io/langchain/
MIT License
450 stars 70 forks source link

Can't find LLamaSharpModelInstruction in getting started example #362

Open markat1 opened 1 week ago

markat1 commented 1 week ago

Describe the bug

I tried your example in Getting-started

I'm getting a CS0103 compiler error - it can't find LLamaSharpModelInstruction

Error (active) CS0103 The name 'LLamaSharpModelInstruction' does not exist in the current context

So is it because 'LLamaSharpModelInstruction' is called something else now?

Steps to reproduce the bug

  1. created a .net 8 console app
  2. installed Langchain, llamacharp.Backend
  <ItemGroup>
    <PackageReference Include="LangChain" Version="0.15.0" />
    <PackageReference Include="LLamaSharp.Backend.Cpu" Version="0.13.0" />
    <PackageReference Include="LLamaSharp.Backend.Cuda11" Version="0.13.0" />
    <PackageReference Include="LLamaSharp.Backend.Cuda12" Version="0.13.0" />
  </ItemGroup>
  1. added following code:
using LangChain.Chains;
using LangChain.Providers.Downloader;
using LangChain.Providers.HuggingFace.Downloader;
using LangChain.Providers.LLamaSharp;

// get model path
var modelPath = await HuggingFaceModelDownloader.Instance.GetModel("TheBloke/Thespis-13B-v0.5-GGUF", "thespis-13b-v0.5.Q2_K.gguf", "main");

// load model
var model = LLamaSharpModelInstruction.FromPath(modelPath);
model.PromptSent += Console.Write;
model.TokenGenerated += Console.Write;

// building a chain
var prompt = @"
You are an AI assistant that greets the world.
World: Hello, Assistant!
Assistant:";

var chain =
    Chain.Set(prompt, outputKey: "prompt")
    | Chain.LLM(model, inputKey: "prompt");

chain.Run().Wait();

Expected behavior

I can compile and run the console app.

Screenshots

image

image

NuGet package version

   <PackageReference Include="LangChain" Version="0.15.0" />
    <PackageReference Include="LLamaSharp.Backend.Cpu" Version="0.13.0" />
    <PackageReference Include="LLamaSharp.Backend.Cuda11" Version="0.13.0" />
    <PackageReference Include="LLamaSharp.Backend.Cuda12" Version="0.13.0" />