-
-
Notifications
You must be signed in to change notification settings - Fork 590
/
Copy pathClient.php
200 lines (180 loc) · 5.53 KB
/
Client.php
1
2
3
4
5
6
7
8
9
10
11
12
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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
declare(strict_types=1);
namespace OpenAI;
use OpenAI\Contracts\ClientContract;
use OpenAI\Contracts\Resources\ThreadsContract;
use OpenAI\Contracts\Resources\VectorStoresContract;
use OpenAI\Contracts\TransporterContract;
use OpenAI\Resources\Assistants;
use OpenAI\Resources\Audio;
use OpenAI\Resources\Batches;
use OpenAI\Resources\Chat;
use OpenAI\Resources\Completions;
use OpenAI\Resources\Edits;
use OpenAI\Resources\Embeddings;
use OpenAI\Resources\Files;
use OpenAI\Resources\FineTunes;
use OpenAI\Resources\FineTuning;
use OpenAI\Resources\Images;
use OpenAI\Resources\Models;
use OpenAI\Resources\Moderations;
use OpenAI\Resources\Responses;
use OpenAI\Resources\Threads;
use OpenAI\Resources\VectorStores;
final class Client implements ClientContract
{
/**
* Creates a Client instance with the given API token.
*/
public function __construct(private readonly TransporterContract $transporter)
{
// ..
}
/**
* Manage responses to assist models with tasks.
*
* @see https://platform.openai.com/docs/api-reference/responses
*/
public function responses(): Responses
{
return new Responses($this->transporter);
}
/**
* Given a prompt, the model will return one or more predicted completions, and can also return the probabilities
* of alternative tokens at each position.
*
* @see https://platform.openai.com/docs/api-reference/completions
*/
public function completions(): Completions
{
return new Completions($this->transporter);
}
/**
* Given a chat conversation, the model will return a chat completion response.
*
* @see https://platform.openai.com/docs/api-reference/chat
*/
public function chat(): Chat
{
return new Chat($this->transporter);
}
/**
* Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
*
* @see https://platform.openai.com/docs/api-reference/embeddings
*/
public function embeddings(): Embeddings
{
return new Embeddings($this->transporter);
}
/**
* Learn how to turn audio into text.
*
* @see https://platform.openai.com/docs/api-reference/audio
*/
public function audio(): Audio
{
return new Audio($this->transporter);
}
/**
* Given a prompt and an instruction, the model will return an edited version of the prompt.
*
* @see https://platform.openai.com/docs/api-reference/edits
*/
public function edits(): Edits
{
return new Edits($this->transporter);
}
/**
* Files are used to upload documents that can be used with features like Fine-tuning.
*
* @see https://platform.openai.com/docs/api-reference/files
*/
public function files(): Files
{
return new Files($this->transporter);
}
/**
* List and describe the various models available in the API.
*
* @see https://platform.openai.com/docs/api-reference/models
*/
public function models(): Models
{
return new Models($this->transporter);
}
/**
* Manage fine-tuning jobs to tailor a model to your specific training data.
*
* @see https://platform.openai.com/docs/api-reference/fine-tuning
*/
public function fineTuning(): FineTuning
{
return new FineTuning($this->transporter);
}
/**
* Manage fine-tuning jobs to tailor a model to your specific training data.
*
* @see https://platform.openai.com/docs/api-reference/fine-tunes
* @deprecated OpenAI has deprecated this endpoint and will stop working by January 4, 2024.
* https://openai.com/blog/gpt-3-5-turbo-fine-tuning-and-api-updates#updated-gpt-3-models
*/
public function fineTunes(): FineTunes
{
return new FineTunes($this->transporter);
}
/**
* Given an input text, outputs if the model classifies it as violating OpenAI's content policy.
*
* @see https://platform.openai.com/docs/api-reference/moderations
*/
public function moderations(): Moderations
{
return new Moderations($this->transporter);
}
/**
* Given a prompt and/or an input image, the model will generate a new image.
*
* @see https://platform.openai.com/docs/api-reference/images
*/
public function images(): Images
{
return new Images($this->transporter);
}
/**
* Build assistants that can call models and use tools to perform tasks.
*
* @see https://platform.openai.com/docs/api-reference/assistants
*/
public function assistants(): Assistants
{
return new Assistants($this->transporter);
}
/**
* Create threads that assistants can interact with.
*
* @see https://platform.openai.com/docs/api-reference/threads
*/
public function threads(): ThreadsContract
{
return new Threads($this->transporter);
}
/**
* Create large batches of API requests for asynchronous processing. The Batch API returns completions within 24 hours.
*
* @see https://platform.openai.com/docs/api-reference/batch
*/
public function batches(): Batches
{
return new Batches($this->transporter);
}
/**
* Create and update vector stores that assistants can interact with
*
* @see https://platform.openai.com/docs/api-reference/vector-stores
*/
public function vectorStores(): VectorStoresContract
{
return new VectorStores($this->transporter);
}
}