pixeltable 0.2.26__tar.gz → 0.2.27__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pixeltable might be problematic. Click here for more details.
- {pixeltable-0.2.26 → pixeltable-0.2.27}/PKG-INFO +1 -1
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/__version__.py +2 -2
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/env.py +8 -1
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/__init__.py +2 -2
- pixeltable-0.2.27/pixeltable/functions/gemini.py +85 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/iterators/document.py +12 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/type_system.py +1 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/documents.py +14 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pyproject.toml +2 -1
- {pixeltable-0.2.26 → pixeltable-0.2.27}/LICENSE +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/README.md +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/catalog.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/column.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/dir.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/globals.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/insertable_table.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/named_function.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/path.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/path_dict.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/schema_object.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/table.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/table_version.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/table_version_path.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/catalog/view.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/dataframe.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exceptions.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/aggregation_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/cache_prefetch_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/component_iteration_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/data_row_batch.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/exec_context.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/exec_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/expr_eval_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/in_memory_data_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/row_update_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exec/sql_node.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/arithmetic_expr.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/array_slice.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/column_property_ref.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/column_ref.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/comparison.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/compound_predicate.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/data_row.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/expr.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/expr_dict.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/expr_set.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/function_call.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/globals.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/in_predicate.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/inline_expr.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/is_null.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/json_mapper.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/json_path.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/literal.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/method_ref.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/object_ref.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/row_builder.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/rowid_ref.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/similarity_expr.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/sql_element_cache.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/type_cast.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/exprs/variable.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/ext/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/ext/functions/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/ext/functions/whisperx.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/ext/functions/yolox.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/aggregate_function.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/callable_function.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/expr_template_function.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/function.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/function_registry.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/globals.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/query_template_function.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/signature.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/func/udf.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/anthropic.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/audio.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/fireworks.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/globals.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/huggingface.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/image.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/json.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/llama_cpp.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/mistralai.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/ollama.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/openai.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/replicate.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/string.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/timestamp.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/together.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/util.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/video.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/vision.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/functions/whisper.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/globals.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/index/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/index/base.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/index/btree.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/index/embedding_index.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/external_store.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/fiftyone.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/globals.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/hf_datasets.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/label_studio.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/pandas.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/io/parquet.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/iterators/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/iterators/base.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/iterators/image.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/iterators/string.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/iterators/video.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_10.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_12.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_13.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_14.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_15.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_16.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_17.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_18.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_19.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_20.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_21.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/convert_22.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/converters/util.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/notes.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/metadata/schema.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/plan.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/py.typed +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/store.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/tool/create_test_db_dump.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/tool/create_test_video.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/tool/doc_plugins/griffe.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/tool/doc_plugins/mkdocstrings.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/tool/doc_plugins/templates/material/udf.html.jinja +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/tool/embed_udf.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/tool/mypy_plugin.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/__init__.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/arrow.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/coco.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/code.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/description_helper.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/filecache.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/formatter.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/http_server.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/media_store.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/pytorch.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/s3.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/sql.py +0 -0
- {pixeltable-0.2.26 → pixeltable-0.2.27}/pixeltable/utils/transactional_directory.py +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# These version placeholders will be replaced during build.
|
|
2
|
-
__version__ = "0.2.
|
|
3
|
-
__version_tuple__ = (0, 2,
|
|
2
|
+
__version__ = "0.2.27"
|
|
3
|
+
__version_tuple__ = (0, 2, 27)
|
|
@@ -496,6 +496,7 @@ class Env:
|
|
|
496
496
|
self.__register_package('datasets')
|
|
497
497
|
self.__register_package('fiftyone')
|
|
498
498
|
self.__register_package('fireworks', library_name='fireworks-ai')
|
|
499
|
+
self.__register_package('google.generativeai', library_name='google-generativeai')
|
|
499
500
|
self.__register_package('huggingface_hub', library_name='huggingface-hub')
|
|
500
501
|
self.__register_package('label_studio_sdk', library_name='label-studio-sdk')
|
|
501
502
|
self.__register_package('llama_cpp', library_name='llama-cpp-python')
|
|
@@ -520,8 +521,14 @@ class Env:
|
|
|
520
521
|
self.__register_package('yolox', library_name='git+https://github.com/Megvii-BaseDetection/YOLOX@ac58e0a')
|
|
521
522
|
|
|
522
523
|
def __register_package(self, package_name: str, library_name: Optional[str] = None) -> None:
|
|
524
|
+
is_installed: bool
|
|
525
|
+
try:
|
|
526
|
+
is_installed = importlib.util.find_spec(package_name) is not None
|
|
527
|
+
except ModuleNotFoundError:
|
|
528
|
+
# This can happen if the parent of `package_name` is not installed.
|
|
529
|
+
is_installed = False
|
|
523
530
|
self.__optional_packages[package_name] = PackageInfo(
|
|
524
|
-
is_installed=
|
|
531
|
+
is_installed=is_installed,
|
|
525
532
|
library_name=library_name or package_name # defaults to package_name unless specified otherwise
|
|
526
533
|
)
|
|
527
534
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from pixeltable.utils.code import local_public_names
|
|
2
2
|
|
|
3
|
-
from . import (anthropic, audio, fireworks, huggingface, image, json, llama_cpp, mistralai, ollama, openai,
|
|
4
|
-
timestamp, together, video, vision, whisper)
|
|
3
|
+
from . import (anthropic, audio, fireworks, gemini, huggingface, image, json, llama_cpp, mistralai, ollama, openai,
|
|
4
|
+
string, timestamp, together, video, vision, whisper)
|
|
5
5
|
from .globals import *
|
|
6
6
|
|
|
7
7
|
__all__ = local_public_names(__name__, exclude=['globals']) + local_public_names(globals.__name__)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pixeltable [UDFs](https://pixeltable.readme.io/docs/user-defined-functions-udfs)
|
|
3
|
+
that wrap various endpoints from the Google Gemini API. In order to use them, you must
|
|
4
|
+
first `pip install google-generativeai` and configure your Gemini credentials, as described in
|
|
5
|
+
the [Working with Gemini](https://pixeltable.readme.io/docs/working-with-gemini) tutorial.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
import pixeltable as pxt
|
|
11
|
+
from pixeltable import env
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@env.register_client('gemini')
|
|
15
|
+
def _(api_key: str) -> None:
|
|
16
|
+
import google.generativeai as genai # type: ignore[import-untyped]
|
|
17
|
+
genai.configure(api_key=api_key)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _ensure_loaded() -> None:
|
|
21
|
+
env.Env.get().get_client('gemini')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pxt.udf
|
|
25
|
+
def generate_content(
|
|
26
|
+
contents: str,
|
|
27
|
+
*,
|
|
28
|
+
model_name: str,
|
|
29
|
+
candidate_count: Optional[int] = None,
|
|
30
|
+
stop_sequences: Optional[list[str]] = None,
|
|
31
|
+
max_output_tokens: Optional[int] = None,
|
|
32
|
+
temperature: Optional[float] = None,
|
|
33
|
+
top_p: Optional[float] = None,
|
|
34
|
+
top_k: Optional[int] = None,
|
|
35
|
+
response_mime_type: Optional[str] = None,
|
|
36
|
+
response_schema: Optional[dict] = None,
|
|
37
|
+
presence_penalty: Optional[float] = None,
|
|
38
|
+
frequency_penalty: Optional[float] = None,
|
|
39
|
+
response_logprobs: Optional[bool] = None,
|
|
40
|
+
logprobs: Optional[int] = None,
|
|
41
|
+
) -> dict:
|
|
42
|
+
"""
|
|
43
|
+
Generate content from the specified model. For additional details, see:
|
|
44
|
+
<https://ai.google.dev/gemini-api/docs>
|
|
45
|
+
|
|
46
|
+
__Requirements:__
|
|
47
|
+
|
|
48
|
+
- `pip install google-generativeai`
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
contents: The input content to generate from.
|
|
52
|
+
model_name: The name of the model to use.
|
|
53
|
+
|
|
54
|
+
For details on the other parameters, see: <https://ai.google.dev/gemini-api/docs>
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
A dictionary containing the response and other metadata.
|
|
58
|
+
|
|
59
|
+
Examples:
|
|
60
|
+
Add a computed column that applies the model `gemini-1.5-flash`
|
|
61
|
+
to an existing Pixeltable column `tbl.prompt` of the table `tbl`:
|
|
62
|
+
|
|
63
|
+
>>> tbl['response'] = generate_content(tbl.prompt, model_name='gemini-1.5-flash')
|
|
64
|
+
"""
|
|
65
|
+
env.Env.get().require_package('google.generativeai')
|
|
66
|
+
_ensure_loaded()
|
|
67
|
+
import google.generativeai as genai
|
|
68
|
+
|
|
69
|
+
model = genai.GenerativeModel(model_name=model_name)
|
|
70
|
+
gc = genai.GenerationConfig(
|
|
71
|
+
candidate_count=candidate_count,
|
|
72
|
+
stop_sequences=stop_sequences,
|
|
73
|
+
max_output_tokens=max_output_tokens,
|
|
74
|
+
temperature=temperature,
|
|
75
|
+
top_p=top_p,
|
|
76
|
+
top_k=top_k,
|
|
77
|
+
response_mime_type=response_mime_type,
|
|
78
|
+
response_schema=response_schema,
|
|
79
|
+
presence_penalty=presence_penalty,
|
|
80
|
+
frequency_penalty=frequency_penalty,
|
|
81
|
+
response_logprobs=response_logprobs,
|
|
82
|
+
logprobs=logprobs,
|
|
83
|
+
)
|
|
84
|
+
response = model.generate_content(contents, generation_config=gc)
|
|
85
|
+
return response.to_dict()
|
|
@@ -151,6 +151,9 @@ class DocumentSplitter(ComponentIterator):
|
|
|
151
151
|
elif self._doc_handle.format == DocumentType.DocumentFormat.PDF:
|
|
152
152
|
assert self._doc_handle.pdf_doc is not None
|
|
153
153
|
self._sections = self._pdf_sections()
|
|
154
|
+
elif self._doc_handle.format == DocumentType.DocumentFormat.TXT:
|
|
155
|
+
assert self._doc_handle.txt_doc is not None
|
|
156
|
+
self._sections = self._txt_sections()
|
|
154
157
|
else:
|
|
155
158
|
assert False, f'Unsupported document format: {self._doc_handle.format}'
|
|
156
159
|
|
|
@@ -389,6 +392,15 @@ class DocumentSplitter(ComponentIterator):
|
|
|
389
392
|
if accumulated_text and not emit_on_page:
|
|
390
393
|
yield DocumentSection(text=_emit_text(), metadata=DocumentSectionMetadata())
|
|
391
394
|
|
|
395
|
+
def _txt_sections(self) -> Iterator[DocumentSection]:
|
|
396
|
+
"""Create DocumentSections for text files.
|
|
397
|
+
|
|
398
|
+
Currently, it returns the entire text as a single section.
|
|
399
|
+
TODO: Add support for paragraphs.
|
|
400
|
+
"""
|
|
401
|
+
assert self._doc_handle.txt_doc is not None
|
|
402
|
+
yield DocumentSection(text=ftfy.fix_text(self._doc_handle.txt_doc), metadata=DocumentSectionMetadata())
|
|
403
|
+
|
|
392
404
|
def _sentence_sections(self, input_sections: Iterable[DocumentSection]) -> Iterator[DocumentSection]:
|
|
393
405
|
"""Split the input sections into sentences"""
|
|
394
406
|
for section in input_sections:
|
|
@@ -15,6 +15,7 @@ class DocumentHandle:
|
|
|
15
15
|
bs_doc: Optional[bs4.BeautifulSoup] = None
|
|
16
16
|
md_ast: Optional[dict] = None
|
|
17
17
|
pdf_doc: Optional[fitz.Document] = None
|
|
18
|
+
txt_doc: Optional[str] = None
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
def get_document_handle(path: str) -> Optional[DocumentHandle]:
|
|
@@ -40,6 +41,11 @@ def get_document_handle(path: str) -> Optional[DocumentHandle]:
|
|
|
40
41
|
if bs_doc is not None:
|
|
41
42
|
return DocumentHandle(format=ts.DocumentType.DocumentFormat.XML, bs_doc=bs_doc)
|
|
42
43
|
|
|
44
|
+
if doc_format == '.txt':
|
|
45
|
+
txt_doc = get_txt(path)
|
|
46
|
+
if txt_doc is not None:
|
|
47
|
+
return DocumentHandle(format=ts.DocumentType.DocumentFormat.TXT, txt_doc=txt_doc)
|
|
48
|
+
|
|
43
49
|
return None
|
|
44
50
|
|
|
45
51
|
|
|
@@ -84,3 +90,11 @@ def get_markdown_handle(path: str) -> Optional[dict]:
|
|
|
84
90
|
return md_ast(text)
|
|
85
91
|
except Exception:
|
|
86
92
|
return None
|
|
93
|
+
|
|
94
|
+
def get_txt(path: str) -> Optional[str]:
|
|
95
|
+
try:
|
|
96
|
+
with open(path, "r") as f:
|
|
97
|
+
doc = f.read()
|
|
98
|
+
return doc if doc != '' else None
|
|
99
|
+
except Exception:
|
|
100
|
+
return None
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry_dynamic_versioning.backend"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "pixeltable"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.27"
|
|
8
8
|
description = "AI Data Infrastructure: Declarative, Multimodal, and Incremental"
|
|
9
9
|
license = "Apache-2.0"
|
|
10
10
|
authors = ["Pixeltable, Inc. <contact@pixeltable.com>"]
|
|
@@ -114,6 +114,7 @@ together = "^1.3.1"
|
|
|
114
114
|
fireworks-ai = "^0.13.0"
|
|
115
115
|
mistralai = "^1.2.1"
|
|
116
116
|
replicate = "^1.0.2"
|
|
117
|
+
google-generativeai = "^0.8.3"
|
|
117
118
|
boto3 = "==1.35.5" # Locking a specific version of boto3 dramatically improves `poetry lock` runtimes
|
|
118
119
|
spacy = ">=3.7"
|
|
119
120
|
pydantic = ">=2.7.4" # Required minimum version to work with spacy + python 3.12
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|