langchain 0.0.1

Base trait framework for implementing applications on large language models
Documentation

Langchain

Work in progress interface for building langchain framework tools. Will attempt 1-1 correspondence with the python langchain framework (including serialisation)

Objectives:

  • 1-1 correspondence with python langchain framwork interface
  • Serialisation / Deserialisation of langchain objects

Non-objectives:

  • Reference / concrete implementations of various modules. Those are delegated to other crates
  • Visualisation, UI tools

Architecture:

The vast majority of code written when using this framework will be writing tools, working with memory, and llm models. The abstraction provided is described in the Model trait

#[async_trait::async_trait]
pub trait Model<M>
where
    M: Memory,
{
    async fn run(&self, memory: &mut M) -> Result<(), LanguageModelError>;
}

This is describing that an LLM model is abstract over its own internal implementation and the memory it operates on. Memory is a serialisation of state or a "session" of a model and is expected to be passed around if required.

A very simple agent implementation would be something like


pub fn answer_question(question: &str) {
	let model = langchain::model::openai::ChatModel;
	let memory = langchain::model::openai::ChatMemory;
	
	let mut agent = langchain::agent::Agent::default()
		.with_tool(SearchWeb) // implement this yourself 
	
	let result = agent.execute( AgentRequest { memory, question: "How do birds fly?" } ).await;
}