Skip to content

Commit

Permalink
fix: standardise APIs according to FE + usage document
Browse files Browse the repository at this point in the history
  • Loading branch information
yashbonde committed Jul 4, 2023
1 parent 8b4f01e commit 64df199
Show file tree
Hide file tree
Showing 64 changed files with 2,603 additions and 904 deletions.
Binary file modified api_docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified api_docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file modified api_docs/_build/doctrees/install.doctree
Binary file not shown.
Binary file modified api_docs/_build/doctrees/source/chainfury.client.doctree
Binary file not shown.
Binary file modified api_docs/_build/doctrees/source/chainfury.components.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified api_docs/_build/doctrees/usage.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion api_docs/_build/html/_modules/chainfury/agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.utils.html">chainfury utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.version.html">Version</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Third Party Components:</span></p>
<p class="caption" role="heading"><span class="caption-text">Integrations:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.components.html">chainfury Components</a></li>
</ul>
Expand Down
5 changes: 3 additions & 2 deletions api_docs/_build/html/_modules/chainfury/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.utils.html">chainfury utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.version.html">Version</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Third Party Components:</span></p>
<p class="caption" role="heading"><span class="caption-text">Integrations:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.components.html">chainfury Components</a></li>
</ul>
Expand Down Expand Up @@ -96,6 +96,7 @@ <h1>Source code for chainfury.base</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">jinja2schema</span> <span class="kn">import</span> <span class="n">model</span> <span class="k">as</span> <span class="n">j2sm</span>

<span class="kn">from</span> <span class="nn">chainfury.utils</span> <span class="kn">import</span> <span class="n">logger</span><span class="p">,</span> <span class="n">terminal_top_with_text</span>
<span class="kn">from</span> <span class="nn">chainfury.types</span> <span class="kn">import</span> <span class="n">FENode</span>


<div class="viewcode-block" id="Secret"><a class="viewcode-back" href="../../source/chainfury.base.html#chainfury.base.Secret">[docs]</a><span class="k">class</span> <span class="nc">Secret</span><span class="p">(</span><span class="nb">str</span><span class="p">):</span>
Expand Down Expand Up @@ -968,7 +969,7 @@ <h1>Source code for chainfury.base</h1><div class="highlight"><pre>
<span class="n">main_in</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="n">main_out</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="p">{</span><span class="n">node</span><span class="o">.</span><span class="n">id</span><span class="p">:</span> <span class="n">node</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">nodes</span><span class="p">}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">nodes</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">Node</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">node</span><span class="o">.</span><span class="n">id</span><span class="p">:</span> <span class="n">node</span> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">nodes</span><span class="p">}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">edges</span> <span class="o">=</span> <span class="n">edges</span>

<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nodes</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
Expand Down
2 changes: 1 addition & 1 deletion api_docs/_build/html/_modules/chainfury/cli.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.utils.html">chainfury utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.version.html">Version</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Third Party Components:</span></p>
<p class="caption" role="heading"><span class="caption-text">Integrations:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../source/chainfury.components.html">chainfury Components</a></li>
</ul>
Expand Down
162 changes: 94 additions & 68 deletions api_docs/_build/html/_modules/chainfury/client.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.utils.html">chainfury utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.version.html">Version</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Third Party Components:</span></p>
<p class="caption" role="heading"><span class="caption-text">Integrations:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.components.html">chainfury Components</a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.utils.html">chainfury utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.version.html">Version</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Third Party Components:</span></p>
<p class="caption" role="heading"><span class="caption-text">Integrations:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.components.html">chainfury Components</a></li>
</ul>
Expand Down
41 changes: 38 additions & 3 deletions api_docs/_build/html/_modules/chainfury/components/nbx.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.utils.html">chainfury utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.version.html">Version</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Third Party Components:</span></p>
<p class="caption" role="heading"><span class="caption-text">Integrations:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../source/chainfury.components.html">chainfury Components</a></li>
</ul>
Expand Down Expand Up @@ -88,12 +88,13 @@ <h1>Source code for chainfury.components.nbx</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">Optional</span>

<span class="kn">from</span> <span class="nn">chainfury</span> <span class="kn">import</span> <span class="n">Secret</span><span class="p">,</span> <span class="n">model_registry</span><span class="p">,</span> <span class="n">exponential_backoff</span><span class="p">,</span> <span class="n">Model</span><span class="p">,</span> <span class="n">UnAuthException</span>
<span class="kn">from</span> <span class="nn">chainfury.components.const</span> <span class="kn">import</span> <span class="n">Env</span>


<div class="viewcode-block" id="nbx_chat_api"><a class="viewcode-back" href="../../../source/chainfury.components.nbx.html#chainfury.components.nbx.nbx_chat_api">[docs]</a><span class="k">def</span> <span class="nf">nbx_chat_api</span><span class="p">(</span>
<span class="n">nbx_deploy_url</span><span class="p">:</span> <span class="n">Secret</span><span class="p">,</span>
<span class="n">nbx_header_token</span><span class="p">:</span> <span class="n">Secret</span><span class="p">,</span>
<span class="n">inputs</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">nbx_deploy_url</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="n">nbx_header_token</span><span class="p">:</span> <span class="n">Secret</span> <span class="o">=</span> <span class="n">Secret</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">),</span>
<span class="n">best_of</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="n">decoder_input_details</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="n">details</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
Expand All @@ -115,7 +116,41 @@ <h1>Source code for chainfury.components.nbx</h1><div class="highlight"><pre>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Any</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Returns a JSON object containing the OpenAI&#39;s API chat response.</span>

<span class="sd"> Args:</span>
<span class="sd"> inputs (str): The prompt to send to the API.</span>
<span class="sd"> nbx_deploy_url (str): The NBX deploy URL. Defaults to the value of NBX_DEPLOY_URL environment variable.</span>
<span class="sd"> nbx_header_token (Secret): The NBX header token. Defaults to the value of NBX_DEPLOY_KEY environment variable.</span>
<span class="sd"> best_of (int): The number of outputs to generate and return. Defaults to 1.</span>
<span class="sd"> decoder_input_details (bool): Whether to return the decoder input details. Defaults to True.</span>
<span class="sd"> details (bool): Whether to return the details. Defaults to True.</span>
<span class="sd"> do_sample (bool): Whether to use sampling. Defaults to True.</span>
<span class="sd"> max_new_tokens (int): The maximum number of tokens to generate. Defaults to 20.</span>
<span class="sd"> repetition_penalty (float): The repetition penalty. Defaults to 1.03.</span>
<span class="sd"> return_full_text (bool): Whether to return the full text. Defaults to False.</span>
<span class="sd"> seed (int): The seed to use for random number generation. Defaults to a random integer between 0 and 2^32 - 1.</span>
<span class="sd"> stop (List[str]): The stop tokens. Defaults to an empty list.</span>
<span class="sd"> temperature (float): The temperature. Defaults to 0.5.</span>
<span class="sd"> top_k (int): The top k. Defaults to 10.</span>
<span class="sd"> top_p (float): The top p. Defaults to 0.95.</span>
<span class="sd"> truncate (int): The truncate. Defaults to None.</span>
<span class="sd"> typical_p (float): The typical p. Defaults to 0.95.</span>
<span class="sd"> watermark (bool): Whether to include the watermark. Defaults to True.</span>
<span class="sd"> retry_count (int): The number of times to retry the API call. Defaults to 3.</span>
<span class="sd"> retry_delay (int): The number of seconds to wait between retries. Defaults to 1.</span>

<span class="sd"> Returns:</span>
<span class="sd"> Any: The JSON object containing the OpenAI&#39;s API chat response.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">nbx_deploy_url</span><span class="p">:</span>
<span class="n">nbx_deploy_url</span> <span class="o">=</span> <span class="n">Env</span><span class="o">.</span><span class="n">NBX_DEPLOY_URL</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">nbx_deploy_url</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;NBX_DEPLOY_URL not set, please set it in your environment or pass it as an argument&quot;</span><span class="p">)</span>

<span class="k">if</span> <span class="ow">not</span> <span class="n">nbx_header_token</span><span class="p">:</span>
<span class="n">nbx_header_token</span> <span class="o">=</span> <span class="n">Secret</span><span class="p">(</span><span class="n">Env</span><span class="o">.</span><span class="n">NBX_DEPLOY_KEY</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">))</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">nbx_header_token</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">&quot;NBX_DEPLOY_KEY not set, please set it in your environment or pass it as an argument&quot;</span><span class="p">)</span>

<span class="n">seed</span> <span class="o">=</span> <span class="n">seed</span> <span class="ow">or</span> <span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="o">**</span><span class="mi">32</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>

Expand Down
Loading

0 comments on commit 64df199

Please sign in to comment.