Method: Langchain::LLM::Replicate#summarize

Defined in:
lib/langchain/llm/replicate.rb

#summarize(text:) ⇒ String

Generate a summary for a given text

Parameters:

  • text (String)

    The text to generate a summary for

Returns:

  • (String)

    The summary

[View source]

78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/langchain/llm/replicate.rb', line 78

def summarize(text:)
  prompt_template = Langchain::Prompt.load_from_path(
    file_path: Langchain.root.join("langchain/llm/prompts/summarize_template.yaml")
  )
  prompt = prompt_template.format(text: text)

  complete(
    prompt: prompt,
    temperature: @defaults[:temperature],
    # Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
    max_tokens: 2048
  )
end