Skip to content

Commit

Permalink
deploy: 0f6bba4
Browse files Browse the repository at this point in the history
  • Loading branch information
vkehfdl1 committed Dec 19, 2024
1 parent 4bfb2a7 commit 8d6f378
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
Binary file modified .doctrees/api_spec/autorag.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/nodes/passage_reranker/cohere.doctree
Binary file not shown.
12 changes: 7 additions & 5 deletions _modules/autorag/nodes/passagereranker/cohere.html
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,15 @@ <h1>Source code for autorag.nodes.passagereranker.cohere</h1><div class="highlig
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">project_dir</span><span class="p">)</span>
<span class="n">api_key</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;api_key&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
<span class="n">api_key</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;COHERE_API_KEY&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">if</span> <span class="n">api_key</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">api_key</span>
<span class="k">if</span> <span class="n">api_key</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">api_key</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;CO_API_KEY&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
<span class="k">if</span> <span class="n">api_key</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span>
<span class="s2">&quot;Please set the API key for Cohere rerank in the environment variable COHERE_API_KEY &quot;</span>
<span class="s2">&quot;or directly set it on the config YAML file.&quot;</span>
<span class="p">)</span>

<span class="bp">self</span><span class="o">.</span><span class="n">cohere_client</span> <span class="o">=</span> <span class="n">cohere</span><span class="o">.</span><span class="n">AsyncClient</span><span class="p">(</span><span class="n">api_key</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cohere_client</span> <span class="o">=</span> <span class="n">cohere</span><span class="o">.</span><span class="n">AsyncClientV2</span><span class="p">(</span><span class="n">api_key</span><span class="o">=</span><span class="n">api_key</span><span class="p">)</span>

<span class="k">def</span> <span class="fm">__del__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">cohere_client</span>
Expand All @@ -447,7 +449,7 @@ <h1>Source code for autorag.nodes.passagereranker.cohere</h1><div class="highlig
<span class="n">queries</span><span class="p">,</span> <span class="n">contents</span><span class="p">,</span> <span class="n">scores</span><span class="p">,</span> <span class="n">ids</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_to_run</span><span class="p">(</span><span class="n">previous_result</span><span class="p">)</span>
<span class="n">top_k</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;top_k&quot;</span><span class="p">)</span>
<span class="n">batch</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;batch&quot;</span><span class="p">,</span> <span class="mi">64</span><span class="p">)</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;model&quot;</span><span class="p">,</span> <span class="s2">&quot;rerank-multilingual-v2.0&quot;</span><span class="p">)</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;model&quot;</span><span class="p">,</span> <span class="s2">&quot;rerank-v3.5&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pure</span><span class="p">(</span><span class="n">queries</span><span class="p">,</span> <span class="n">contents</span><span class="p">,</span> <span class="n">scores</span><span class="p">,</span> <span class="n">ids</span><span class="p">,</span> <span class="n">top_k</span><span class="p">,</span> <span class="n">batch</span><span class="p">,</span> <span class="n">model</span><span class="p">)</span></div>


Expand All @@ -459,7 +461,7 @@ <h1>Source code for autorag.nodes.passagereranker.cohere</h1><div class="highlig
<span class="n">ids_list</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]],</span>
<span class="n">top_k</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
<span class="n">batch</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">64</span><span class="p">,</span>
<span class="n">model</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;rerank-multilingual-v2.0&quot;</span><span class="p">,</span>
<span class="n">model</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;rerank-v3.5&quot;</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Tuple</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]],</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]],</span> <span class="n">List</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="nb">float</span><span class="p">]]]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Rerank a list of contents with Cohere rerank models.</span>
Expand All @@ -472,8 +474,8 @@ <h1>Source code for autorag.nodes.passagereranker.cohere</h1><div class="highlig
<span class="sd"> :param top_k: The number of passages to be retrieved</span>
<span class="sd"> :param batch: The number of queries to be processed in a batch</span>
<span class="sd"> :param model: The model name for Cohere rerank.</span>
<span class="sd"> You can choose between &quot;rerank-multilingual-v2.0&quot; and &quot;rerank-english-v2.0&quot;.</span>
<span class="sd"> Default is &quot;rerank-multilingual-v2.0&quot;.</span>
<span class="sd"> You can choose between &quot;rerank-v3.5&quot;, &quot;rerank-english-v3.0&quot;, and &quot;rerank-multilingual-v3.0&quot;.</span>
<span class="sd"> Default is &quot;rerank-v3.5&quot;.</span>
<span class="sd"> :return: Tuple of lists containing the reranked contents, ids, and scores</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Run async cohere_rerank_pure function</span>
Expand Down
11 changes: 9 additions & 2 deletions _sources/nodes/passage_reranker/cohere.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Next, you can set your Cohere API key in the environment variable.
export COHERE_API_KEY=your_cohere_api_key
```

or

```bash
export CO_API_KEY=your_cohere_api_key
```

Or, you can set your Cohere API key in the config.yaml file directly.

```yaml
Expand All @@ -34,8 +40,9 @@ Or, you can set your Cohere API key in the config.yaml file directly.
It sends the batch size of passages to cohere API at once.
If it is too large, it can cause some error.
(default: 64)
- **model** : The type of model you want to use for reranking. Default is "rerank-multilingual-v2.0" and you can change
it to "rerank-multilingual-v1.0" or "rerank-english-v2.0" (default: "rerank-multilingual-v2.0")
- **model** : The type of model you want to use for reranking.
Default is "rerank-v3.5" and you can change
it to "rerank-v3.5" or "rerank-english-v3.0" or "rerank-multilingual-v3.0"
- **api_key** : The cohere api key.

## **Example config.yaml**
Expand Down
2 changes: 1 addition & 1 deletion api_spec/autorag.html
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ <h2>Submodules<a class="headerlink" href="#submodules" title="Link to this headi

<dl class="py function">
<dt class="sig sig-object py" id="autorag.node_line.run_node_line">
<span class="sig-prename descclassname"><span class="pre">autorag.node_line.</span></span><span class="sig-name descname"><span class="pre">run_node_line</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="pre">nodes:</span> <span class="pre">~typing.List[~autorag.schema.node.Node],</span> <span class="pre">node_line_dir:</span> <span class="pre">str,</span> <span class="pre">previous_result:</span> <span class="pre">~pandas.core.frame.DataFrame</span> <span class="pre">|</span> <span class="pre">None</span> <span class="pre">=</span> <span class="pre">None,</span> <span class="pre">progress:</span> <span class="pre">~rich.progress.Progress</span> <span class="pre">=</span> <span class="pre">None,</span> <span class="pre">task_eval:</span> <span class="pre">&lt;property</span> <span class="pre">object</span> <span class="pre">at</span> <span class="pre">0x7f7ae5a25990&gt;</span> <span class="pre">=</span> <span class="pre">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/autorag/node_line.html#run_node_line"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#autorag.node_line.run_node_line" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">autorag.node_line.</span></span><span class="sig-name descname"><span class="pre">run_node_line</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="pre">nodes:</span> <span class="pre">~typing.List[~autorag.schema.node.Node],</span> <span class="pre">node_line_dir:</span> <span class="pre">str,</span> <span class="pre">previous_result:</span> <span class="pre">~pandas.core.frame.DataFrame</span> <span class="pre">|</span> <span class="pre">None</span> <span class="pre">=</span> <span class="pre">None,</span> <span class="pre">progress:</span> <span class="pre">~rich.progress.Progress</span> <span class="pre">=</span> <span class="pre">None,</span> <span class="pre">task_eval:</span> <span class="pre">&lt;property</span> <span class="pre">object</span> <span class="pre">at</span> <span class="pre">0x7f0249be9a30&gt;</span> <span class="pre">=</span> <span class="pre">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/autorag/node_line.html#run_node_line"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#autorag.node_line.run_node_line" title="Link to this definition"></a></dt>
<dd><p>Run the whole node line by running each node.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
Expand Down
9 changes: 7 additions & 2 deletions nodes/passage_reranker/cohere.html
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ <h2>Before Usage<a class="headerlink" href="#before-usage" title="Link to this h
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">export</span><span class="w"> </span><span class="nv">COHERE_API_KEY</span><span class="o">=</span>your_cohere_api_key
</pre></div>
</div>
<p>or</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nb">export</span><span class="w"> </span><span class="nv">CO_API_KEY</span><span class="o">=</span>your_cohere_api_key
</pre></div>
</div>
<p>Or, you can set your Cohere API key in the config.yaml file directly.</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">module_type</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">cohere_reranker</span>
<span class="w"> </span><span class="nt">api_key</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">your_cohere_api_key</span>
Expand All @@ -434,8 +438,9 @@ <h2><strong>Module Parameters</strong><a class="headerlink" href="#module-parame
It sends the batch size of passages to cohere API at once.
If it is too large, it can cause some error.
(default: 64)</p></li>
<li><p><strong>model</strong> : The type of model you want to use for reranking. Default is “rerank-multilingual-v2.0” and you can change
it to “rerank-multilingual-v1.0” or “rerank-english-v2.0” (default: “rerank-multilingual-v2.0”)</p></li>
<li><p><strong>model</strong> : The type of model you want to use for reranking.
Default is “rerank-v3.5” and you can change
it to “rerank-v3.5” or “rerank-english-v3.0” or “rerank-multilingual-v3.0”</p></li>
<li><p><strong>api_key</strong> : The cohere api key.</p></li>
</ul>
</section>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 8d6f378

Please sign in to comment.