Skip to content

Commit

Permalink
deploy: 629246a
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 2, 2024
1 parent 5c2145d commit 024dcb5
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 20 deletions.
Binary file modified .doctrees/apis/core/core.base_data_class.doctree
Binary file not shown.
Binary file modified .doctrees/developer_notes/base_data_class.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/get_started/installation.doctree
Binary file not shown.
2 changes: 2 additions & 0 deletions _modules/core/base_data_class.html
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,9 @@ <h1>Source code for core.base_data_class</h1><div class="highlight"><pre>

<span class="s2"> # Define a dataclass</span>
<span class="s2"> from lightrag.core import DataClass</span>
<span class="s2"> from dataclasses import dataclass, field</span>

<span class="s2"> @dataclass</span>
<span class="s2"> class MyOutputs(DataClass):</span>
<span class="s2"> age: int = field(metadata={&quot;desc&quot;: &quot;The age of the person&quot;, &quot;prefix&quot;: &quot;Age:&quot;})</span>
<span class="s2"> name: str = field(metadata={&quot;desc&quot;: &quot;The name of the person&quot;, &quot;prefix&quot;: &quot;Name:&quot;})</span>
Expand Down
12 changes: 6 additions & 6 deletions _sources/developer_notes/base_data_class.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ Here is how you can do it with a ``DataClass`` subclass:
example = TrecData2(Question("What is the capital of France?"), 1, {"key": "value"})
print(example)
dict_example = TrecData2.to_dict(example)
dict_example = example.to_dict()
print(dict_example)
reconstructed = TrecData2.from_dict(dict_example)
Expand All @@ -466,10 +466,10 @@ Here is how it works with ``DataClass`` subclass:

.. code-block:: python
json_str = TrecData2.to_json(example)
json_str = example.to_json()
print(json_str)
yaml_str = TrecData2.to_yaml(example)
yaml_str = example.to_yaml(example)
print(yaml_str)
reconstructed_from_json = TrecData2.from_json(json_str)
Expand Down Expand Up @@ -514,10 +514,10 @@ Similarly, (1) all ``to_dict``, ``to_json``, and ``to_yaml`` works with `exclude
from lightrag.core import DataClassFormatType
example_str = TrecData2.format_example_str(example, DataClassFormatType.EXAMPLE_JSON)
example_str = example.format_example_str(DataClassFormatType.EXAMPLE_JSON)
print(example_str)
example_str = TrecData2.format_example_str(example, DataClassFormatType.EXAMPLE_YAML)
example_str = example.format_example_str(DataClassFormatType.EXAMPLE_YAML)
print(example_str)
Expand Down Expand Up @@ -580,7 +580,7 @@ You can simply do a bit customization to map the dataset's key to the field name
class_index: int = field(metadata={"desc": "class_index in range[0, 5]"})
@classmethod
def from_dict(cls, data: Dict[str, Any]):
def from_dict(cls, data: Dict[str, object]):
_COARSE_LABELS_DESC = [
"Abbreviation",
"Entity",
Expand Down
7 changes: 5 additions & 2 deletions _sources/get_started/installation.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ You can use the following import:

.. code-block:: python
from lightrag.utils import setup_env #noqa
from lightrag.utils import setup_env()
setup_env()
Or, you can load it yourself with ``python-dotenv``:

Expand All @@ -49,9 +51,10 @@ Or, you can load it yourself with ``python-dotenv``:
from dotenv import load_dotenv
load_dotenv() # This loads the environment variables from `.env`.
You can place the above code in your project's root ``__init__.py`` file.
This setup ensures that LightRAG can access all necessary configurations during runtime.

4. Install Optional Packages
1. Install Optional Packages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Expand Down
2 changes: 2 additions & 0 deletions apis/core/core.base_data_class.html
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,9 @@
<p>Examples:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Define a dataclass</span>
<span class="kn">from</span> <span class="nn">lightrag.core</span> <span class="kn">import</span> <span class="n">DataClass</span>
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span><span class="p">,</span> <span class="n">field</span>

<span class="nd">@dataclass</span>
<span class="k">class</span> <span class="nc">MyOutputs</span><span class="p">(</span><span class="n">DataClass</span><span class="p">):</span>
<span class="n">age</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">metadata</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;The age of the person&quot;</span><span class="p">,</span> <span class="s2">&quot;prefix&quot;</span><span class="p">:</span> <span class="s2">&quot;Age:&quot;</span><span class="p">})</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">metadata</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;The name of the person&quot;</span><span class="p">,</span> <span class="s2">&quot;prefix&quot;</span><span class="p">:</span> <span class="s2">&quot;Name:&quot;</span><span class="p">})</span>
Expand Down
12 changes: 6 additions & 6 deletions developer_notes/base_data_class.html
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ <h3>Show data examples &amp; parse string to data instance<a class="headerlink"
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">example</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="p">(</span><span class="n">Question</span><span class="p">(</span><span class="s2">&quot;What is the capital of France?&quot;</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="p">{</span><span class="s2">&quot;key&quot;</span><span class="p">:</span> <span class="s2">&quot;value&quot;</span><span class="p">})</span>
<span class="nb">print</span><span class="p">(</span><span class="n">example</span><span class="p">)</span>

<span class="n">dict_example</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="o">.</span><span class="n">to_dict</span><span class="p">(</span><span class="n">example</span><span class="p">)</span>
<span class="n">dict_example</span> <span class="o">=</span> <span class="n">example</span><span class="o">.</span><span class="n">to_dict</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="n">dict_example</span><span class="p">)</span>

<span class="n">reconstructed</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">dict_example</span><span class="p">)</span>
Expand All @@ -773,10 +773,10 @@ <h3>Show data examples &amp; parse string to data instance<a class="headerlink"
<li><p><code class="docutils literal notranslate"><span class="pre">from_json</span></code> (from json string to reconstruct instance) and <code class="docutils literal notranslate"><span class="pre">to_json</span></code> (a json string)</p></li>
</ul>
<p>Here is how it works with <code class="docutils literal notranslate"><span class="pre">DataClass</span></code> subclass:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">json_str</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="o">.</span><span class="n">to_json</span><span class="p">(</span><span class="n">example</span><span class="p">)</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">json_str</span> <span class="o">=</span> <span class="n">example</span><span class="o">.</span><span class="n">to_json</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="n">json_str</span><span class="p">)</span>

<span class="n">yaml_str</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="o">.</span><span class="n">to_yaml</span><span class="p">(</span><span class="n">example</span><span class="p">)</span>
<span class="n">yaml_str</span> <span class="o">=</span> <span class="n">example</span><span class="o">.</span><span class="n">to_yaml</span><span class="p">(</span><span class="n">example</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">yaml_str</span><span class="p">)</span>

<span class="n">reconstructed_from_json</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="o">.</span><span class="n">from_json</span><span class="p">(</span><span class="n">json_str</span><span class="p">)</span>
Expand Down Expand Up @@ -816,10 +816,10 @@ <h3>Show data examples &amp; parse string to data instance<a class="headerlink"
(2) you can use <code class="docutils literal notranslate"><span class="pre">DataClassFormatType</span></code> along with <code class="docutils literal notranslate"><span class="pre">format_example_str</span></code> method to specify the format type for the data example methods.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lightrag.core</span> <span class="kn">import</span> <span class="n">DataClassFormatType</span>

<span class="n">example_str</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="o">.</span><span class="n">format_example_str</span><span class="p">(</span><span class="n">example</span><span class="p">,</span> <span class="n">DataClassFormatType</span><span class="o">.</span><span class="n">EXAMPLE_JSON</span><span class="p">)</span>
<span class="n">example_str</span> <span class="o">=</span> <span class="n">example</span><span class="o">.</span><span class="n">format_example_str</span><span class="p">(</span><span class="n">DataClassFormatType</span><span class="o">.</span><span class="n">EXAMPLE_JSON</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">example_str</span><span class="p">)</span>

<span class="n">example_str</span> <span class="o">=</span> <span class="n">TrecData2</span><span class="o">.</span><span class="n">format_example_str</span><span class="p">(</span><span class="n">example</span><span class="p">,</span> <span class="n">DataClassFormatType</span><span class="o">.</span><span class="n">EXAMPLE_YAML</span><span class="p">)</span>
<span class="n">example_str</span> <span class="o">=</span> <span class="n">example</span><span class="o">.</span><span class="n">format_example_str</span><span class="p">(</span><span class="n">DataClassFormatType</span><span class="o">.</span><span class="n">EXAMPLE_YAML</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">example_str</span><span class="p">)</span>
</pre></div>
</div>
Expand All @@ -841,7 +841,7 @@ <h3>Load data from dataset as example<a class="headerlink" href="#load-data-from
<span class="n">class_index</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">field</span><span class="p">(</span><span class="n">metadata</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;class_index in range[0, 5]&quot;</span><span class="p">})</span>

<span class="nd">@classmethod</span>
<span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">data</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]):</span>
<span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">data</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">object</span><span class="p">]):</span>
<span class="n">_COARSE_LABELS_DESC</span> <span class="o">=</span> <span class="p">[</span>
<span class="s2">&quot;Abbreviation&quot;</span><span class="p">,</span>
<span class="s2">&quot;Entity&quot;</span><span class="p">,</span>
Expand Down
2 changes: 1 addition & 1 deletion get_started/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ <h1>Get Started<a class="headerlink" href="#get-started" title="Link to this hea
<li class="toctree-l2"><a class="reference internal" href="installation.html#install-lightrag">1. Install LightRAG</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#set-up-api-keys">2. Set up API keys</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#load-environment-variables">3. Load environment variables</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#install-optional-packages">4. Install Optional Packages</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html#install-optional-packages">1. Install Optional Packages</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="community.html">Community</a></li>
Expand Down
11 changes: 7 additions & 4 deletions get_started/installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,18 +452,21 @@ <h2>2. Set up API keys<a class="headerlink" href="#set-up-api-keys" title="Link
<section id="load-environment-variables">
<h2>3. Load environment variables<a class="headerlink" href="#load-environment-variables" title="Link to this heading">#</a></h2>
<p>You can use the following import:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lightrag.utils</span> <span class="kn">import</span> <span class="n">setup_env</span> <span class="c1">#noqa</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">lightrag.utils</span> <span class="kn">import</span> <span class="n">setup_env</span><span class="p">()</span>

<span class="n">setup_env</span><span class="p">()</span>
</pre></div>
</div>
<p>Or, you can load it yourself with <code class="docutils literal notranslate"><span class="pre">python-dotenv</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">dotenv</span> <span class="kn">import</span> <span class="n">load_dotenv</span>
<span class="n">load_dotenv</span><span class="p">()</span> <span class="c1"># This loads the environment variables from `.env`.</span>
</pre></div>
</div>
<p>This setup ensures that LightRAG can access all necessary configurations during runtime.</p>
<p>You can place the above code in your project’s root <code class="docutils literal notranslate"><span class="pre">__init__.py</span></code> file.
This setup ensures that LightRAG can access all necessary configurations during runtime.</p>
</section>
<section id="install-optional-packages">
<h2>4. Install Optional Packages<a class="headerlink" href="#install-optional-packages" title="Link to this heading">#</a></h2>
<h2>1. Install Optional Packages<a class="headerlink" href="#install-optional-packages" title="Link to this heading">#</a></h2>
<p>LightRAG currently has built-in support for (1) OpenAI, Groq, Anthropic, Google, and Cohere, and (2) FAISS and Transformers.
You can find all optional packages at <a class="reference internal" href="../apis/utils/utils.lazy_import.html#utils.lazy_import.OptionalPackages" title="utils.lazy_import.OptionalPackages"><code class="xref py py-class docutils literal notranslate"><span class="pre">utils.lazy_import.OptionalPackages</span></code></a>.
Make sure to install the necessary SDKs for the components you plan to use.
Expand Down Expand Up @@ -530,7 +533,7 @@ <h2>4. Install Optional Packages<a class="headerlink" href="#install-optional-pa
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#install-lightrag">1. Install LightRAG</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#set-up-api-keys">2. Set up API keys</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#load-environment-variables">3. Load environment variables</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#install-optional-packages">4. Install Optional Packages</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#install-optional-packages">1. Install Optional Packages</a></li>
</ul>
</nav></div>

Expand Down
Binary file modified objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 024dcb5

Please sign in to comment.