VertexAICodeGenerator
This component enables code generation using Google Vertex AI generative model.
Basic Information
- Type:
haystack_integrations.components.generators.google_vertex.code_generator.VertexAICodeGenerator
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| prefix | str | Code before the current point. | |
| suffix | Optional[str] | None | Code after the current point. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| replies | List[str] | A dictionary with the following keys: - replies: A list of generated code snippets. |
Overview
Work in Progress
Bear with us while we're working on adding pipeline examples and most common components connections.
This component enables code generation using Google Vertex AI generative model.
VertexAICodeGenerator supports code-bison, code-bison-32k, and code-gecko.
Usage example:
from haystack_integrations.components.generators.google_vertex import VertexAICodeGenerator
generator = VertexAICodeGenerator()
result = generator.run(prefix="def to_json(data):")
for answer in result["replies"]:
print(answer)
>>> ```python
>>> import json
>>>
>>> def to_json(data):
>>> """Converts a Python object to a JSON string.
>>>
>>> Args:
>>> data: The Python object to convert.
>>>
>>> Returns:
>>> A JSON string representing the Python object.
>>> """
>>>
>>> return json.dumps(data)
>>> ```
Usage Example
components:
VertexAICodeGenerator:
type: google_vertex.src.haystack_integrations.components.generators.google_vertex.code_generator.VertexAICodeGenerator
init_parameters:
Parameters
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| project_id | Optional[str] | None | ID of the GCP project to use. By default, it is set during Google Cloud authentication. |
| model | str | code-bison | Name of the model to use. |
| location | Optional[str] | None | The default location to use when making API calls, if not set uses us-central-1. |
| kwargs | Any | Additional keyword arguments to pass to the model. For a list of supported arguments see the TextGenerationModel.predict() documentation. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| prefix | str | Code before the current point. | |
| suffix | Optional[str] | None | Code after the current point. |
Was this page helpful?