mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 19:47:13 +00:00
@@ -3,47 +3,59 @@ import multiprocessing
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
# List of 4-tuples (integration_name, display_name, concept_page, how_to_fragment)
|
||||
INTEGRATION_INFO = [
|
||||
("chat", "Chat model", "chat_models", "chat-models"),
|
||||
("llms", "LLM", "text_llms", "llms"),
|
||||
("text_embedding", "Embedding model", "embedding_models", "embedding-models"),
|
||||
("document_loaders", "Document loader", "document_loaders", "document-loaders"),
|
||||
("vectorstores", "Vector store", "vectorstores", "vector-stores"),
|
||||
("retrievers", "Retriever", "retrievers", "retrievers"),
|
||||
("tools", "Tool", "tools", "tools"),
|
||||
# stores is a special case because there are no key-value store how-tos yet
|
||||
# this is a placeholder for when we do have them
|
||||
# for now the related links section will only contain the conceptual guide.
|
||||
("stores", "Key-value store", "key_value_stores", "key-value-stores"),
|
||||
]
|
||||
|
||||
def _generate_related_links_section(integration_type: str, notebook_name: str):
|
||||
concept_display_name = None
|
||||
concept_heading = None
|
||||
if integration_type == "chat":
|
||||
concept_display_name = "Chat model"
|
||||
concept_heading = "chat-models"
|
||||
elif integration_type == "llms":
|
||||
concept_display_name = "LLM"
|
||||
concept_heading = "llms"
|
||||
elif integration_type == "text_embedding":
|
||||
concept_display_name = "Embedding model"
|
||||
concept_heading = "embedding-models"
|
||||
elif integration_type == "document_loaders":
|
||||
concept_display_name = "Document loader"
|
||||
concept_heading = "document-loaders"
|
||||
elif integration_type == "vectorstores":
|
||||
concept_display_name = "Vector store"
|
||||
concept_heading = "vector-stores"
|
||||
elif integration_type == "retrievers":
|
||||
concept_display_name = "Retriever"
|
||||
concept_heading = "retrievers"
|
||||
elif integration_type == "tools":
|
||||
concept_display_name = "Tool"
|
||||
concept_heading = "tools"
|
||||
elif integration_type == "stores":
|
||||
concept_display_name = "Key-value store"
|
||||
concept_heading = "key-value-stores"
|
||||
# Special case because there are no key-value store how-tos yet
|
||||
return f"""## Related
|
||||
# Create a dictionary with key being the first element (integration_name) and value being the rest of the tuple
|
||||
INTEGRATION_INFO_DICT = {
|
||||
integration_name: rest for integration_name, *rest in INTEGRATION_INFO
|
||||
}
|
||||
|
||||
- [{concept_display_name} conceptual guide](/docs/concepts/#{concept_heading})
|
||||
RELATED_LINKS_SECTION = """## Related
|
||||
- {concept_display_name} [conceptual guide](/docs/concepts/{concept_page})
|
||||
- {concept_display_name} [how-to guides](/docs/how_to/#{how_to_fragment})
|
||||
"""
|
||||
else:
|
||||
|
||||
RELATED_LINKS_WITHOUT_HOW_TO_SECTION = """## Related
|
||||
- {concept_display_name} [conceptual guide](/docs/concepts/{concept_page})
|
||||
"""
|
||||
|
||||
|
||||
def _generate_related_links_section(
|
||||
integration_type: str, notebook_name: str
|
||||
) -> Optional[str]:
|
||||
if integration_type not in INTEGRATION_INFO_DICT:
|
||||
return None
|
||||
return f"""## Related
|
||||
concept_display_name, concept_page, how_to_fragment = INTEGRATION_INFO_DICT[
|
||||
integration_type
|
||||
]
|
||||
|
||||
- {concept_display_name} [conceptual guide](/docs/concepts/#{concept_heading})
|
||||
- {concept_display_name} [how-to guides](/docs/how_to/#{concept_heading})
|
||||
"""
|
||||
# Special case because there are no key-value store how-tos yet
|
||||
if integration_type == "stores":
|
||||
return RELATED_LINKS_WITHOUT_HOW_TO_SECTION.format(
|
||||
concept_display_name=concept_display_name,
|
||||
concept_page=concept_page,
|
||||
)
|
||||
|
||||
return RELATED_LINKS_SECTION.format(
|
||||
concept_display_name=concept_display_name,
|
||||
concept_page=concept_page,
|
||||
how_to_fragment=how_to_fragment,
|
||||
)
|
||||
|
||||
|
||||
def _process_path(doc_path: Path):
|
||||
|
Reference in New Issue
Block a user