"# add this import for running in jupyter notebook\n",
"import nest_asyncio\n",
"\n",
"nest_asyncio.apply()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e49be085-ddf1-4028-8c0c-97836ce4a873",
"id": "e49be085-ddf1-4028-8c0c-97836ce4a873",
"metadata": {
"metadata": {
"tags": []
"tags": []
@ -68,7 +81,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "38222aee-adc5-44c2-913c-97977b394cf5",
"id": "38222aee-adc5-44c2-913c-97977b394cf5",
"metadata": {
"metadata": {
"tags": []
"tags": []
@ -92,28 +105,28 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "ff9d0304-1e11-4db2-9454-1350db7907e6",
"id": "ff9d0304-1e11-4db2-9454-1350db7907e6",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"['documents:th7j29cjsx6495wluo7e',\n",
"['documents:38hz49bv1p58f5lrvrdc',\n",
" 'documents:qkqhhjnl7ahbhr07euky',\n",
" 'documents:niayw63vzwm2vcbh6w2s',\n",
" 'documents:8kd6xw8o7y0l171iqry0',\n",
" 'documents:it1fa3ktplbuye43n0ch',\n",
" 'documents:33ejf42dlkmavol9si74',\n",
" 'documents:il8f7vgbbp9tywmsn98c',\n",
" 'documents:f7y4dbs7eitqz58xt1p5']"
" 'documents:vza4c6cqje0avqd58gal']"
]
]
},
},
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"db = SurrealDBStore(\n",
"db = SurrealDBStore(\n",
" dburl=\"http://localhost:8000/rpc\", # url for the hosted SurrealDB database\n",
" dburl=\"ws://localhost:8000/rpc\", # url for the hosted SurrealDB database\n",
" embedding_function=embeddings,\n",
" embedding_function=embeddings,\n",
" db_user=\"root\", # SurrealDB credentials if needed: db username\n",
" db_user=\"root\", # SurrealDB credentials if needed: db username\n",
" db_pass=\"root\", # SurrealDB credentials if needed: db password\n",
" db_pass=\"root\", # SurrealDB credentials if needed: db password\n",
@ -145,7 +158,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "73d66563-4e1f-4edf-9e95-5fc9adcfa2cb",
"id": "73d66563-4e1f-4edf-9e95-5fc9adcfa2cb",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
@ -153,7 +166,7 @@
"await db.adelete()\n",
"await db.adelete()\n",
"\n",
"\n",
"db = await SurrealDBStore.afrom_documents(\n",
"db = await SurrealDBStore.afrom_documents(\n",
" dburl=\"http://localhost:8000/rpc\", # url for the hosted SurrealDB database\n",
" dburl=\"ws://localhost:8000/rpc\", # url for the hosted SurrealDB database\n",
" embedding=embeddings,\n",
" embedding=embeddings,\n",
" documents=docs,\n",
" documents=docs,\n",
" db_user=\"root\", # SurrealDB credentials if needed: db username\n",
" db_user=\"root\", # SurrealDB credentials if needed: db username\n",
@ -174,7 +187,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "aa28a7f8-41d0-4299-84eb-91d1576e8a63",
"id": "aa28a7f8-41d0-4299-84eb-91d1576e8a63",
"metadata": {
"metadata": {
"tags": []
"tags": []
@ -187,7 +200,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"id": "1eb16d2a-b466-456a-b412-5e74bb8523dd",
"id": "1eb16d2a-b466-456a-b412-5e74bb8523dd",
"metadata": {
"metadata": {
"tags": []
"tags": []
@ -229,7 +242,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"id": "8e9eef05-1516-469a-ad36-880c69aef7a9",
"id": "8e9eef05-1516-469a-ad36-880c69aef7a9",
"metadata": {
"metadata": {
"tags": []
"tags": []
@ -241,7 +254,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"id": "bd5fb0e4-2a94-4bb4-af8a-27327ecb1a7f",
"id": "bd5fb0e4-2a94-4bb4-af8a-27327ecb1a7f",
"metadata": {
"metadata": {
"tags": []
"tags": []
@ -250,11 +263,11 @@
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"(Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \\n\\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \\n\\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \\n\\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.', metadata={'id': 'documents:639m99rzwqlm9imcwg13'}),\n",
"(Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \\n\\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service. \\n\\nOne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court. \\n\\nAnd I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.', metadata={'id': 'documents:slgdlhjkfknhqo15xz0w', 'source': '../../modules/state_of_the_union.txt'}),\n",