Skip to content

Commit

Permalink
fix formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrohitgarg committed Feb 28, 2024
1 parent 3c5a9f7 commit 74a68c0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 46 deletions.
56 changes: 29 additions & 27 deletions docs/examples/retrievers/videodb_retriever.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"\"\n",
"os.environ[\"VIDEO_DB_API_KEY\"] = \"\""
]
Expand All @@ -72,12 +73,10 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"%pip install llama-index \n",
"%pip install llama-index\n",
"%pip install videodb"
]
},
Expand All @@ -101,7 +100,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -110,7 +109,7 @@
"# connect to VideoDB\n",
"conn = connect()\n",
"\n",
"# upload videos to default collection in VideoDB \n",
"# upload videos to default collection in VideoDB\n",
"print(\"uploading first video\")\n",
"video1 = conn.upload(url=\"https://www.youtube.com/watch?v=lsODSDmY4CY\")\n",
"print(\"uploading second video\")\n",
Expand Down Expand Up @@ -141,7 +140,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -177,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -188,11 +187,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# VideoDBRetriever by default uses the default collection in the VideoDB \n",
"# VideoDBRetriever by default uses the default collection in the VideoDB\n",
"retriever = VideoDBRetriever()\n",
"\n",
"# use your llama_index response_synthesizer on search results.\n",
Expand All @@ -206,7 +205,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -225,7 +224,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -256,18 +255,18 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from videodb import connect, play_stream \n",
"from videodb import connect, play_stream\n",
"from videodb.timeline import Timeline\n",
"from videodb.asset import VideoAsset"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -276,7 +275,7 @@
"'https://console.videodb.io/player?url=https://stream.videodb.io/v3/published/manifests/9c39c8a9-62a2-4b5e-b15d-8565cc58c8ae.m3u8'"
]
},
"execution_count": 8,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -291,11 +290,15 @@
"for node_obj in relevant_nodes:\n",
" node = node_obj.node\n",
" # create a video asset for each node\n",
" node_asset = VideoAsset(asset_id=node.metadata[\"video_id\"], start=node.metadata[\"start\"], end=node.metadata[\"end\"])\n",
" node_asset = VideoAsset(\n",
" asset_id=node.metadata[\"video_id\"],\n",
" start=node.metadata[\"start\"],\n",
" end=node.metadata[\"end\"],\n",
" )\n",
" # add the asset to timeline\n",
" timeline.add_inline(node_asset)\n",
"\n",
"#generate stream for the compiled timeline\n",
"# generate stream for the compiled timeline\n",
"stream_url = timeline.generate_stream()\n",
"play_stream(stream_url)"
]
Expand Down Expand Up @@ -345,7 +348,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -355,7 +358,7 @@
" NodeWithScore(node=TextNode(id_='2244fd64-121e-4699-ba36-f0f6a110750f', embedding=None, metadata={'collection_id': 'c-33978c87-33e6-4259-9e27-a9edc79be9ad', 'video_id': 'm-eae54005-b5ca-44f1-9c31-fcdb2f1db56a', 'length': '1830.498685', 'title': 'AMA #2: Improve Sleep, Reduce Sugar Cravings, Optimal Protein Intake, Stretching Frequency & More', 'start': 899.772, 'end': 977.986}, excluded_embed_metadata_keys=[], excluded_llm_metadata_keys=[], relationships={}, text=\" Because the study, as far as I know, has not been done. Whether or not doing resistance training or some other type of exercise would have led to the same effect. Although I have to imagine that if it's moderately intense to intense resistance training, provided it's done far enough away from going to sleep right prior to 6 hours before sleep, that one ought to see the same effects, although that was not a condition in this study. But it's a very nice study. They looked at everything from changes in core body temperature to caloric expenditure. They didn't see huge changes in core body temperature changes, so that couldn't explain the effect. It really appears that the major effect of improving slow wave sleep was due to something in changing the fine structure of the brainwaves that occur during slow wave sleep. In fact, and this is an important point. The subjects in this study did not report subjectively feeling that much better from their sleep. So you might say, well then, why would I even want to bother? However, it's well known that getting sufficient slow wave sleep is important not just for repair, excuse me, for repair of bodily tissues, but also for repair of brain tissues and repair and washout of debris in the brain. And that debris is known to lead to things like dementia.\", start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'), score=0.282342136)]"
]
},
"execution_count": 10,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -366,7 +369,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -375,7 +378,7 @@
"'https://console.videodb.io/player?url=https://stream.videodb.io/v3/published/manifests/b7201145-7302-4ec5-b87c-d1a4c6592f69.m3u8'"
]
},
"execution_count": 9,
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -426,9 +429,9 @@
"If you have any questions or feedback. Feel free to reach out to us 🙌🏼\n",
"\n",
"- [Discord](https://discord.gg/py9P639jGz) \n",
"- [Github](https://videodb.io) \n",
"- [GitHub](https://github.com/video-db) \n",
"- [VideoDB](https://videodb.io) \n",
"- [Email](mailto:contact@videodb.io) "
"- [Email](mailto:ashu@videodb.io) "
]
}
],
Expand All @@ -447,8 +450,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
# VideoDB Retriever
# VideoDB Retriever

## Overview
[VideoDB](https://videodb.io) is a serverless database designed to streamline the storage, search, editing, and streaming of video content. VideoDB offers random access to sequential video data by building indexes and developing interfaces for querying and browsing video content. Learn more at [docs.videodb.io](https://docs.videodb.io).

[VideoDB](https://videodb.io) is a serverless database designed to streamline the storage, search, editing, and streaming of video content. VideoDB offers random access to sequential video data by building indexes and developing interfaces for querying and browsing video content. Learn more at [docs.videodb.io](https://docs.videodb.io).

## Getting Started

### Prerequisites

- Obtain API keys from [VideoDB dashboard](https://console.videodb.io)

### Installation

Install the necessary packages with the following command:
```python
%pip install llama-index llama-index-retrievers-videodb videodb

```
pip install llama-index llama-index-retrievers-videodb videodb
```

## Building Your Pipeline

1. **Data Ingestion**: Upload your videos to VideoDB and leverage its managed indexing for efficient data organization, choosing between semantic or scene-based indexing.
2. **Querying**: Utilize `VideoDBRetriever` to retrieve relevant video segments and `llama-index` for constructing your RAG pipeline, enhancing your LLM's context with video-based insights.

## 👨‍👩‍👧‍👦 Support & Community

If you have any questions or feedback.
If you have any questions or feedback.
Please feel free to reach out to us

- [Discord](https://discord.gg/py9P639jGz)
- [Github](https://github.com/video-db)
- [VideoDB](https://videodb.io)
- [Email](mailto:[email protected])
- [Discord](https://discord.gg/py9P639jGz)
- [Github](https://github.com/video-db)
- [VideoDB](https://videodb.io)
- [Email](mailto:[email protected])
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core"]

[tool.codespell]
check-filenames = true
Expand All @@ -25,23 +25,23 @@ ignore_missing_imports = true
python_version = "3.8"

[tool.poetry]
name = "llama-index-retrievers-videodb"
version = "0.1.0"
description = "llama-index VideoDB Retriever integration"
authors = ["VideoDB <[email protected]>"]
maintainers = ["Rohit Garg <[email protected]>"]
description = "llama-index VideoDB Retriever integration"
license = "MIT"
maintainers = ["Rohit Garg <[email protected]>"]
name = "llama-index-retrievers-videodb"
packages = [{include = "llama_index/"}]
readme = "README.md"
packages = [{ include = "llama_index/" }]
version = "0.1.0"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
llama-index-core = "^0.10.0"
videodb = "^0.0"

[tool.poetry.group.dev.dependencies]
black = { extras = ["jupyter"], version = "<=23.9.1,>=23.7.0" }
codespell = { extras = ["toml"], version = ">=v2.2.6" }
black = {extras = ["jupyter"], version = "<=23.9.1,>=23.7.0"}
codespell = {extras = ["toml"], version = ">=v2.2.6"}
ipython = "8.10.0"
jupyter = "^1.0.0"
mypy = "0.991"
Expand All @@ -55,5 +55,5 @@ types-Deprecated = ">=0.1.0"
types-PyYAML = "^6.0.12.12"
types-protobuf = "^4.24.0.4"
types-redis = "4.5.5.0"
types-requests = "2.28.11.8" # TODO: unpin when mypy>0.991
types-requests = "2.28.11.8" # TODO: unpin when mypy>0.991
types-setuptools = "67.1.0.0"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python_tests()
python_tests()

0 comments on commit 74a68c0

Please sign in to comment.