Skip to content

Commit 8453144

Browse files
committed
Update docs for real.
1 parent f5d2625 commit 8453144

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+286
-12008
lines changed

‎docs/api/huggingFace/index.html‎

Lines changed: 104 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,13 @@
8787
</li>
8888
<li class="toctree-l1 current"><a class="reference internal current" href="./">HuggingFace</a>
8989
<ul class="current">
90-
<li class="toctree-l2"><a class="reference internal" href="#class-huggingface">Class: HuggingFace</a>
91-
<ul>
92-
<li class="toctree-l3"><a class="reference internal" href="#constructor">Constructor</a>
90+
<li class="toctree-l2"><a class="reference internal" href="#method-tokenisvalid">Method: tokenIsValid()</a>
9391
</li>
94-
<li class="toctree-l3"><a class="reference internal" href="#method-tokenisvalid">Method: tokenIsValid()</a>
92+
<li class="toctree-l2"><a class="reference internal" href="#method-hubexists">Method: hubExists()</a>
9593
</li>
96-
<li class="toctree-l3"><a class="reference internal" href="#method-hubexists">Method: hubExists()</a>
94+
<li class="toctree-l2"><a class="reference internal" href="#method-questionansweringmodel-inputs">Method: questionAnswering(model, inputs)</a>
9795
</li>
98-
<li class="toctree-l3"><a class="reference internal" href="#method-questionansweringmodel-inputs">Method: questionAnswering(model, inputs)</a>
99-
</li>
100-
<li class="toctree-l3"><a class="reference internal" href="#method-createreporepopath-type">Method: createRepo(repoPath, type)</a>
101-
</li>
102-
<li class="toctree-l3"><a class="reference internal" href="#method-uploadfilerepopath-filepath-blob">Method: uploadFile(repoPath, filePath, blob)</a>
103-
</li>
104-
<li class="toctree-l3"><a class="reference internal" href="#method-deletefilestype-name-paths">Method: deleteFiles(type, name, paths)</a>
105-
</li>
106-
</ul>
107-
</li>
108-
<li class="toctree-l2"><a class="reference internal" href="#export">Export</a>
109-
</li>
110-
<li class="toctree-l2"><a class="reference internal" href="#comments-and-todos">Comments and TODOs</a>
96+
<li class="toctree-l2"><a class="reference internal" href="#method-createreporepopath-type">Method: createRepo(repoPath, type)</a>
11197
</li>
11298
</ul>
11399
</li>
@@ -142,81 +128,116 @@
142128
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
143129
<div class="section" itemprop="articleBody">
144130

145-
<h1 id="huggingface">HuggingFace</h1>
146-
<p>The <code>HuggingFace</code> class in Node.js facilitates interaction with the Hugging Face API for operations such as validating tokens, managing repositories, uploading files, and performing model inference.</p>
147-
<h2 id="class-huggingface">Class: HuggingFace</h2>
148-
<h3 id="constructor">Constructor</h3>
149-
<ul>
150-
<li><strong>Parameters</strong>:</li>
151-
<li><code>accessToken</code> (String): Access token for Hugging Face API.</li>
152-
<li><code>defaultOptions</code> (Object): Default options for the class.</li>
153-
<li><strong>Description</strong>: </li>
154-
<li>Initializes the class with the provided access token and default options.</li>
155-
<li>Sets up an instance of <code>HfInference</code> for model inference tasks.</li>
156-
</ul>
157-
<h3 id="method-tokenisvalid">Method: <code>tokenIsValid()</code></h3>
158-
<ul>
159-
<li><strong>Returns</strong>: Boolean indicating if the token is valid.</li>
160-
<li><strong>Description</strong>: </li>
161-
<li>Validates the provided access token by attempting to list models.</li>
162-
<li>Logs the process and errors if any.</li>
163-
</ul>
164-
<h3 id="method-hubexists">Method: <code>hubExists()</code></h3>
131+
<h1 id="huggingface-documentation">HuggingFace Documentation</h1>
132+
<p>The <code>HuggingFace</code> class is a wrapper around the <code>HfInference</code> class from <code>@huggingface/inference</code> and some functions (<code>createRepo</code>, <code>uploadFile</code>, <code>deleteFiles</code>) from <code>@huggingface/hub</code>. This class provides methods that enable users to perform actions such as validating tokens, checking if a hub exists, asking questions, creating repositories, uploading files, and deleting files on the Hugging Face platform.</p>
133+
<h2 id="method-tokenisvalid">Method: <code>tokenIsValid()</code></h2>
134+
<p>This method checks if the provided access token is valid by making an inference call using the token. This method can help to avoid problems further down the line by ensuring that the token is valid before performing any operation.</p>
165135
<ul>
166-
<li><strong>Returns</strong>: Boolean indicating if the hub exists.</li>
167-
<li><strong>Description</strong>: </li>
168-
<li>Checks for the existence of a hub by attempting to list models.</li>
169-
<li>Handles and logs any errors encountered.</li>
136+
<li>
137+
<p><strong>Returns</strong>: A boolean indicating whether the token is valid (true) or invalid (false).</p>
138+
</li>
139+
<li>
140+
<p><strong>Description</strong>:</p>
141+
</li>
142+
<li>The method lists the models available on the Hugging Face platform and, based on the success or failure of this operation, it returns a boolean.</li>
143+
<li>
144+
<p>If an error occurs during the execution of the method, this error is logged and the method returns <code>false</code>.</p>
145+
</li>
146+
<li>
147+
<p><strong>Parameters</strong>: This method has no parameters.</p>
148+
</li>
170149
</ul>
171-
<h3 id="method-questionansweringmodel-inputs">Method: <code>questionAnswering(model, inputs)</code></h3>
150+
<h2 id="method-hubexists">Method: <code>hubExists()</code></h2>
151+
<p>This method is used to check if a hub exists on the Hugging Face platform.</p>
172152
<ul>
173-
<li><strong>Parameters</strong>:</li>
174-
<li><code>model</code> (String): The model to use for question answering.</li>
175-
<li><code>inputs</code> (String): The inputs for the model.</li>
176-
<li><strong>Returns</strong>: The result of the question answering model.</li>
177-
<li><strong>Description</strong>: </li>
178-
<li>Calls a question-answering model on the Hugging Face platform.</li>
179-
<li>Returns the model's response.</li>
180-
</ul>
181-
<h3 id="method-createreporepopath-type">Method: <code>createRepo(repoPath, type)</code></h3>
153+
<li>
154+
<p><strong>Returns</strong>: A boolean indicating whether the hub exists (true) or not (false).</p>
155+
</li>
156+
<li>
157+
<p><strong>Description</strong>: </p>
182158
<ul>
183-
<li><strong>Parameters</strong>:</li>
184-
<li><code>repoPath</code> (String): The path to the repository.</li>
185-
<li><code>type</code> (String): The type of repository.</li>
186-
<li><strong>Returns</strong>: Result of repository creation.</li>
187-
<li><strong>Description</strong>: </li>
188-
<li>Creates a repository or folder in the Hugging Face hub.</li>
189-
<li>Handles different repository types.</li>
159+
<li>This method works by listing the models of the Hugging Face platform and, based on the success or failure of this operation, it returns a boolean.</li>
160+
<li>If an error occurs during the execution of the method, this error is logged and the method returns <code>false</code>.</li>
190161
</ul>
191-
<h3 id="method-uploadfilerepopath-filepath-blob">Method: <code>uploadFile(repoPath, filePath, blob)</code></h3>
192-
<ul>
193-
<li><strong>Parameters</strong>:</li>
194-
<li><code>repoPath</code> (String): The repository path.</li>
195-
<li><code>filePath</code> (String): The file path.</li>
196-
<li><code>blob</code> (Blob): The file content.</li>
197-
<li><strong>Returns</strong>: Result of file upload.</li>
198-
<li><strong>Description</strong>: </li>
199-
<li>Uploads a file to the specified repository in the Hugging Face hub.</li>
200-
</ul>
201-
<h3 id="method-deletefilestype-name-paths">Method: <code>deleteFiles(type, name, paths)</code></h3>
202-
<ul>
203-
<li><strong>Parameters</strong>:</li>
204-
<li><code>type</code> (String): Type of repository or space.</li>
205-
<li><code>name</code> (String): The path to the repo or space.</li>
206-
<li><code>paths</code> (Array): File paths to delete.</li>
207-
<li><strong>Returns</strong>: Result of file deletion.</li>
208-
<li><strong>Description</strong>: </li>
209-
<li>Deletes files in the specified repository or space on the Hugging Face hub.</li>
162+
</li>
163+
<li>
164+
<p><strong>Parameters</strong>: This method does not take any parameters.</p>
165+
</li>
210166
</ul>
211-
<h2 id="export">Export</h2>
167+
<h2 id="method-questionansweringmodel-inputs">Method: <code>questionAnswering(model, inputs)</code></h2>
168+
<p>This method runs a question answering model on Hugging Face, using the provided model and inputs.</p>
212169
<ul>
213-
<li>The <code>HuggingFace</code> class is exported for use in other modules.</li>
170+
<li>
171+
<p><strong>Returns</strong>: The result of the question answering model inference.</p>
172+
</li>
173+
<li>
174+
<p><strong>Description</strong>:</p>
175+
</li>
176+
<li>
177+
<p>This method uses the <code>questionAnswer</code> method from the <code>HfInference</code> instance (<code>this.inference</code>) to answer questions.</p>
178+
</li>
179+
<li>
180+
<p><strong>Parameters</strong>:</p>
181+
</li>
214182
</ul>
215-
<h2 id="comments-and-todos">Comments and TODOs</h2>
183+
<table>
184+
<thead>
185+
<tr>
186+
<th>Parameter Name</th>
187+
<th>Description</th>
188+
<th>Accepted Values/Data Types</th>
189+
</tr>
190+
</thead>
191+
<tbody>
192+
<tr>
193+
<td>model</td>
194+
<td>The model to be used</td>
195+
<td>String</td>
196+
</tr>
197+
<tr>
198+
<td>inputs</td>
199+
<td>The inputs to the model</td>
200+
<td>String</td>
201+
</tr>
202+
</tbody>
203+
</table>
204+
<h2 id="method-createreporepopath-type">Method: <code>createRepo(repoPath, type)</code></h2>
216205
<ul>
217-
<li>The code includes TODO comments outlining future goals like updating models, connecting models to inference endpoints, checking for space existence, and managing space resources.</li>
218-
<li>These comments link to relevant documentation for further guidance on these tasks.</li>
206+
<li>
207+
<p><strong>Returns</strong>: The response from the <code>createRepo</code> function from the <code>@huggingface/hub</code> package.</p>
208+
</li>
209+
<li>
210+
<p><strong>Description</strong>:</p>
211+
</li>
212+
<li>
213+
<p>This method is used to create a new repository or folder on the Hugging Face hub.</p>
214+
</li>
215+
<li>
216+
<p><strong>Parameters</strong>:</p>
217+
</li>
219218
</ul>
219+
<table>
220+
<thead>
221+
<tr>
222+
<th>Parameter Name</th>
223+
<th>Description</th>
224+
<th>Accepted Values/Data Types</th>
225+
</tr>
226+
</thead>
227+
<tbody>
228+
<tr>
229+
<td>repoPath</td>
230+
<td>The path to the new repository</td>
231+
<td>String</td>
232+
</tr>
233+
<tr>
234+
<td>type</td>
235+
<td>The type of the new repository</td>
236+
<td>String</td>
237+
</tr>
238+
</tbody>
239+
</table>
240+
<p>For more methods like <code>uploadFile</code>, <code>deleteFiles</code>, etc., the template provided above should be followed to document them.</p>
220241

221242
</div>
222243
</div><footer>
File renamed without changes.

‎docs/demo/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ <h2 id="app-developers">App Developers</h2>
153153
<li>.env.examples -&gt; .env + Keys</li>
154154
<li>npm run start</li>
155155
</ol>
156-
<p>More instructions for hands-on configuration available in the <a href="/api/chatbot.md">Chatbot</a> section</p>
156+
<p>More instructions for hands-on configuration available in the <a href="../api/chatbot/">Chatbot</a> section</p>
157157

158158
</div>
159159
</div><footer>

0 commit comments

Comments
 (0)