aicaller 1.0.0__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.
- aicaller-1.0.0/MANIFEST.in +1 -0
- aicaller-1.0.0/PKG-INFO +123 -0
- aicaller-1.0.0/README.md +100 -0
- aicaller-1.0.0/aicaller/__init__.py +6 -0
- aicaller-1.0.0/aicaller/__main__.py +492 -0
- aicaller-1.0.0/aicaller/api.py +267 -0
- aicaller-1.0.0/aicaller/conversion.py +156 -0
- aicaller-1.0.0/aicaller/few_shot_sampler.py +35 -0
- aicaller-1.0.0/aicaller/loader.py +74 -0
- aicaller-1.0.0/aicaller/sample_assembler.py +168 -0
- aicaller-1.0.0/aicaller/template.py +290 -0
- aicaller-1.0.0/aicaller/utils.py +177 -0
- aicaller-1.0.0/aicaller.egg-info/PKG-INFO +123 -0
- aicaller-1.0.0/aicaller.egg-info/SOURCES.txt +23 -0
- aicaller-1.0.0/aicaller.egg-info/dependency_links.txt +1 -0
- aicaller-1.0.0/aicaller.egg-info/entry_points.txt +2 -0
- aicaller-1.0.0/aicaller.egg-info/requires.txt +13 -0
- aicaller-1.0.0/aicaller.egg-info/top_level.txt +1 -0
- aicaller-1.0.0/pyproject.toml +28 -0
- aicaller-1.0.0/requirements.txt +13 -0
- aicaller-1.0.0/setup.cfg +4 -0
- aicaller-1.0.0/tests/test_few_shot.py +28 -0
- aicaller-1.0.0/tests/test_loader.py +96 -0
- aicaller-1.0.0/tests/test_sample_assembler.py +94 -0
- aicaller-1.0.0/tests/test_template.py +179 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include requirements.txt
|
aicaller-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aicaller
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Package for using API models. It is designed mainly for experimenting with various models. It allows to easily process Hugging Face datasets, or JSONL/CSV datasets, and send requests to OpenAI compatibles APIs with just using simple configuration files.
|
|
5
|
+
Author: Martin Dočekal
|
|
6
|
+
Project-URL: Repository, https://github.com/mdocekal/ai_caller
|
|
7
|
+
Keywords: openai,ollama,api,datasets
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: classconfig~=1.0.5
|
|
11
|
+
Requires-Dist: Jinja2~=3.1.4
|
|
12
|
+
Requires-Dist: openai~=1.57.0
|
|
13
|
+
Requires-Dist: inquirer~=3.4.0
|
|
14
|
+
Requires-Dist: tiktoken~=0.8.0
|
|
15
|
+
Requires-Dist: tqdm~=4.66.5
|
|
16
|
+
Requires-Dist: numpy~=1.26.4
|
|
17
|
+
Requires-Dist: datasets
|
|
18
|
+
Requires-Dist: json-repair
|
|
19
|
+
Requires-Dist: ollama~=0.4.7
|
|
20
|
+
Requires-Dist: segmentedstring~=1.0.1
|
|
21
|
+
Requires-Dist: pillow~=10.4.0
|
|
22
|
+
Requires-Dist: requests~=2.32.3
|
|
23
|
+
|
|
24
|
+
# AICaller
|
|
25
|
+
Package for using API models. It is designed mainly for experimenting with various models. It allows to easily process Hugging Face datasets, or JSONL/CSV datasets, and send requests to OpenAI compatibles APIs with just using simple configuration files.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install aicaller
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
The package is designed a batch oriented way. It means that you must first create a batch file with API requests, and then you can send the requests to the API.
|
|
36
|
+
|
|
37
|
+
Using this two stage approach allows you to check and save the raw requests that are sent to the API.
|
|
38
|
+
|
|
39
|
+
**If you prefer learning by doing, you can check the examples folder.**
|
|
40
|
+
|
|
41
|
+
## Batch file creation
|
|
42
|
+
Firstly, you need to create a batch file, fo that you can use the `create_batch_file` argument that expects a configuration `--config` (see config [creation](#configuration)) and voluntary a `--path` to file with data to be processed.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
aicaller create_batch_file --config config.yaml --path data.jsonl > batch.jsonl
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Batch Split
|
|
49
|
+
It might be necessary to split the batch into smaller batches. It expects following arguments:
|
|
50
|
+
|
|
51
|
+
* `file` - path to batch file
|
|
52
|
+
* `output` - path to folder where the split files will be saved
|
|
53
|
+
* `max_tokens` - maximum number of tokens in one batch
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
aicaller split_batch batch.jsonl splits 1000000
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Sending requests
|
|
60
|
+
After your batch file is created, you can send the requests to the API (see API config [creation](#configuration)). You can use the `batch_request` command. Here is an example of how to use it:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
aicaller batch_request batch.jsonl -c api_config.yaml -r results.jsonl
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
To see all available options, you can use the `--help` argument:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
aicaller batch_request --help
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
There are two types of configuration files that you can use: one for creating batch files and one for sending requests to the API.
|
|
74
|
+
|
|
75
|
+
If you want to create a new configuration file, please use the `create_config` command, which will lead you through the process of creating a new configuration file:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
aicaller create_config --path config.yaml
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Batch file configuration
|
|
82
|
+
The batch file configuration is a YAML file that defines how to create the batch file from a dataset. Here we will describe multiple options that you can use in an order that they appear during the configuration creation process. Detailed description of each attribute is always available directly in the configuration file.
|
|
83
|
+
|
|
84
|
+
#### Convertor
|
|
85
|
+
There are following convertors available:
|
|
86
|
+
|
|
87
|
+
* ToOpenAIBatchFile
|
|
88
|
+
* Allows to create a batch file for OpenAI compatible APIs
|
|
89
|
+
* ToOllamaBatchFile
|
|
90
|
+
* Even though Ollama API is compatible for basic usage with OpenAI API, it is not compatible with all features. Thus, we suggest to use this convertor for Ollama API.
|
|
91
|
+
|
|
92
|
+
### Loaders
|
|
93
|
+
This package allows to load Hugging Face datasets, or JSONL/CSV datasets, using following loaders:
|
|
94
|
+
|
|
95
|
+
* JSONLLoader
|
|
96
|
+
* Loads JSONL files using Hugging Face dataset loader
|
|
97
|
+
* CSVLoader
|
|
98
|
+
* Loads CSV files using Hugging Face dataset loader
|
|
99
|
+
* HFLoader
|
|
100
|
+
* Loads text oriented Hugging Face datasets
|
|
101
|
+
* HFImageLoader
|
|
102
|
+
* Loads image oriented Hugging Face datasets
|
|
103
|
+
|
|
104
|
+
### Sample Assemblers
|
|
105
|
+
A sample assembler is a component responsible for creating a sample from loaded data. There are two assemblers one for text and one for images:
|
|
106
|
+
* TextDatasetAssembler
|
|
107
|
+
* ImageDatasetAssembler
|
|
108
|
+
|
|
109
|
+
### Templates
|
|
110
|
+
Template specifies the format and content of a sample. It can be simple as string with Jinja2 template, or it can be whole chat history.
|
|
111
|
+
|
|
112
|
+
Now this package supports following types of templates:
|
|
113
|
+
|
|
114
|
+
* StringTemplate
|
|
115
|
+
* Simple string template, that allows to use Jinja2 template
|
|
116
|
+
* MessagesTemplate
|
|
117
|
+
* Allows to define whole chat history with roles and text/image content.
|
|
118
|
+
* As the specification of messages varies for different APIs. There are different types of message builders.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
### API configuration
|
|
122
|
+
File for configuring API connection. It is used for defining API key, URL, and other parameters.
|
|
123
|
+
|
aicaller-1.0.0/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# AICaller
|
|
2
|
+
Package for using API models. It is designed mainly for experimenting with various models. It allows to easily process Hugging Face datasets, or JSONL/CSV datasets, and send requests to OpenAI compatibles APIs with just using simple configuration files.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pip install aicaller
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
The package is designed a batch oriented way. It means that you must first create a batch file with API requests, and then you can send the requests to the API.
|
|
13
|
+
|
|
14
|
+
Using this two stage approach allows you to check and save the raw requests that are sent to the API.
|
|
15
|
+
|
|
16
|
+
**If you prefer learning by doing, you can check the examples folder.**
|
|
17
|
+
|
|
18
|
+
## Batch file creation
|
|
19
|
+
Firstly, you need to create a batch file, fo that you can use the `create_batch_file` argument that expects a configuration `--config` (see config [creation](#configuration)) and voluntary a `--path` to file with data to be processed.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
aicaller create_batch_file --config config.yaml --path data.jsonl > batch.jsonl
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Batch Split
|
|
26
|
+
It might be necessary to split the batch into smaller batches. It expects following arguments:
|
|
27
|
+
|
|
28
|
+
* `file` - path to batch file
|
|
29
|
+
* `output` - path to folder where the split files will be saved
|
|
30
|
+
* `max_tokens` - maximum number of tokens in one batch
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
aicaller split_batch batch.jsonl splits 1000000
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Sending requests
|
|
37
|
+
After your batch file is created, you can send the requests to the API (see API config [creation](#configuration)). You can use the `batch_request` command. Here is an example of how to use it:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
aicaller batch_request batch.jsonl -c api_config.yaml -r results.jsonl
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To see all available options, you can use the `--help` argument:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
aicaller batch_request --help
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
There are two types of configuration files that you can use: one for creating batch files and one for sending requests to the API.
|
|
51
|
+
|
|
52
|
+
If you want to create a new configuration file, please use the `create_config` command, which will lead you through the process of creating a new configuration file:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
aicaller create_config --path config.yaml
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Batch file configuration
|
|
59
|
+
The batch file configuration is a YAML file that defines how to create the batch file from a dataset. Here we will describe multiple options that you can use in an order that they appear during the configuration creation process. Detailed description of each attribute is always available directly in the configuration file.
|
|
60
|
+
|
|
61
|
+
#### Convertor
|
|
62
|
+
There are following convertors available:
|
|
63
|
+
|
|
64
|
+
* ToOpenAIBatchFile
|
|
65
|
+
* Allows to create a batch file for OpenAI compatible APIs
|
|
66
|
+
* ToOllamaBatchFile
|
|
67
|
+
* Even though Ollama API is compatible for basic usage with OpenAI API, it is not compatible with all features. Thus, we suggest to use this convertor for Ollama API.
|
|
68
|
+
|
|
69
|
+
### Loaders
|
|
70
|
+
This package allows to load Hugging Face datasets, or JSONL/CSV datasets, using following loaders:
|
|
71
|
+
|
|
72
|
+
* JSONLLoader
|
|
73
|
+
* Loads JSONL files using Hugging Face dataset loader
|
|
74
|
+
* CSVLoader
|
|
75
|
+
* Loads CSV files using Hugging Face dataset loader
|
|
76
|
+
* HFLoader
|
|
77
|
+
* Loads text oriented Hugging Face datasets
|
|
78
|
+
* HFImageLoader
|
|
79
|
+
* Loads image oriented Hugging Face datasets
|
|
80
|
+
|
|
81
|
+
### Sample Assemblers
|
|
82
|
+
A sample assembler is a component responsible for creating a sample from loaded data. There are two assemblers one for text and one for images:
|
|
83
|
+
* TextDatasetAssembler
|
|
84
|
+
* ImageDatasetAssembler
|
|
85
|
+
|
|
86
|
+
### Templates
|
|
87
|
+
Template specifies the format and content of a sample. It can be simple as string with Jinja2 template, or it can be whole chat history.
|
|
88
|
+
|
|
89
|
+
Now this package supports following types of templates:
|
|
90
|
+
|
|
91
|
+
* StringTemplate
|
|
92
|
+
* Simple string template, that allows to use Jinja2 template
|
|
93
|
+
* MessagesTemplate
|
|
94
|
+
* Allows to define whole chat history with roles and text/image content.
|
|
95
|
+
* As the specification of messages varies for different APIs. There are different types of message builders.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### API configuration
|
|
99
|
+
File for configuring API connection. It is used for defining API key, URL, and other parameters.
|
|
100
|
+
|