Skip to content

Commit

Permalink
feat: add service huggingface to website
Browse files Browse the repository at this point in the history
  • Loading branch information
morristai committed Dec 24, 2023
1 parent cd323f8 commit fe15b1a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/services/huggingface/docs.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This service will visit the [Huggingface API](https://huggingface.co/docs/huggingface_hub/package_reference/hf_api) to access the Huggingface File System.
Currently, we only support the `model` and `dataset` types of repositories, and operations are limited to reading and listing/stating.

Huggingface doesn't host official HTTP API docs. Detailed HTTP request API information can be found on the [Huggingface Hub](https://github.com/huggingface/huggingface_hub).
Huggingface doesn't host official HTTP API docs. Detailed HTTP request API information can be found on the [`huggingface_hub` Source Code](https://github.com/huggingface/huggingface_hub).

## Capabilities

Expand All @@ -27,7 +27,7 @@ This service can be used to:
- `root`: Set the work directory for backend.
- `token`: The token for accessing the repository.

Refer to [`Builder`]'s public API docs for more information.
Refer to [`HuggingfaceBuilder`]'s public API docs for more information.

## Examples

Expand Down
74 changes: 74 additions & 0 deletions website/docs/services/huggingface.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Hugging Face
---

[Hugging Face](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi) services support.

import Docs from '../../../core/src/services/huggingface/docs.md'

<Docs components={props.components} />

### Via Config

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="rust" label="Rust" default>

```rust
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("repo_type".to_string(), "dataset".to_string());
map.insert("repo_id".to_string(), "databricks/databricks-dolly-15k".to_string());
map.insert("revision".to_string(), "main".to_string());
map.insert("root".to_string(), "/path/to/dir".to_string());
map.insert("token".to_string(), "access_token".to_string());

let op: Operator = Operator::via_map(Scheme::Huggingface, map)?;
Ok(())
}
```

</TabItem>
<TabItem value="node.js" label="Node.js">

```javascript
import { Operator } from "opendal";

async function main() {
# Use `huggingface` or `hf` for scheme name
const op = new Operator("huggingface", {
repo_type: "dataset",
repo_id: "databricks/databricks-dolly-15k",
revision: "main",
root: "/path/to/dir",
token: "access_token",
});
}
```

</TabItem>
<TabItem value="python" label="Python">

```python
import opendal

# Use `huggingface` or `hf` for scheme name
op = opendal.Operator("huggingface",
repo_type="dataset",
repo_id="databricks/databricks-dolly-15k",
revision="main",
root: "/path/to/dir",
token: "access_token",
)
```

</TabItem>
</Tabs>

0 comments on commit fe15b1a

Please sign in to comment.