Skip to content

Commit

Permalink
Change prompt constants to UPPERCASE
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyclements committed Feb 10, 2025
1 parent a0b5a05 commit 3bbf258
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libs/langchain-mongodb/langchain_mongodb/graphrag/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(
allowed_entity_types: If provided, constrains search to these types.
allowed_relationship_types: If provided, constrains search to these types.
entity_examples: A string containing any number of additional examples to provide as context for entity extraction.
entity_name_examples: A string appended to schema.name_extraction_instructions containing examples.
entity_name_examples: A string appended to prompts.NAME_EXTRACTION_INSTRUCTIONS containing examples.
validate: If True, entity schema will be validated on every insert or update.
validation_action: One of {"warn", "error"}.
- If "warn", the default, documents will be inserted but errors logged.
Expand Down Expand Up @@ -204,7 +204,7 @@ def from_connection_string(
allowed_entity_types: If provided, constrains search to these types.
allowed_relationship_types: If provided, constrains search to these types.
entity_examples: A string containing any number of additional examples to provide as context for entity extraction.
entity_name_examples: A string appended to schema.name_extraction_instructions containing examples.
entity_name_examples: A string appended to prompts.NAME_EXTRACTION_INSTRUCTIONS containing examples.
validate: If True, entity schema will be validated on every insert or update.
validation_action: One of {"warn", "error"}.
- If "warn", the default, documents will be inserted but errors logged.
Expand Down
12 changes: 6 additions & 6 deletions libs/langchain-mongodb/langchain_mongodb/graphrag/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SystemMessagePromptTemplate,
)

entity_extraction_instructions = """
ENTITY_EXTRACTION_INSTRUCTIONS = """
## Overview
You are a meticulous analyst tasked with extracting information from unstructured text
to build a knowledge graph in a structured json format of entities (nodes) and their relationships (edges).
Expand Down Expand Up @@ -81,7 +81,7 @@
"""


name_extraction_instructions = """
NAME_EXTRACTION_INSTRUCTIONS = """
You are a meticulous analyst tasked with extracting information from documents to form
knowledge graphs of entities (nodes) and their relationships (edges).
Expand Down Expand Up @@ -129,7 +129,7 @@
"""


rag_instructions = """
RAG_INSTRUCTIONS = """
## Context
You are a meticulous analyst tasked with extracting information in the form of knowledge graphs
comprised of entities (nodes) and their relationships (edges).
Expand All @@ -151,21 +151,21 @@

entity_prompt = ChatPromptTemplate.from_messages(
[
SystemMessagePromptTemplate.from_template(entity_extraction_instructions),
SystemMessagePromptTemplate.from_template(ENTITY_EXTRACTION_INSTRUCTIONS),
HumanMessagePromptTemplate.from_template("{input_document}"),
]
)

query_prompt = ChatPromptTemplate.from_messages(
[
SystemMessagePromptTemplate.from_template(name_extraction_instructions),
SystemMessagePromptTemplate.from_template(NAME_EXTRACTION_INSTRUCTIONS),
HumanMessagePromptTemplate.from_template("{input_document}"),
]
)

rag_prompt = ChatPromptTemplate.from_messages(
[
SystemMessagePromptTemplate.from_template(rag_instructions),
SystemMessagePromptTemplate.from_template(RAG_INSTRUCTIONS),
HumanMessagePromptTemplate.from_template("{query}"),
]
)

0 comments on commit 3bbf258

Please sign in to comment.