diff --git a/examples/huggingface_demo.ipynb b/examples/huggingface_demo.ipynb new file mode 100644 index 0000000..ccd17dc --- /dev/null +++ b/examples/huggingface_demo.ipynb @@ -0,0 +1,93 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "3bc5c094", + "metadata": {}, + "source": [ + "# OpenDeepSearch + Hugging Face Demo\n", + "Run this notebook to quickly test OpenDeepSearch with Hugging Face Inference API.\n", + "\n", + "👉 Requirements:\n", + "- A Hugging Face account and API token (https://huggingface.co/settings/tokens)\n", + "- `opendeepsearch` installed in your environment" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "52831ffe", + "metadata": {}, + "outputs": [], + "source": [ + "from opendeepsearch import OpenDeepSearchTool\n", + "import os" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1defad09", + "metadata": {}, + "outputs": [], + "source": [ + "# 1. Set your Hugging Face API key\n", + "# 👉 Replace with your token from https://huggingface.co/settings/tokens\n", + "os.environ[\"HUGGINGFACE_API_KEY\"] = \"your-hf-api-key\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5be1fa20", + "metadata": {}, + "outputs": [], + "source": [ + "# 2. Initialize the search agent with a Hugging Face model\n", + "search_agent = OpenDeepSearchTool(\n", + " model_name=\"facebook/bart-large-mnli\", # ✅ correct model name\n", + " reranker=\"jina\"\n", + ")\n", + "\n", + "if not search_agent.is_initialized:\n", + " search_agent.setup()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "084c2120", + "metadata": {}, + "outputs": [], + "source": [ + "# 3. Run a sample query\n", + "query = \"Is Hugging Face great for NLP?\"\n", + "result = search_agent.forward(query)\n", + "\n", + "print(\"🔍 Query:\", query)\n", + "print(\"✅ Result:\", result)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}