Google Gemini
This module helps in generating texts using the Gemini API.
GoogleClient
Bases: BatchClient
Source code in dactyl_generation/google_generation.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
__init__(api_key)
Constructor for Google's Gemini API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
Gemini API key. |
required |
Source code in dactyl_generation/google_generation.py
14 15 16 17 18 19 20 21 22 | |
create_batch_job(jsonl_path, jsonl_display_name, model, batch_display_name)
Creates and starts batch job with the Gemini API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jsonl_path
|
str
|
Local path to JSONL file containing prompts. |
required |
jsonl_display_name
|
str
|
Name of file on Google cloud to upload to. |
required |
model
|
str
|
Name of LLM to use. |
required |
batch_display_name
|
str
|
Batch display name to show. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
batch_info |
dict
|
Dictionary containing batch information. |
Source code in dactyl_generation/google_generation.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
get_batch_job_output(file_path)
Fetches batch inference results and returns as pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
JSON file containing object returned by |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dataframe |
DataFrame
|
Results containing responses and prompts. |
Source code in dactyl_generation/google_generation.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
upload_prompts(jsonl_path, display_name)
Uploads JSONL file to Google Cloud.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jsonl_path
|
str
|
Local path to JSONL file containing prompts. |
required |
display_name
|
str
|
Name of file on Google cloud to upload to. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
uploaded_file |
File
|
Uploaded file object |
Source code in dactyl_generation/google_generation.py
24 25 26 27 28 29 30 31 32 33 34 35 | |