Skip to content

Commit

Permalink
updated index document
Browse files Browse the repository at this point in the history
  • Loading branch information
ardan-bkennedy committed Jun 4, 2024
1 parent 975993e commit caebf6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<pre><code><span class="hl-0"> </span><span class="hl-1">$</span><span class="hl-0"> </span><span class="hl-1">npm</span><span class="hl-0"> </span><span class="hl-1">i</span><span class="hl-0"> </span><span class="hl-1">predictionguard</span>
</code><button>Copy</button></pre>
<p><strong>Code Example</strong></p>
<pre><code class="language-js"><span class="hl-2">import</span><span class="hl-0"> </span><span class="hl-3">*</span><span class="hl-0"> </span><span class="hl-2">as</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0"> </span><span class="hl-2">from</span><span class="hl-0"> </span><span class="hl-4">&#39;predictionguard&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-3">const</span><span class="hl-0"> </span><span class="hl-5">client</span><span class="hl-0"> = </span><span class="hl-3">new</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-6">Client</span><span class="hl-0">(</span><span class="hl-4">&#39;https://api.predictionguard.com&#39;</span><span class="hl-0">, </span><span class="hl-1">process</span><span class="hl-0">.</span><span class="hl-1">env</span><span class="hl-0">.</span><span class="hl-5">PGKEY</span><span class="hl-0">);</span><br/><br/><span class="hl-3">async</span><span class="hl-0"> </span><span class="hl-3">function</span><span class="hl-0"> </span><span class="hl-6">Chat</span><span class="hl-0">() {</span><br/><span class="hl-0"> </span><span class="hl-3">const</span><span class="hl-0"> </span><span class="hl-5">input</span><span class="hl-0"> = [</span><br/><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">role:</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-1">Roles</span><span class="hl-0">.</span><span class="hl-1">User</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">content:</span><span class="hl-0"> </span><span class="hl-4">&#39;How do you feel about the world in general&#39;</span><span class="hl-0">,</span><br/><span class="hl-0"> },</span><br/><span class="hl-0"> ];</span><br/><br/><span class="hl-0"> </span><span class="hl-3">var</span><span class="hl-0"> [</span><span class="hl-1">result</span><span class="hl-0">, </span><span class="hl-1">err</span><span class="hl-0">] = </span><span class="hl-2">await</span><span class="hl-0"> </span><span class="hl-1">client</span><span class="hl-0">.</span><span class="hl-6">Chat</span><span class="hl-0">(</span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-1">Models</span><span class="hl-0">.</span><span class="hl-1">NeuralChat7B</span><span class="hl-0">, </span><span class="hl-1">input</span><span class="hl-0">, </span><span class="hl-7">1000</span><span class="hl-0">, </span><span class="hl-7">1.1</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-2">if</span><span class="hl-0"> (</span><span class="hl-1">err</span><span class="hl-0"> != </span><span class="hl-3">null</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">console</span><span class="hl-0">.</span><span class="hl-6">log</span><span class="hl-0">(</span><span class="hl-4">&#39;ERROR:&#39;</span><span class="hl-0"> + </span><span class="hl-1">err</span><span class="hl-0">.</span><span class="hl-1">error</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-2">return</span><span class="hl-0">;</span><br/><span class="hl-0"> }</span><br/><br/><span class="hl-0"> </span><span class="hl-1">console</span><span class="hl-0">.</span><span class="hl-6">log</span><span class="hl-0">(</span><span class="hl-4">&#39;RESULT:&#39;</span><span class="hl-0"> + </span><span class="hl-1">result</span><span class="hl-0">.</span><span class="hl-1">model</span><span class="hl-0"> + </span><span class="hl-4">&#39;: &#39;</span><span class="hl-0"> + </span><span class="hl-1">result</span><span class="hl-0">.</span><span class="hl-1">choices</span><span class="hl-0">[</span><span class="hl-7">0</span><span class="hl-0">].</span><span class="hl-1">message</span><span class="hl-0">.</span><span class="hl-1">content</span><span class="hl-0">);</span><br/><span class="hl-0">}</span><br/><br/><span class="hl-6">Chat</span><span class="hl-0">();</span>
<pre><code class="language-js"><span class="hl-2">import</span><span class="hl-0"> </span><span class="hl-3">*</span><span class="hl-0"> </span><span class="hl-2">as</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0"> </span><span class="hl-2">from</span><span class="hl-0"> </span><span class="hl-4">&#39;predictionguard&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-3">const</span><span class="hl-0"> </span><span class="hl-5">client</span><span class="hl-0"> = </span><span class="hl-3">new</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-6">Client</span><span class="hl-0">(</span><span class="hl-4">&#39;https://api.predictionguard.com&#39;</span><span class="hl-0">, </span><span class="hl-1">process</span><span class="hl-0">.</span><span class="hl-1">env</span><span class="hl-0">.</span><span class="hl-5">PGKEY</span><span class="hl-0">);</span><br/><br/><span class="hl-3">async</span><span class="hl-0"> </span><span class="hl-3">function</span><span class="hl-0"> </span><span class="hl-6">Chat</span><span class="hl-0">() {</span><br/><span class="hl-0"> </span><span class="hl-3">const</span><span class="hl-0"> </span><span class="hl-5">input</span><span class="hl-0"> = {</span><br/><span class="hl-0"> </span><span class="hl-1">model:</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-1">Models</span><span class="hl-0">.</span><span class="hl-1">NeuralChat7B</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">messages:</span><span class="hl-0"> [</span><br/><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">role:</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-1">Roles</span><span class="hl-0">.</span><span class="hl-1">User</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">content:</span><span class="hl-0"> </span><span class="hl-4">&#39;How do you feel about the world in general&#39;</span><span class="hl-0">,</span><br/><span class="hl-0"> },</span><br/><span class="hl-0"> ],</span><br/><span class="hl-0"> </span><span class="hl-1">maxTokens:</span><span class="hl-0"> </span><span class="hl-7">1000</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">temperature:</span><span class="hl-0"> </span><span class="hl-7">0.1</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">topP:</span><span class="hl-0"> </span><span class="hl-7">0.1</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">options:</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">factuality:</span><span class="hl-0"> </span><span class="hl-3">true</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">toxicity:</span><span class="hl-0"> </span><span class="hl-3">true</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">pii:</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-1">PIIs</span><span class="hl-0">.</span><span class="hl-1">Replace</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-1">piiReplaceMethod:</span><span class="hl-0"> </span><span class="hl-1">pg</span><span class="hl-0">.</span><span class="hl-1">ReplaceMethods</span><span class="hl-0">.</span><span class="hl-1">Random</span><span class="hl-0">,</span><br/><span class="hl-0"> },</span><br/><span class="hl-0"> };</span><br/><br/><span class="hl-0"> </span><span class="hl-3">var</span><span class="hl-0"> [</span><span class="hl-1">result</span><span class="hl-0">, </span><span class="hl-1">err</span><span class="hl-0">] = </span><span class="hl-2">await</span><span class="hl-0"> </span><span class="hl-1">client</span><span class="hl-0">.</span><span class="hl-6">Chat</span><span class="hl-0">(</span><span class="hl-1">input</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-2">if</span><span class="hl-0"> (</span><span class="hl-1">err</span><span class="hl-0"> != </span><span class="hl-3">null</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">console</span><span class="hl-0">.</span><span class="hl-6">log</span><span class="hl-0">(</span><span class="hl-4">&#39;ERROR:&#39;</span><span class="hl-0"> + </span><span class="hl-1">err</span><span class="hl-0">.</span><span class="hl-1">error</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-2">return</span><span class="hl-0">;</span><br/><span class="hl-0"> }</span><br/><br/><span class="hl-0"> </span><span class="hl-1">console</span><span class="hl-0">.</span><span class="hl-6">log</span><span class="hl-0">(</span><span class="hl-4">&#39;RESULT:&#39;</span><span class="hl-0"> + </span><span class="hl-1">result</span><span class="hl-0">.</span><span class="hl-6">createdDate</span><span class="hl-0">() + </span><span class="hl-4">&#39;: &#39;</span><span class="hl-0"> + </span><span class="hl-1">result</span><span class="hl-0">.</span><span class="hl-1">model</span><span class="hl-0"> + </span><span class="hl-4">&#39;: &#39;</span><span class="hl-0"> + </span><span class="hl-1">result</span><span class="hl-0">.</span><span class="hl-1">choices</span><span class="hl-0">[</span><span class="hl-7">0</span><span class="hl-0">].</span><span class="hl-1">message</span><span class="hl-0">.</span><span class="hl-1">content</span><span class="hl-0">);</span><br/><span class="hl-0">}</span><br/><br/><span class="hl-6">Chat</span><span class="hl-0">();</span>
</code><button>Copy</button></pre>
<p>Take a look at the <a href="https://github.com/predictionguard/js-client/tree/main/examples">examples</a> directory for more examples.</p>
<a id="md:docs" class="tsd-anchor"></a><h3><a href="#md:docs">Docs</a></h3><p>You can find the SDK and Prediction Guard docs using these links.</p>
Expand Down

0 comments on commit caebf6a

Please sign in to comment.