diff --git a/core/src/services/huggingface/docs.md b/core/src/services/huggingface/docs.md index 951087811e8..e60b26d5791 100644 --- a/core/src/services/huggingface/docs.md +++ b/core/src/services/huggingface/docs.md @@ -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 @@ -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 diff --git a/website/docs/services/huggingface.mdx b/website/docs/services/huggingface.mdx new file mode 100644 index 00000000000..1f1855033dd --- /dev/null +++ b/website/docs/services/huggingface.mdx @@ -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' + + + +### Via Config + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```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(()) +} +``` + + + + +```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", + }); +} +``` + + + + +```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", +) +``` + + + \ No newline at end of file