Skip to content

sombraSoft/langchainex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LangchainEx

Overview

Loosely inspired by LangChainJs This library seeks to enable core LangChain functionality but using Elixir and OTP idioms. It provides low-level structures you can use to build your own language chain applications as well as high-level GenServers for accomplishing common natural-language processing tasks very quickly.

Installation

def deps do
  [
    {:langchainex, "~> 0.1.0"}
  ]
end

Be sure to set your OPENAI_API_KEY and OPENAI_ORGANIZATION_KEY in your environment variables before using.

GenServers

Scraper

Scraper holds language chains that extract structured data from natural language text. It has a handy "default_scraper" that can be used out of the box.

In your Application tree:

  {LangChain.Scraper, name: :scraper},

In your code:

  description = "Hi I'm Nermal an 11th-level magic user with 30 hit points, I have a wand of healing and a cloak of protection in my inventory."

  character_schema = "{
    name: String,
    class: String,
    hitPoints: Int,          
    inventory: [String]
  }"

  {:ok, result } = LangChain.Scraper.scrape(:scraper, description, "default_scraper", %{ outputFormat: "YAML", inputSchema: character_schema }) 

  IO.puts result.text 
  " name: Nermal
    class: magic user
    hitPoints: 30
    inventory:
      - wand of healing
      - cloak of protection
  "
    end

About

Language Chain Library for Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%