Mistral
Generates texts with using the Mistral Batch API.
MistralClient
Bases: BatchClient
Source code in dactyl_generation/mistral_generation.py
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
__init__(api_key)
Constructor for Mistral client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
|
required |
Source code in dactyl_generation/mistral_generation.py
19 20 21 22 23 24 25 26 27 | |
create_batch_job(file_name, prompts_df)
Creates batch job for set of prompts given file name to save Mistral prompts to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
name of file to upload to Mistral API. |
required |
prompts_df
|
DataFrame
|
DataFrame containing generation prompts and parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
info |
dict
|
dictionary containing batch job info |
Source code in dactyl_generation/mistral_generation.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
create_message_batch(file_name, prompts_df)
Creates batch of messages to send to Mistral API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
Name of file in Mistral API to save as. |
required |
prompts_df
|
DataFrame
|
DataFrame containing prompts and generation parameters |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Tuple[List[dict], UploadFileOut]
|
List of requests sent, UploadFileOut object |
Source code in dactyl_generation/mistral_generation.py
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 | |
get_batch_job_output(file_path)
Gets batch job results using saved metadata from a local JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
local JSON file containing output of the |
required |
Returns:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
pandas DataFrame of generations. |
Source code in dactyl_generation/mistral_generation.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
get_batch_jobs()
Helper method to get status of all batch jobs.
Returns:
| Name | Type | Description |
|---|---|---|
batch_jobs_list |
BatchJobsOut
|
list of all batch jobs |
Source code in dactyl_generation/mistral_generation.py
98 99 100 101 102 103 104 105 106 107 | |
start_batch_job(input_file, model)
Start batch job from input file stored on Mistral API containing prompts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_file
|
UploadFileOut
|
input file object to create job with |
required |
model
|
str
|
model name to use for generation |
required |
Returns:
| Name | Type | Description |
|---|---|---|
batch_job |
BatchJobOut
|
Batch job object |
Source code in dactyl_generation/mistral_generation.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |