LangChain.Tools.DeepResearch.ResearchResult (LangChain v0.6.0)

Copy Markdown View Source

Represents the final result of a completed Deep Research request.

This schema captures the research findings, citations, usage statistics, and other metadata from a successful research operation.

Sources are stored as LangChain.Message.Citation structs, providing a unified citation representation shared across all providers.

Summary

Functions

Creates a changeset for research result.

Formats the result for display, including the main text and source summary.

Creates a ResearchResult from an OpenAI API response.

Gets the total number of sources cited in the research.

Extracts just the URLs from the sources for easy reference.

Gets the total number of tool calls made during research.

Types

t()

@type t() :: %LangChain.Tools.DeepResearch.ResearchResult{
  completion_time: integer() | nil,
  created_at: integer() | nil,
  id: String.t(),
  model: String.t() | nil,
  output_text: String.t(),
  sources: [LangChain.Message.Citation.t()],
  tool_calls: [any()],
  usage: any() | nil
}

Functions

changeset(result \\ %__MODULE__{}, attrs)

@spec changeset(t(), map()) :: Ecto.Changeset.t()

Creates a changeset for research result.

format_for_display(result)

@spec format_for_display(t()) :: String.t()

Formats the result for display, including the main text and source summary.

from_api_response(response)

@spec from_api_response(map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Creates a ResearchResult from an OpenAI API response.

source_count(research_result)

@spec source_count(t()) :: integer()

Gets the total number of sources cited in the research.

source_urls(research_result)

@spec source_urls(t()) :: [String.t()]

Extracts just the URLs from the sources for easy reference.

tool_call_count(research_result)

@spec tool_call_count(t()) :: integer()

Gets the total number of tool calls made during research.