Name | mocker-db JSON |
Version |
0.2.6
JSON |
| download |
home_page | None |
Summary | A mock handler for simulating a vector database. |
upload_time | 2024-10-01 23:54:07 |
maintainer | None |
docs_url | None |
author | Kyrylo Mordan |
requires_python | None |
license | mit |
keywords |
['aa-paa-tool']
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Mocker db
MockerDB is a python module that contains mock vector database like solution built around
python dictionary data type. It contains methods necessary to interact with this 'database',
embed, search and persist.
```python
from mocker_db import MockerDB, MockerConnector, SentenceTransformerEmbedder
```
### 1. Inserting values into the database
MockerDB can be used as ephemeral database where everything is saved in memory, but also can be persisted in one file for the database and another for embeddings storage.
Embedder is set to sentence_transformer by default and processed locally, custom embedders that connect to an api or use other open source models could be used as long as they have the same interface.
```python
# Initialization
handler = MockerDB(
# optional
embedder_params = {'model_name_or_path' : 'paraphrase-multilingual-mpnet-base-v2',
'processing_type' : 'batch',
'tbatch_size' : 500},
similarity_search_type = 'linear_torch',
use_embedder = True,
embedder = SentenceTransformerEmbedder,
persist = True
)
# Initialize empty database
handler.establish_connection(
# optional for persist
file_path = "./mock_persist",
embs_file_path = "./mock_embs_persist",
)
```
```python
sentences = [
"The cat slept.",
"It rained today.",
"She smiled gently.",
"Books hold knowledge.",
"The sun set behind the mountains, casting a golden glow over the valley.",
"He quickly realized that time was slipping away, and he needed to act fast.",
"The concert was an unforgettable experience, filled with laughter and joy.",
"Despite the challenges, they managed to build a beautiful home together.",
"As the wind howled through the ancient trees, scattering leaves and whispering secrets of the forest, she stood there, gazing up at the endless expanse of stars, feeling both infinitely small and profoundly connected to the universe.",
"While the project seemed daunting at first, requiring countless hours of research, planning, and execution, the team worked tirelessly, motivated by their shared goal of creating something truly remarkable and innovative in their field.",
"In the bustling city streets, amidst the constant hum of traffic and chatter, he found himself contemplating life's mysteries, pondering the choices that had brought him to this very moment and wondering where the path ahead would lead.",
"The conference was a gathering of minds from around the globe, each participant bringing their unique perspectives and insights to the table, fostering a vibrant exchange of ideas that would shape the future of their respective fields for years to come."
]
# Insert Data
values_list = [
{'text' : t, 'n_words' : len(t.split())} for t in sentences
]
handler.insert_values(values_list, "text")
print(f"Items in the database {len(handler.data)}")
```
Items in the database 12
### 2. Searching and retrieving values from the database
There are multiple options for search which could be used together or separately:
- simple filter
- filter with keywords
- llm filter
- search based on similarity
- get all keys
```python
results = handler.search_database(
query = "cat",
filter_criteria = {
"n_words" : 3,
}
)
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'text': 'The cat slept....', 'n_words': '3...'}, {'text': 'She smiled gently....', 'n_words': '3...'}, {'text': 'It rained today....', 'n_words': '3...'}, {'text': 'Books hold knowledge....', 'n_words': '3...'}]
- get all keys with keywords search
```python
results = handler.search_database(
# when keyword key is provided filter is used to pass keywords
filter_criteria = {
"text" : ["sun"],
},
keyword_check_keys = ['text'],
# percentage of filter keyword allowed to be different
keyword_check_cutoff = 1,
return_keys_list=['text']
)
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'text': 'The sun set behind the mountai...'}]
- get all key - n_words
```python
results = handler.search_database(
query = "cat",
filter_criteria = {
"n_words" : 3,
},
return_keys_list=["-n_words"])
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'text': 'The cat slept....'}, {'text': 'She smiled gently....'}, {'text': 'It rained today....'}, {'text': 'Books hold knowledge....'}]
- get all keys + distance
```python
results = handler.search_database(
query = "cat slept",
filter_criteria = {
"n_words" : 3,
},
return_keys_list=["+&distance"]
)
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'text': 'The cat slept....', 'n_words': '3...', '&distance': '0.9757655658500587...'}, {'text': 'She smiled gently....', 'n_words': '3...', '&distance': '0.255370996400475...'}, {'text': 'It rained today....', 'n_words': '3...', '&distance': '0.049663160920329866...'}, {'text': 'Books hold knowledge....', 'n_words': '3...', '&distance': '0.011214848789777708...'}]
- get distance
```python
results = handler.search_database(
query = "cat slept",
filter_criteria = {
"n_words" : 3,
},
return_keys_list=["&distance"]
)
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'&distance': '0.9757655658500587...'}, {'&distance': '0.255370996400475...'}, {'&distance': '0.049663160920329866...'}, {'&distance': '0.011214848789777708...'}]
- get all keys + embeddings
```python
results = handler.search_database(
query = "cat slept",
filter_criteria = {
"n_words" : 3,
},
return_keys_list=["+embedding"]
)
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'text': 'The cat slept....', 'n_words': '3...', 'embedding': '[-3.86438631e-02 1.23167999e-...'}, {'text': 'She smiled gently....', 'n_words': '3...', 'embedding': '[-2.46711988e-02 2.37020120e-...'}, {'text': 'It rained today....', 'n_words': '3...', 'embedding': '[-1.35887757e-01 -2.52719939e-...'}, {'text': 'Books hold knowledge....', 'n_words': '3...', 'embedding': '[ 6.20862879e-02 1.13785893e-...'}]
- get embeddings
```python
results = handler.search_database(
query = "cat slept",
filter_criteria = {
"n_words" : 3,
},
return_keys_list=["embedding"]
)
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'embedding': '[-3.86438631e-02 1.23167999e-...'}, {'embedding': '[-2.46711988e-02 2.37020120e-...'}, {'embedding': '[-1.35887757e-01 -2.52719939e-...'}, {'embedding': '[ 6.20862879e-02 1.13785893e-...'}]
- get embeddings and embedded field
```python
results = handler.search_database(
query = "cat slept",
filter_criteria = {
"n_words" : 3,
},
return_keys_list=["embedding", "+&embedded_field"]
)
print([{k: str(v)[:30] + "..." for k, v in result.items()} for result in results])
```
[{'&embedded_field': 'text...', 'embedding': '[-3.86438631e-02 1.23167999e-...'}, {'&embedded_field': 'text...', 'embedding': '[-2.46711988e-02 2.37020120e-...'}, {'&embedded_field': 'text...', 'embedding': '[-1.35887757e-01 -2.52719939e-...'}, {'&embedded_field': 'text...', 'embedding': '[ 6.20862879e-02 1.13785893e-...'}]
### 3. Removing values from the database
```python
print(f"Items in the database {len(handler.data)}")
handler.remove_from_database(filter_criteria = {"n_words" : 11})
print(f"Items left in the database {len(handler.data)}")
```
Items in the database 12
Items left in the database 10
### 4 Embeding text
```python
results = handler.embed_texts(
texts = [
"Short. Variation 1: Short.",
"Another medium-length example, aiming to test the variability in processing different lengths of text inputs. Variation 2: processing lengths medium-length example, in inputs. to variability aiming test of text different the Another"
]
)
print(str(results)[0:300] + "...")
```
{'embeddings': [[0.04973424971103668, -0.43570247292518616, -0.014545125886797905, -0.03648979589343071, -0.04165348783135414, -0.04544278606772423, -0.07025150209665298, 0.10043243318796158, -0.20846229791641235, 0.15596869587898254, 0.11489829421043396, -0.13442179560661316, -0.02425091527402401, ...
### 5. Using MockerDB API
Remote Mocker can be used via very similar methods to the local one.
```python
# Initialization
handler = MockerDB(
skip_post_init=True
)
# Initialize empty database
handler.establish_connection(
# optional for connecting to api
connection_details = {
'base_url' : "http://localhost:8000/mocker-db"
}
)
```
```python
sentences = [
"The cat slept.",
"It rained today.",
"She smiled gently.",
"Books hold knowledge.",
"The sun set behind the mountains, casting a golden glow over the valley.",
"He quickly realized that time was slipping away, and he needed to act fast.",
"The concert was an unforgettable experience, filled with laughter and joy.",
"Despite the challenges, they managed to build a beautiful home together.",
"As the wind howled through the ancient trees, scattering leaves and whispering secrets of the forest, she stood there, gazing up at the endless expanse of stars, feeling both infinitely small and profoundly connected to the universe.",
"While the project seemed daunting at first, requiring countless hours of research, planning, and execution, the team worked tirelessly, motivated by their shared goal of creating something truly remarkable and innovative in their field.",
"In the bustling city streets, amidst the constant hum of traffic and chatter, he found himself contemplating life's mysteries, pondering the choices that had brought him to this very moment and wondering where the path ahead would lead.",
"The conference was a gathering of minds from around the globe, each participant bringing their unique perspectives and insights to the table, fostering a vibrant exchange of ideas that would shape the future of their respective fields for years to come."
]
# Insert Data
values_list = [
{'text' : t, 'n_words' : len(t.split())} for t in sentences
]
handler.insert_values(values_list, "text")
```
HTTP Request: POST http://localhost:8000/mocker-db/insert "HTTP/1.1 200 OK"
{'status': 'success', 'message': ''}
MockerAPI has multiple handlers stored in memory at a time, they can be displayed with number of items and memory estimate.
```python
handler.show_handlers()
```
HTTP Request: GET http://localhost:8000/mocker-db/active_handlers "HTTP/1.1 200 OK"
{'results': [{'handler': 'default',
'items': 14,
'memory_usage': 1.4558258056640625}],
'status': 'success',
'message': '',
'handlers': ['default'],
'items': [14],
'memory_usage': [1.4558258056640625]}
```python
results = handler.search_database(
query = "cat",
filter_criteria = {
"n_words" : 3,
}
)
results
```
HTTP Request: POST http://localhost:8000/mocker-db/search "HTTP/1.1 200 OK"
{'status': 'success',
'message': '',
'handler': 'default',
'results': [{'text': 'The cat slept.', 'n_words': 3},
{'text': 'Books hold knowledge.', 'n_words': 3},
{'text': 'It rained today.', 'n_words': 3},
{'text': 'She smiled gently.', 'n_words': 3}]}
```python
results = handler.embed_texts(
texts = [
"Short. Variation 1: Short.",
"Another medium-length example, aiming to test the variability in processing different lengths of text inputs. Variation 2: processing lengths medium-length example, in inputs. to variability aiming test of text different the Another"
],
# optional
embedding_model = "intfloat/multilingual-e5-base"
)
print(str(results)[0:500] + "...")
```
HTTP Request: POST http://localhost:8000/mocker-db/embed "HTTP/1.1 200 OK"
{'status': 'success', 'message': '', 'handler': 'cache_mocker_intfloat_multilingual-e5-base', 'embedding_model': 'intfloat/multilingual-e5-base', 'embeddings': [[-0.021023565903306007, 0.03461984172463417, -0.01310338918119669, 0.03071131743490696, 0.023395607247948647, -0.04054545238614082, -0.015805143862962723, -0.02682858146727085, 0.01583343744277954, 0.01763748936355114, 0.0008703064522705972, -0.011133715510368347, 0.11296682059764862, 0.015158131718635559, -0.0466904453933239, -0.0481428...
```python
handler.show_handlers()
```
HTTP Request: GET http://localhost:8000/mocker-db/active_handlers "HTTP/1.1 200 OK"
{'results': [{'handler': 'default',
'items': 14,
'memory_usage': 1.4564743041992188},
{'handler': 'cache_mocker_intfloat_multilingual-e5-base',
'items': 2,
'memory_usage': 1.3639755249023438}],
'status': 'success',
'message': '',
'handlers': ['default', 'cache_mocker_intfloat_multilingual-e5-base'],
'items': [14, 2],
'memory_usage': [1.4564743041992188, 1.3639755249023438]}
Raw data
{
"_id": null,
"home_page": null,
"name": "mocker-db",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "['aa-paa-tool']",
"author": "Kyrylo Mordan",
"author_email": "parachute.repo@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/dc/c6/b4a763c4ab0373fae4f85a6a3b0e79aabb3a60a7752d1aacc280f4f492bf/mocker_db-0.2.6.tar.gz",
"platform": null,
"description": "# Mocker db\n\nMockerDB is a python module that contains mock vector database like solution built around\npython dictionary data type. It contains methods necessary to interact with this 'database',\nembed, search and persist.\n\n```python\nfrom mocker_db import MockerDB, MockerConnector, SentenceTransformerEmbedder\n```\n\n### 1. Inserting values into the database\n\nMockerDB can be used as ephemeral database where everything is saved in memory, but also can be persisted in one file for the database and another for embeddings storage.\n\nEmbedder is set to sentence_transformer by default and processed locally, custom embedders that connect to an api or use other open source models could be used as long as they have the same interface. \n\n\n```python\n# Initialization\nhandler = MockerDB(\n # optional\n embedder_params = {'model_name_or_path' : 'paraphrase-multilingual-mpnet-base-v2',\n 'processing_type' : 'batch',\n 'tbatch_size' : 500},\n similarity_search_type = 'linear_torch',\n use_embedder = True,\n embedder = SentenceTransformerEmbedder,\n persist = True\n)\n# Initialize empty database\nhandler.establish_connection(\n # optional for persist\n file_path = \"./mock_persist\",\n embs_file_path = \"./mock_embs_persist\",\n)\n```\n\n\n```python\nsentences = [\n \"The cat slept.\",\n \"It rained today.\",\n \"She smiled gently.\",\n \"Books hold knowledge.\",\n \"The sun set behind the mountains, casting a golden glow over the valley.\",\n \"He quickly realized that time was slipping away, and he needed to act fast.\",\n \"The concert was an unforgettable experience, filled with laughter and joy.\",\n \"Despite the challenges, they managed to build a beautiful home together.\",\n \"As the wind howled through the ancient trees, scattering leaves and whispering secrets of the forest, she stood there, gazing up at the endless expanse of stars, feeling both infinitely small and profoundly connected to the universe.\",\n \"While the project seemed daunting at first, requiring countless hours of research, planning, and execution, the team worked tirelessly, motivated by their shared goal of creating something truly remarkable and innovative in their field.\",\n \"In the bustling city streets, amidst the constant hum of traffic and chatter, he found himself contemplating life's mysteries, pondering the choices that had brought him to this very moment and wondering where the path ahead would lead.\",\n \"The conference was a gathering of minds from around the globe, each participant bringing their unique perspectives and insights to the table, fostering a vibrant exchange of ideas that would shape the future of their respective fields for years to come.\"\n]\n\n# Insert Data\nvalues_list = [\n {'text' : t, 'n_words' : len(t.split())} for t in sentences\n]\nhandler.insert_values(values_list, \"text\")\nprint(f\"Items in the database {len(handler.data)}\")\n```\n\n Items in the database 12\n\n\n### 2. Searching and retrieving values from the database\n\nThere are multiple options for search which could be used together or separately:\n\n- simple filter\n- filter with keywords\n- llm filter\n- search based on similarity\n\n- get all keys\n\n\n```python\nresults = handler.search_database(\n query = \"cat\",\n filter_criteria = {\n \"n_words\" : 3,\n }\n)\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n```\n\n [{'text': 'The cat slept....', 'n_words': '3...'}, {'text': 'She smiled gently....', 'n_words': '3...'}, {'text': 'It rained today....', 'n_words': '3...'}, {'text': 'Books hold knowledge....', 'n_words': '3...'}]\n\n\n- get all keys with keywords search\n\n\n```python\nresults = handler.search_database(\n # when keyword key is provided filter is used to pass keywords\n filter_criteria = {\n \"text\" : [\"sun\"],\n },\n keyword_check_keys = ['text'],\n # percentage of filter keyword allowed to be different\n keyword_check_cutoff = 1,\n return_keys_list=['text']\n)\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n```\n\n [{'text': 'The sun set behind the mountai...'}]\n\n\n- get all key - n_words\n\n\n```python\nresults = handler.search_database(\n query = \"cat\",\n filter_criteria = {\n \"n_words\" : 3,\n },\n return_keys_list=[\"-n_words\"])\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n```\n\n [{'text': 'The cat slept....'}, {'text': 'She smiled gently....'}, {'text': 'It rained today....'}, {'text': 'Books hold knowledge....'}]\n\n\n- get all keys + distance\n\n\n```python\nresults = handler.search_database(\n query = \"cat slept\",\n filter_criteria = {\n \"n_words\" : 3,\n },\n return_keys_list=[\"+&distance\"]\n)\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n```\n\n [{'text': 'The cat slept....', 'n_words': '3...', '&distance': '0.9757655658500587...'}, {'text': 'She smiled gently....', 'n_words': '3...', '&distance': '0.255370996400475...'}, {'text': 'It rained today....', 'n_words': '3...', '&distance': '0.049663160920329866...'}, {'text': 'Books hold knowledge....', 'n_words': '3...', '&distance': '0.011214848789777708...'}]\n\n\n- get distance\n\n\n```python\nresults = handler.search_database(\n query = \"cat slept\",\n filter_criteria = {\n \"n_words\" : 3,\n },\n return_keys_list=[\"&distance\"]\n)\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n```\n\n [{'&distance': '0.9757655658500587...'}, {'&distance': '0.255370996400475...'}, {'&distance': '0.049663160920329866...'}, {'&distance': '0.011214848789777708...'}]\n\n\n- get all keys + embeddings\n\n\n```python\nresults = handler.search_database(\n query = \"cat slept\",\n filter_criteria = {\n \"n_words\" : 3,\n },\n return_keys_list=[\"+embedding\"]\n)\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n```\n\n [{'text': 'The cat slept....', 'n_words': '3...', 'embedding': '[-3.86438631e-02 1.23167999e-...'}, {'text': 'She smiled gently....', 'n_words': '3...', 'embedding': '[-2.46711988e-02 2.37020120e-...'}, {'text': 'It rained today....', 'n_words': '3...', 'embedding': '[-1.35887757e-01 -2.52719939e-...'}, {'text': 'Books hold knowledge....', 'n_words': '3...', 'embedding': '[ 6.20862879e-02 1.13785893e-...'}]\n\n\n- get embeddings\n\n\n```python\nresults = handler.search_database(\n query = \"cat slept\",\n filter_criteria = {\n \"n_words\" : 3,\n },\n return_keys_list=[\"embedding\"]\n)\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n\n```\n\n [{'embedding': '[-3.86438631e-02 1.23167999e-...'}, {'embedding': '[-2.46711988e-02 2.37020120e-...'}, {'embedding': '[-1.35887757e-01 -2.52719939e-...'}, {'embedding': '[ 6.20862879e-02 1.13785893e-...'}]\n\n\n- get embeddings and embedded field\n\n\n```python\nresults = handler.search_database(\n query = \"cat slept\",\n filter_criteria = {\n \"n_words\" : 3,\n },\n return_keys_list=[\"embedding\", \"+&embedded_field\"]\n)\nprint([{k: str(v)[:30] + \"...\" for k, v in result.items()} for result in results])\n\n```\n\n [{'&embedded_field': 'text...', 'embedding': '[-3.86438631e-02 1.23167999e-...'}, {'&embedded_field': 'text...', 'embedding': '[-2.46711988e-02 2.37020120e-...'}, {'&embedded_field': 'text...', 'embedding': '[-1.35887757e-01 -2.52719939e-...'}, {'&embedded_field': 'text...', 'embedding': '[ 6.20862879e-02 1.13785893e-...'}]\n\n\n### 3. Removing values from the database\n\n\n```python\nprint(f\"Items in the database {len(handler.data)}\")\nhandler.remove_from_database(filter_criteria = {\"n_words\" : 11})\nprint(f\"Items left in the database {len(handler.data)}\")\n\n```\n\n Items in the database 12\n Items left in the database 10\n\n\n### 4 Embeding text\n\n\n```python\nresults = handler.embed_texts(\n texts = [\n \"Short. Variation 1: Short.\",\n \"Another medium-length example, aiming to test the variability in processing different lengths of text inputs. Variation 2: processing lengths medium-length example, in inputs. to variability aiming test of text different the Another\"\n ]\n)\n\nprint(str(results)[0:300] + \"...\")\n```\n\n {'embeddings': [[0.04973424971103668, -0.43570247292518616, -0.014545125886797905, -0.03648979589343071, -0.04165348783135414, -0.04544278606772423, -0.07025150209665298, 0.10043243318796158, -0.20846229791641235, 0.15596869587898254, 0.11489829421043396, -0.13442179560661316, -0.02425091527402401, ...\n\n\n### 5. Using MockerDB API\n\nRemote Mocker can be used via very similar methods to the local one.\n\n\n```python\n# Initialization\nhandler = MockerDB(\n skip_post_init=True\n)\n# Initialize empty database\nhandler.establish_connection(\n # optional for connecting to api\n connection_details = {\n 'base_url' : \"http://localhost:8000/mocker-db\"\n }\n)\n```\n\n\n```python\nsentences = [\n \"The cat slept.\",\n \"It rained today.\",\n \"She smiled gently.\",\n \"Books hold knowledge.\",\n \"The sun set behind the mountains, casting a golden glow over the valley.\",\n \"He quickly realized that time was slipping away, and he needed to act fast.\",\n \"The concert was an unforgettable experience, filled with laughter and joy.\",\n \"Despite the challenges, they managed to build a beautiful home together.\",\n \"As the wind howled through the ancient trees, scattering leaves and whispering secrets of the forest, she stood there, gazing up at the endless expanse of stars, feeling both infinitely small and profoundly connected to the universe.\",\n \"While the project seemed daunting at first, requiring countless hours of research, planning, and execution, the team worked tirelessly, motivated by their shared goal of creating something truly remarkable and innovative in their field.\",\n \"In the bustling city streets, amidst the constant hum of traffic and chatter, he found himself contemplating life's mysteries, pondering the choices that had brought him to this very moment and wondering where the path ahead would lead.\",\n \"The conference was a gathering of minds from around the globe, each participant bringing their unique perspectives and insights to the table, fostering a vibrant exchange of ideas that would shape the future of their respective fields for years to come.\"\n]\n\n# Insert Data\nvalues_list = [\n {'text' : t, 'n_words' : len(t.split())} for t in sentences\n]\nhandler.insert_values(values_list, \"text\")\n```\n\n HTTP Request: POST http://localhost:8000/mocker-db/insert \"HTTP/1.1 200 OK\"\n\n\n\n\n\n {'status': 'success', 'message': ''}\n\n\n\nMockerAPI has multiple handlers stored in memory at a time, they can be displayed with number of items and memory estimate.\n\n\n```python\nhandler.show_handlers()\n```\n\n HTTP Request: GET http://localhost:8000/mocker-db/active_handlers \"HTTP/1.1 200 OK\"\n\n\n\n\n\n {'results': [{'handler': 'default',\n 'items': 14,\n 'memory_usage': 1.4558258056640625}],\n 'status': 'success',\n 'message': '',\n 'handlers': ['default'],\n 'items': [14],\n 'memory_usage': [1.4558258056640625]}\n\n\n\n\n```python\nresults = handler.search_database(\n query = \"cat\",\n filter_criteria = {\n \"n_words\" : 3,\n }\n)\n\nresults\n```\n\n HTTP Request: POST http://localhost:8000/mocker-db/search \"HTTP/1.1 200 OK\"\n\n\n\n\n\n {'status': 'success',\n 'message': '',\n 'handler': 'default',\n 'results': [{'text': 'The cat slept.', 'n_words': 3},\n {'text': 'Books hold knowledge.', 'n_words': 3},\n {'text': 'It rained today.', 'n_words': 3},\n {'text': 'She smiled gently.', 'n_words': 3}]}\n\n\n\n\n```python\nresults = handler.embed_texts(\n texts = [\n \"Short. Variation 1: Short.\",\n \"Another medium-length example, aiming to test the variability in processing different lengths of text inputs. Variation 2: processing lengths medium-length example, in inputs. to variability aiming test of text different the Another\"\n ],\n # optional\n embedding_model = \"intfloat/multilingual-e5-base\"\n)\n\nprint(str(results)[0:500] + \"...\")\n```\n\n HTTP Request: POST http://localhost:8000/mocker-db/embed \"HTTP/1.1 200 OK\"\n\n\n {'status': 'success', 'message': '', 'handler': 'cache_mocker_intfloat_multilingual-e5-base', 'embedding_model': 'intfloat/multilingual-e5-base', 'embeddings': [[-0.021023565903306007, 0.03461984172463417, -0.01310338918119669, 0.03071131743490696, 0.023395607247948647, -0.04054545238614082, -0.015805143862962723, -0.02682858146727085, 0.01583343744277954, 0.01763748936355114, 0.0008703064522705972, -0.011133715510368347, 0.11296682059764862, 0.015158131718635559, -0.0466904453933239, -0.0481428...\n\n\n\n```python\nhandler.show_handlers()\n```\n\n HTTP Request: GET http://localhost:8000/mocker-db/active_handlers \"HTTP/1.1 200 OK\"\n\n\n\n\n\n {'results': [{'handler': 'default',\n 'items': 14,\n 'memory_usage': 1.4564743041992188},\n {'handler': 'cache_mocker_intfloat_multilingual-e5-base',\n 'items': 2,\n 'memory_usage': 1.3639755249023438}],\n 'status': 'success',\n 'message': '',\n 'handlers': ['default', 'cache_mocker_intfloat_multilingual-e5-base'],\n 'items': [14, 2],\n 'memory_usage': [1.4564743041992188, 1.3639755249023438]}\n\n\n",
"bugtrack_url": null,
"license": "mit",
"summary": "A mock handler for simulating a vector database.",
"version": "0.2.6",
"project_urls": null,
"split_keywords": [
"['aa-paa-tool']"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "30188c24e7c86a7940d7fcf1453ef511e9e17c37f152ccf1979e6808d2e845d5",
"md5": "5a4265d04a8031d4446a7d60a26c4833",
"sha256": "21dc38b4125f5679cf5b1605772310975f8ac46b653d676e114815443a4cdc9e"
},
"downloads": -1,
"filename": "mocker_db-0.2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5a4265d04a8031d4446a7d60a26c4833",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 1065970,
"upload_time": "2024-10-01T23:54:05",
"upload_time_iso_8601": "2024-10-01T23:54:05.164150Z",
"url": "https://files.pythonhosted.org/packages/30/18/8c24e7c86a7940d7fcf1453ef511e9e17c37f152ccf1979e6808d2e845d5/mocker_db-0.2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dcc6b4a763c4ab0373fae4f85a6a3b0e79aabb3a60a7752d1aacc280f4f492bf",
"md5": "e71af17cce2c879f3d24ebe1b1de5bca",
"sha256": "a2ba33dc9323fd544f3817c569c4195489438aa4f7bde126b60b0ac1ca0bd91d"
},
"downloads": -1,
"filename": "mocker_db-0.2.6.tar.gz",
"has_sig": false,
"md5_digest": "e71af17cce2c879f3d24ebe1b1de5bca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 1029871,
"upload_time": "2024-10-01T23:54:07",
"upload_time_iso_8601": "2024-10-01T23:54:07.284316Z",
"url": "https://files.pythonhosted.org/packages/dc/c6/b4a763c4ab0373fae4f85a6a3b0e79aabb3a60a7752d1aacc280f4f492bf/mocker_db-0.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-01 23:54:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "mocker-db"
}