LangChain.Scraper (langchainex v0.2.3)

A Scraper is a GenServer that scrapes natural language text and tries to turn it into some kind of structured data. It comes with a built in "default_scraper" that can generally extract data from text according to the schema you gave it. Examples:

= Scraper.start_link() input_text = "John Doe is 30 years old." {:ok, result} = Scraper.scrape(scraper_pid, input_text)

= Scraper.scrape(scraper_pid, input_text, "default_scraper", %{ output_format: "XML" })

= Scraper.scrape(scraper_pid, input_text, "default_scraper", %{ input_schema: "{ name: { first: String, last: String }, age: Number }", output_format: "YAML" })

Link to this section Summary

Functions

add your own custom scrape chain to the Scraper

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

A default output parser that just returns the first response text as json

Returns a list of all the scrape chains in the Scraper

simple passthrough parser that just returns the result

A default output parser that just returns the first response text

Link to this section Functions

Link to this function

add_scrape_chain(pid, name, scrape_chain)

add your own custom scrape chain to the Scraper

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Callback implementation for GenServer.init/1.

Link to this function

json_parser(chain_link, outputs)

A default output parser that just returns the first response text as json

Returns a list of all the scrape chains in the Scraper

Link to this function

output_parser(result)

simple passthrough parser that just returns the result

Link to this function

passthru_parser(chain_link, response_text)

A default output parser that just returns the first response text

Link to this function

scrape(pid, input_text, llm_pid, name \\ "default_scraper", opts \\ %{})

scrape some text using the default scraper

Link to this function

start_link(opts \\ [])