\n",
+ " Refer to
troubleshooting\n",
+ " for any problem when running this guide.\n",
+ "
\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "148d275b",
+ "metadata": {},
+ "source": [
+ "**Pre-requisite**: Create a tenant at [cloud.vespa.ai](https://cloud.vespa.ai/), save the tenant name.\n",
+ "\n",
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vespa-engine/pyvespa/blob/master/docs/sphinx/source/getting-started-pyvespa-cloud.ipynb)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "366b0d83",
+ "metadata": {},
+ "source": [
+ "## Install\n",
+ "\n",
+ "Install [pyvespa](https://pyvespa.readthedocs.io/) >= 0.45\n",
+ "and the [Vespa CLI](https://docs.vespa.ai/en/vespa-cli.html).\n",
+ "The Vespa CLI is used for data and control plane key management ([Vespa Cloud Security Guide](https://cloud.vespa.ai/en/security/guide)).\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "136750de",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "!pip3 install pyvespa vespacli datasets"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "02f706ff",
+ "metadata": {},
+ "source": [
+ "## Configure application\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "9ca4da83",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Replace with your tenant name from the Vespa Cloud Console\n",
+ "tenant_name = \"mytenant\"\n",
+ "# Replace with your application name (does not need to exist yet)\n",
+ "application = \"fasthtml\"\n",
+ "# Token id (from Vespa Cloud Console)\n",
+ "token_id = \"fasthtmltoken\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "db637322",
+ "metadata": {},
+ "source": [
+ "## Create an application package\n",
+ "\n",
+ "The [application package](https://pyvespa.readthedocs.io/en/latest/reference-api.html#vespa.package.ApplicationPackage)\n",
+ "has all the Vespa configuration files -\n",
+ "create one from scratch:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "bd5c2629",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from vespa.package import (\n",
+ " ApplicationPackage,\n",
+ " Field,\n",
+ " Schema,\n",
+ " Document,\n",
+ " HNSW,\n",
+ " RankProfile,\n",
+ " Component,\n",
+ " Parameter,\n",
+ " FieldSet,\n",
+ " GlobalPhaseRanking,\n",
+ " Function,\n",
+ " AuthClient,\n",
+ ")\n",
+ "\n",
+ "package = ApplicationPackage(\n",
+ " name=application,\n",
+ " schema=[\n",
+ " Schema(\n",
+ " name=\"doc\",\n",
+ " document=Document(\n",
+ " fields=[\n",
+ " Field(name=\"id\", type=\"string\", indexing=[\"summary\"]),\n",
+ " Field(\n",
+ " name=\"title\",\n",
+ " type=\"string\",\n",
+ " indexing=[\"index\", \"summary\"],\n",
+ " index=\"enable-bm25\",\n",
+ " ),\n",
+ " Field(\n",
+ " name=\"body\",\n",
+ " type=\"string\",\n",
+ " indexing=[\"index\", \"summary\"],\n",
+ " index=\"enable-bm25\",\n",
+ " bolding=True,\n",
+ " ),\n",
+ " Field(\n",
+ " name=\"embedding\",\n",
+ " type=\"tensor