Skip to content

Commit c40960c

Browse files
authored
feat(vertex): support Vertex AI for generation (#739)
* feat(vertex): support Vertex AI for generation * style: use `region` instead of `location` * style: fix format * style: undo unrelated diffs
1 parent ad34e59 commit c40960c

File tree

10 files changed

+410
-13
lines changed

10 files changed

+410
-13
lines changed

Cargo.lock

Lines changed: 242 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,4 @@ aws-sdk-sqs = "1.67.0"
117117
numpy = "0.25.0"
118118
infer = "0.19.0"
119119
serde_with = { version = "3.13.0", features = ["base64"] }
120+
google-cloud-aiplatform-v1 = "0.4.0"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Ultra performant data transformation framework for AI, with core engine written
2929

3030
</br>
3131

32-
CocoIndex makes it super easy to transform data with AI workloads, and keep source data and target in sync effortlessly.
32+
CocoIndex makes it super easy to transform data with AI workloads, and keep source data and target in sync effortlessly.
3333

3434
</br>
3535

@@ -39,7 +39,7 @@ CocoIndex makes it super easy to transform data with AI workloads, and keep sour
3939

4040
</br>
4141

42-
Either creating embedding, building knowledge graphs, or any data transformations - beyond traditional SQL.
42+
Either creating embedding, building knowledge graphs, or any data transformations - beyond traditional SQL.
4343

4444
## Exceptional velocity
4545
Just declare transformation in dataflow with ~100 lines of python
@@ -65,7 +65,7 @@ CocoIndex follows the idea of [Dataflow](https://en.wikipedia.org/wiki/Dataflow_
6565
**Particularly**, developers don't explicitly mutate data by creating, updating and deleting. They just need to define transformation/formula for a set of source data.
6666

6767
## Build like LEGO
68-
Native builtins for different source, targets and transformations. Standardize interface, make it 1-line code switch between different components.
68+
Native builtins for different source, targets and transformations. Standardize interface, make it 1-line code switch between different components.
6969

7070
<p align="center">
7171
<img src="https://cocoindex.io/images/components.svg" alt="CocoIndex Features">

python/cocoindex/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# Submodules
3434
"_engine",
3535
"functions",
36+
"llm",
3637
"sources",
3738
"targets",
3839
"storages",

python/cocoindex/functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class EmbedText(op.FunctionSpec):
4545
address: str | None = None
4646
output_dimension: int | None = None
4747
task_type: str | None = None
48+
api_config: llm.VertexAiConfig | None = None
4849

4950

5051
class ExtractByLlm(op.FunctionSpec):

python/cocoindex/llm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@ class LlmApiType(Enum):
88
OPENAI = "OpenAi"
99
OLLAMA = "Ollama"
1010
GEMINI = "Gemini"
11+
VERTEX_AI = "VertexAi"
1112
ANTHROPIC = "Anthropic"
1213
LITE_LLM = "LiteLlm"
1314
OPEN_ROUTER = "OpenRouter"
1415
VOYAGE = "Voyage"
1516
VLLM = "Vllm"
1617

1718

19+
@dataclass
20+
class VertexAiConfig:
21+
"""A specification for a Vertex AI LLM."""
22+
23+
kind = "VertexAi"
24+
25+
project: str
26+
region: str | None = None
27+
28+
1829
@dataclass
1930
class LlmSpec:
2031
"""A specification for a LLM."""
2132

2233
api_type: LlmApiType
2334
model: str
2435
address: str | None = None
36+
api_config: VertexAiConfig | None = None

0 commit comments

Comments
 (0)