From 14f85cbf7b47d3447469f67ce292148d3eceb9a8 Mon Sep 17 00:00:00 2001 From: Jeff Zhang Date: Fri, 13 Dec 2024 17:01:45 +0800 Subject: [PATCH] [MINOR] Rename from lightrag to adalflow --- .../components/output_parsers/outputs.py | 2 +- adalflow/adalflow/core/__init__.py | 4 ++-- .../adalflow/core/default_prompt_template.py | 20 +++++++++---------- adalflow/adalflow/core/generator.py | 4 ++-- adalflow/adalflow/core/model_client.py | 6 +++--- adalflow/adalflow/core/prompt_builder.py | 4 ++-- docs/source/tutorials/generator.rst | 4 ++-- docs/source/tutorials/prompt.rst | 8 ++++---- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/adalflow/adalflow/components/output_parsers/outputs.py b/adalflow/adalflow/components/output_parsers/outputs.py index 1f4ff652..288cba67 100644 --- a/adalflow/adalflow/components/output_parsers/outputs.py +++ b/adalflow/adalflow/components/output_parsers/outputs.py @@ -75,7 +75,7 @@ class OutputParser(Component): This interface helps users customize output parsers with consistent interfaces for the Generator. Even though you don't always need to subclass it. - LightRAG uses two core components: + AdalFlow uses two core components: 1. the Prompt to format output instruction 2. A string parser component from core.string_parser for response parsing. """ diff --git a/adalflow/adalflow/core/__init__.py b/adalflow/adalflow/core/__init__.py index 852bc6f6..38472520 100644 --- a/adalflow/adalflow/core/__init__.py +++ b/adalflow/adalflow/core/__init__.py @@ -3,7 +3,7 @@ from .component import Component, FunComponent, fun_to_component from .container import Sequential from .db import LocalDB -from .default_prompt_template import DEFAULT_LIGHTRAG_SYSTEM_PROMPT +from .default_prompt_template import DEFAULT_ADALFLOW_SYSTEM_PROMPT from .embedder import Embedder, BatchEmbedder from .generator import Generator, BackwardEngine from .model_client import ModelClient @@ -58,7 +58,7 @@ "Generator", "BackwardEngine", "Prompt", - "DEFAULT_LIGHTRAG_SYSTEM_PROMPT", + "DEFAULT_ADALFLOW_SYSTEM_PROMPT", # "Parameter", "required_field", "ModelClient", diff --git a/adalflow/adalflow/core/default_prompt_template.py b/adalflow/adalflow/core/default_prompt_template.py index 6837e22d..6bdd568e 100644 --- a/adalflow/adalflow/core/default_prompt_template.py +++ b/adalflow/adalflow/core/default_prompt_template.py @@ -1,16 +1,16 @@ -"""This is the default system prompt template used in the LightRAG. +"""This is the default system prompt template used in the AdalFlow. Use :ref:`Prompt ` class to manage it. """ __all__ = [ - "LIGHTRAG_DEFAULT_PROMPT_ARGS", - "LIGHTRAG_DEFAULT_PROMPT_TRAINABLE_PARAMS", - "SIMPLE_DEFAULT_LIGHTRAG_SYSTEM_PROMPT", - "DEFAULT_LIGHTRAG_SYSTEM_PROMPT", + "ADALFLOW_DEFAULT_PROMPT_ARGS", + "ADALFLOW_DEFAULT_PROMPT_TRAINABLE_PARAMS", + "SIMPLE_DEFAULT_ADALFLOW_SYSTEM_PROMPT", + "DEFAULT_ADALFLOW_SYSTEM_PROMPT", ] # TODO: potentially make a data class for this -LIGHTRAG_DEFAULT_PROMPT_ARGS = [ +ADALFLOW_DEFAULT_PROMPT_ARGS = [ "task_desc_str", # task description "output_format_str", # output format of the task "tools_str", # tools used in the task @@ -21,17 +21,17 @@ "input_str", # user query or input ] -LIGHTRAG_DEFAULT_PROMPT_TRAINABLE_PARAMS = [ +ADALFLOW_DEFAULT_PROMPT_TRAINABLE_PARAMS = [ "task_desc_str", # "output_format_str", "examples_str", ] -SIMPLE_DEFAULT_LIGHTRAG_SYSTEM_PROMPT = r"""{{task_desc_str}} +SIMPLE_DEFAULT_ADALFLOW_SYSTEM_PROMPT = r"""{{task_desc_str}} User: {{input_str}} You:""" -DEFAULT_LIGHTRAG_SYSTEM_PROMPT = r""" +DEFAULT_ADALFLOW_SYSTEM_PROMPT = r""" {# task desc #} {% if task_desc_str %} {{task_desc_str}} @@ -87,7 +87,7 @@ {% endif %} """ -"""This is the default system prompt template used in the LightRAG. +"""This is the default system prompt template used in the AdalFlow. Use :ref:`Prompt ` class to manage it. """ diff --git a/adalflow/adalflow/core/generator.py b/adalflow/adalflow/core/generator.py index 309f954f..dd0ff5f6 100644 --- a/adalflow/adalflow/core/generator.py +++ b/adalflow/adalflow/core/generator.py @@ -26,7 +26,7 @@ from adalflow.core.prompt_builder import Prompt from adalflow.core.functional import compose_model_kwargs from adalflow.core.model_client import ModelClient -from adalflow.core.default_prompt_template import DEFAULT_LIGHTRAG_SYSTEM_PROMPT +from adalflow.core.default_prompt_template import DEFAULT_ADALFLOW_SYSTEM_PROMPT from adalflow.optim.function import BackwardContext from adalflow.utils.cache import CachedEngine from adalflow.tracing.callback_manager import CallbackManager @@ -113,7 +113,7 @@ def __init__( Got {model_client} instead." ) - template = template or DEFAULT_LIGHTRAG_SYSTEM_PROMPT + template = template or DEFAULT_ADALFLOW_SYSTEM_PROMPT # create the cache path and initialize the cache engine diff --git a/adalflow/adalflow/core/model_client.py b/adalflow/adalflow/core/model_client.py index fb825f02..31399eb6 100644 --- a/adalflow/adalflow/core/model_client.py +++ b/adalflow/adalflow/core/model_client.py @@ -25,7 +25,7 @@ class ModelClient(Component): (1) Initialize the client, including both sync and async. -(2) Convert the standard LightRAG components inputs to the API-specific format. +(2) Convert the standard AdalFlow components inputs to the API-specific format. (3) Call the API and parse the response. @@ -33,7 +33,7 @@ class ModelClient(Component): Check the subclasses in `components/model_client/` directory for the functional API clients we have. - This interface is designed to bridge the gap between LightRAG components inputs and model APIs. + This interface is designed to bridge the gap between AdalFlow components inputs and model APIs. You can see examples of the subclasses in components/model_client/ directory. """ @@ -103,7 +103,7 @@ def track_completion_usage(self, *args, **kwargs) -> "CompletionUsage": ) def parse_embedding_response(self, response: Any) -> "EmbedderOutput": - r"""Parse the embedding response to a structure LightRAG components can understand.""" + r"""Parse the embedding response to a structure AdalFlow components can understand.""" raise NotImplementedError( f"{type(self).__name__} must implement parse_embedding_response method" ) diff --git a/adalflow/adalflow/core/prompt_builder.py b/adalflow/adalflow/core/prompt_builder.py index 03a61959..eca45557 100644 --- a/adalflow/adalflow/core/prompt_builder.py +++ b/adalflow/adalflow/core/prompt_builder.py @@ -8,7 +8,7 @@ from adalflow.core.component import Component -from adalflow.core.default_prompt_template import DEFAULT_LIGHTRAG_SYSTEM_PROMPT +from adalflow.core.default_prompt_template import DEFAULT_ADALFLOW_SYSTEM_PROMPT from adalflow.optim.parameter import Parameter @@ -56,7 +56,7 @@ def __init__( ): super().__init__() - self.template = template or DEFAULT_LIGHTRAG_SYSTEM_PROMPT + self.template = template or DEFAULT_ADALFLOW_SYSTEM_PROMPT self.__create_jinja2_template() self.prompt_variables: List[str] = [] for var in self._find_template_variables(self.template): diff --git a/docs/source/tutorials/generator.rst b/docs/source/tutorials/generator.rst index 53c8e7fd..a170a8de 100644 --- a/docs/source/tutorials/generator.rst +++ b/docs/source/tutorials/generator.rst @@ -55,7 +55,7 @@ An Orchestrator It orchestrates three components: - `Prompt`: by taking in ``template`` (string) and ``prompt_kwargs`` (dict) to format the prompt at initialization. - When the ``template`` is not provided, it defaults to :const:`DEFAULT_LIGHTRAG_SYSTEM_PROMPT`. + When the ``template`` is not provided, it defaults to :const:`DEFAULT_ADALFLOW_SYSTEM_PROMPT`. - `ModelClient`: by taking in an already instantiated ``model_client`` and ``model_kwargs`` to call the model. Switching out the model client allows you to call any LLM model using the same prompt and output parsing. @@ -485,7 +485,7 @@ It will require users to define ``Parameter`` and pass it to the ``prompt_kwargs - :class:`core.generator.Generator` - :class:`core.types.GeneratorOutput` - - :class:`core.default_prompt_template.DEFAULT_LIGHTRAG_SYSTEM_PROMPT` + - :class:`core.default_prompt_template.DEFAULT_ADALFLOW_SYSTEM_PROMPT` - :class:`core.types.ModelClientType` - :class:`core.types.ModelType` - :class:`core.string_parser.JsonParser` diff --git a/docs/source/tutorials/prompt.rst b/docs/source/tutorials/prompt.rst index 073ba087..6c393b07 100644 --- a/docs/source/tutorials/prompt.rst +++ b/docs/source/tutorials/prompt.rst @@ -6,7 +6,7 @@ Try Quickstart in Colab - + GitHub Open Source Code @@ -206,13 +206,13 @@ As with all components, you can use ``to_dict`` and ``from_dict`` to serialize a Default Prompt Template ------------------------- -In default, the ``Prompt`` class uses the :const:`DEFAULT_LIGHTRAG_SYSTEM_PROMPT` as its string template if no template is provided. +In default, the ``Prompt`` class uses the :const:`DEFAULT_ADALFLOW_SYSTEM_PROMPT` as its string template if no template is provided. This default template allows you to conditionally passing seven important variables designed from the data flow diagram above. These varaibles are: .. code-block:: python - LIGHTRAG_DEFAULT_PROMPT_ARGS = [ + ADALFLOW_DEFAULT_PROMPT_ARGS = [ "task_desc_str", # task description "output_format_str", # output format of the task "tools_str", # tools used in the task @@ -266,4 +266,4 @@ The output will be the bare minimum with only the user query and a prefix for as :class: highlight - :class:`core.prompt_builder.Prompt` - - :const:`core.default_prompt_template.DEFAULT_LIGHTRAG_SYSTEM_PROMPT` + - :const:`core.default_prompt_template.DEFAULT_ADALFLOW_SYSTEM_PROMPT`