Skip to content

Commit

Permalink
deploy: c857072
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 26, 2024
1 parent f2159f5 commit 4aa744c
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 65 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .doctrees/apis/datasets/datasets.types.doctree
Binary file not shown.
Binary file modified .doctrees/apis/datasets/index.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
8 changes: 7 additions & 1 deletion _modules/components/model_client/anthropic_client.html
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ <h1>Source code for components.model_client.anthropic_client</h1><div class="hig

<span class="s2"> Visit https://docs.anthropic.com/en/docs/intro-to-claude for more api details.</span>

<span class="s2"> Ensure &quot;max_tokens&quot; are set.</span>
<span class="s2"> Note:</span>

<span class="s2"> As antropic API needs users to set max_tokens, we set up a default value of 512 for the max_tokens.</span>
<span class="s2"> You can override this value by passing the max_tokens in the model_kwargs.</span>

<span class="s2"> Reference: 8/1/2024</span>
<span class="s2"> - https://docs.anthropic.com/en/docs/about-claude/models</span>
Expand All @@ -514,6 +517,7 @@ <h1>Source code for components.model_client.anthropic_client</h1><div class="hig
<span class="bp">self</span><span class="o">.</span><span class="n">chat_completion_parser</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">chat_completion_parser</span> <span class="ow">or</span> <span class="n">get_first_message_content</span>
<span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">default_max_tokens</span> <span class="o">=</span> <span class="mi">512</span>

<div class="viewcode-block" id="AnthropicAPIClient.init_sync_client">
<a class="viewcode-back" href="../../../apis/components/components.model_client.anthropic_client.html#components.model_client.anthropic_client.AnthropicAPIClient.init_sync_client">[docs]</a>
Expand Down Expand Up @@ -580,6 +584,8 @@ <h1>Source code for components.model_client.anthropic_client</h1><div class="hig
<span class="n">api_kwargs</span><span class="p">[</span><span class="s2">&quot;messages&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">{</span><span class="s2">&quot;role&quot;</span><span class="p">:</span> <span class="s2">&quot;user&quot;</span><span class="p">,</span> <span class="s2">&quot;content&quot;</span><span class="p">:</span> <span class="nb">input</span><span class="p">},</span>
<span class="p">]</span>
<span class="k">if</span> <span class="s2">&quot;max_tokens&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">api_kwargs</span><span class="p">:</span>
<span class="n">api_kwargs</span><span class="p">[</span><span class="s2">&quot;max_tokens&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">default_max_tokens</span>
<span class="c1"># if input and input != &quot;&quot;:</span>
<span class="c1"># api_kwargs[&quot;system&quot;] = input</span>
<span class="k">else</span><span class="p">:</span>
Expand Down
38 changes: 36 additions & 2 deletions _modules/components/model_client/bedrock_client.html
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,27 @@ <h1>Source code for components.model_client.bedrock_client</h1><div class="highl
<a class="viewcode-back" href="../../../apis/components/components.model_client.bedrock_client.html#components.model_client.bedrock_client.BedrockAPIClient">[docs]</a>
<span class="k">class</span> <span class="nc">BedrockAPIClient</span><span class="p">(</span><span class="n">ModelClient</span><span class="p">):</span>
<span class="vm">__doc__</span> <span class="o">=</span> <span class="sa">r</span><span class="s2">&quot;&quot;&quot;A component wrapper for the Bedrock API client.</span>

<span class="s2"> Note:</span>

<span class="s2"> This client needs a lot more work to be fully functional.</span>
<span class="s2"> (1) Setup the AWS credentials.</span>
<span class="s2"> (2) Access to the modelId.</span>
<span class="s2"> (3) Convert the modelId to standard model.</span>

<span class="s2"> To setup the AWS credentials, follow the instructions here:</span>
<span class="s2"> https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html</span>

<span class="s2"> Additionally, this medium article is a good reference:</span>
<span class="s2"> https://medium.com/@harangpeter/setting-up-aws-bedrock-for-api-based-text-inference-dc25ab2b216b</span>

<span class="s2"> Visit https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html for more api details.</span>
<span class="s2"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">aws_profile_name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">aws_region_name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">aws_profile_name</span><span class="o">=</span><span class="s2">&quot;default&quot;</span><span class="p">,</span>
<span class="n">aws_region_name</span><span class="o">=</span><span class="s2">&quot;us-west-2&quot;</span><span class="p">,</span> <span class="c1"># Use a supported default region</span>
<span class="n">aws_access_key_id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">aws_secret_access_key</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">aws_session_token</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
Expand Down Expand Up @@ -543,6 +557,8 @@ <h1>Source code for components.model_client.bedrock_client</h1><div class="highl
<span class="n">aws_session_token</span><span class="o">=</span><span class="n">aws_session_token</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">bedrock_runtime</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">client</span><span class="p">(</span><span class="n">service_name</span><span class="o">=</span><span class="s2">&quot;bedrock-runtime&quot;</span><span class="p">,</span> <span class="n">config</span><span class="o">=</span><span class="n">config</span><span class="p">)</span>

<span class="bp">self</span><span class="o">.</span><span class="n">_client</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">client</span><span class="p">(</span><span class="n">service_name</span><span class="o">=</span><span class="s2">&quot;bedrock&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">bedrock_runtime</span></div>


Expand Down Expand Up @@ -579,6 +595,24 @@ <h1>Source code for components.model_client.bedrock_client</h1><div class="highl
<span class="p">)</span></div>


<div class="viewcode-block" id="BedrockAPIClient.list_models">
<a class="viewcode-back" href="../../../apis/components/components.model_client.bedrock_client.html#components.model_client.bedrock_client.BedrockAPIClient.list_models">[docs]</a>
<span class="k">def</span> <span class="nf">list_models</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># Initialize Bedrock client (not runtime)</span>

<span class="k">try</span><span class="p">:</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client</span><span class="o">.</span><span class="n">list_foundation_models</span><span class="p">()</span>
<span class="n">models</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;models&quot;</span><span class="p">,</span> <span class="p">[])</span>
<span class="k">for</span> <span class="n">model</span> <span class="ow">in</span> <span class="n">models</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Model ID: </span><span class="si">{</span><span class="n">model</span><span class="p">[</span><span class="s1">&#39;modelId&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot; Name: </span><span class="si">{</span><span class="n">model</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot; Description: </span><span class="si">{</span><span class="n">model</span><span class="p">[</span><span class="s1">&#39;description&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot; Provider: </span><span class="si">{</span><span class="n">model</span><span class="p">[</span><span class="s1">&#39;provider&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Error listing models: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span></div>


<div class="viewcode-block" id="BedrockAPIClient.convert_inputs_to_api_kwargs">
<a class="viewcode-back" href="../../../apis/components/components.model_client.bedrock_client.html#components.model_client.bedrock_client.BedrockAPIClient.convert_inputs_to_api_kwargs">[docs]</a>
<span class="k">def</span> <span class="nf">convert_inputs_to_api_kwargs</span><span class="p">(</span>
Expand Down
39 changes: 21 additions & 18 deletions _modules/components/model_client/google_client.html
Original file line number Diff line number Diff line change
Expand Up @@ -481,24 +481,27 @@ <h1>Source code for components.model_client.google_client</h1><div class="highli

<span class="s2"> Info: 8/1/2024</span>
<span class="s2"> Tested: gemini-1.0-pro, gemini-1.5-pro-latest</span>
<span class="s2"> class UsageMetadata(proto.Message):</span>

<span class="s2"> prompt_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=1,</span>
<span class="s2"> )</span>
<span class="s2"> cached_content_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=4,</span>
<span class="s2"> )</span>
<span class="s2"> candidates_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=2,</span>
<span class="s2"> )</span>
<span class="s2"> total_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=3,</span>
<span class="s2"> )</span>

<span class="s2"> .. code-block:: python</span>

<span class="s2"> class UsageMetadata(proto.Message):</span>

<span class="s2"> prompt_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=1,</span>
<span class="s2"> )</span>
<span class="s2"> cached_content_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=4,</span>
<span class="s2"> )</span>
<span class="s2"> candidates_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=2,</span>
<span class="s2"> )</span>
<span class="s2"> total_token_count: int = proto.Field(</span>
<span class="s2"> proto.INT32,</span>
<span class="s2"> number=3,</span>
<span class="s2"> )</span>
<span class="s2"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">api_key</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
Expand Down
2 changes: 1 addition & 1 deletion _modules/core/types.html
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ <h1>Source code for core.types</h1><div class="highlight"><pre>
<span class="n">GroqAPIClient</span><span class="p">,</span>
<span class="n">OpenAIClient</span><span class="p">,</span>
<span class="n">GoogleGenAIClient</span><span class="p">,</span>
<span class="n">OllamaClient</span>
<span class="n">OllamaClient</span><span class="p">,</span>
<span class="p">)</span>


Expand Down
Binary file added _static/images/multi-providers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">ModelClient</span></code></p>
<p>A component wrapper for the Anthropic API client.</p>
<p>Visit <a class="reference external" href="https://docs.anthropic.com/en/docs/intro-to-claude">https://docs.anthropic.com/en/docs/intro-to-claude</a> for more api details.</p>
<p>Ensure “max_tokens” are set.</p>
<p>Note:</p>
<p>As antropic API needs users to set max_tokens, we set up a default value of 512 for the max_tokens.
You can override this value by passing the max_tokens in the model_kwargs.</p>
<p>Reference: 8/1/2024
- <a class="reference external" href="https://docs.anthropic.com/en/docs/about-claude/models">https://docs.anthropic.com/en/docs/about-claude/models</a></p>
<dl class="py method">
Expand Down
Loading

0 comments on commit 4aa744c

Please sign in to comment.