Home / File/ prompts.py — langchain Source File

prompts.py — langchain Source File

Architecture documentation for prompts.py, a python file in the langchain codebase. 1 imports, 0 dependents.

File python 1 imports

Entity Profile

Dependency Diagram

graph LR
  f36f5685_3837_d1d1_819d_33741f4c6eee["prompts.py"]
  4b3dcc0f_d872_0044_39ec_2d289f87f9e6["langchain_core.prompts.prompt"]
  f36f5685_3837_d1d1_819d_33741f4c6eee --> 4b3dcc0f_d872_0044_39ec_2d289f87f9e6
  style f36f5685_3837_d1d1_819d_33741f4c6eee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from langchain_core.prompts.prompt import PromptTemplate

PROMPT_SUFFIX = """Only use the following Elasticsearch indices:
{indices_info}

Question: {input}
ESQuery:"""

DEFAULT_DSL_TEMPLATE = """Given an input question, create a syntactically correct Elasticsearch query to run. Unless the user specifies in their question a specific number of examples they wish to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.

Unless told to do not query for all the columns from a specific index, only ask for a few relevant columns given the question.

Pay attention to use only the column names that you can see in the mapping description. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which index. Return the query as valid json.

Use the following format:

Question: Question here
ESQuery: Elasticsearch Query formatted as json
"""  # noqa: E501

DSL_PROMPT = PromptTemplate.from_template(DEFAULT_DSL_TEMPLATE + PROMPT_SUFFIX)

DEFAULT_ANSWER_TEMPLATE = """Given an input question and relevant data from a database, answer the user question.

Use the following format:

Question: Question here
Data: Relevant data here
Answer: Final answer here

Question: {input}
Data: {data}
Answer:"""  # noqa: E501

ANSWER_PROMPT = PromptTemplate.from_template(DEFAULT_ANSWER_TEMPLATE)

Dependencies

  • langchain_core.prompts.prompt

Frequently Asked Questions

What does prompts.py do?
prompts.py is a source file in the langchain codebase, written in python.
What does prompts.py depend on?
prompts.py imports 1 module(s): langchain_core.prompts.prompt.
Where is prompts.py in the architecture?
prompts.py is located at libs/langchain/langchain_classic/chains/elasticsearch_database/prompts.py (directory: libs/langchain/langchain_classic/chains/elasticsearch_database).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free