llmstudio-core 0.0.1a1__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.
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.1
2
+ Name: llmstudio-core
3
+ Version: 0.0.1a1
4
+ Summary: LLMStudio core capabilities for routing llm calls for any vendor. No proxy server required. For that use llmstudio[proxy]
5
+ License: MIT
6
+ Author: ClΓ‘udio Lemos
7
+ Author-email: claudio.lemos@tensorops.ai
8
+ Requires-Python: >=3.9,<4.0
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Dist: openai (>=1.26,<2.0)
16
+ Requires-Dist: pydantic (>=2.5,<3.0)
17
+ Requires-Dist: pyyaml (>=6,<7)
18
+ Requires-Dist: requests (>=2.31,<3.0)
19
+ Requires-Dist: tiktoken (>=0.7,<0.8)
20
+ Description-Content-Type: text/markdown
21
+
22
+ # LLMstudio-core by [TensorOps](http://tensorops.ai "TensorOps")
23
+
24
+ Prompt Engineering at your fingertips
25
+
26
+ ![LLMstudio logo](https://imgur.com/Xqsj6V2.gif)
27
+
28
+ ## 🌟 Features
29
+ - **Custom and Local LLM Support**: Use custom or local open-source LLMs through Ollama.
30
+ - **Python SDK**: Easily integrate LLMstudio into your existing workflows.
31
+ - **LangChain Integration**: LLMstudio integrates with your already existing LangChain projects.
32
+
33
+ ## πŸš€ Quickstart
34
+
35
+ Don't forget to check out [https://docs.llmstudio.ai](docs) page.
36
+
37
+ ## Installation
38
+
39
+ Install the latest version of **LLMstudio** using `pip`. We suggest that you create and activate a new environment using `conda`
40
+
41
+ ```bash
42
+ pip install llmstudio-core
43
+ ```
44
+
45
+ Create a `.env` file at the same path you'll run **LLMstudio**
46
+
47
+ ```bash
48
+ OPENAI_API_KEY="sk-api_key"
49
+ GOOGLE_API_KEY="sk-api_key"
50
+ ```
51
+
52
+ Now you should be able to run **LLMstudio** Providers using the following code:
53
+
54
+ ```
55
+ # You can set OPENAI_API_KEY environment variable, add it to .env, or pass directly as api_key
56
+ import os
57
+ from llmstudio_core.providers import LLMCore as LLM
58
+ llm = LLM("vertexai", api_key=os.environ["GOOGLE_API_KEY"])
59
+ response = llm.chat("How are you", model="gemini-1.5-pro-latest")
60
+ print(response.chat_output, response.metrics)
61
+ ```
62
+ ## πŸ“– Documentation
63
+
64
+ - [Visit our docs to learn how the SDK works](https://docs.LLMstudio.ai) (coming soon)
65
+ - Checkout our [notebook examples](https://github.com/TensorOpsAI/LLMstudio/tree/main/examples) to follow along with interactive tutorials
66
+
67
+ ## πŸ‘¨β€πŸ’» Contributing
68
+
69
+ - Head on to our [Contribution Guide](https://github.com/TensorOpsAI/LLMstudio/tree/main/CONTRIBUTING.md) to see how you can help LLMstudio.
70
+ - Join our [Discord](https://discord.gg/GkAfPZR9wy) to talk with other LLMstudio enthusiasts.
71
+
72
+ ## Training
73
+
74
+ [![Banner](https://imgur.com/XTRFZ4m.png)](https://www.tensorops.ai/llm-studio-workshop)
75
+
76
+ ---
77
+
78
+ Thank you for choosing LLMstudio. Your journey to perfecting AI interactions starts here.
79
+
@@ -0,0 +1,57 @@
1
+ # LLMstudio-core by [TensorOps](http://tensorops.ai "TensorOps")
2
+
3
+ Prompt Engineering at your fingertips
4
+
5
+ ![LLMstudio logo](https://imgur.com/Xqsj6V2.gif)
6
+
7
+ ## 🌟 Features
8
+ - **Custom and Local LLM Support**: Use custom or local open-source LLMs through Ollama.
9
+ - **Python SDK**: Easily integrate LLMstudio into your existing workflows.
10
+ - **LangChain Integration**: LLMstudio integrates with your already existing LangChain projects.
11
+
12
+ ## πŸš€ Quickstart
13
+
14
+ Don't forget to check out [https://docs.llmstudio.ai](docs) page.
15
+
16
+ ## Installation
17
+
18
+ Install the latest version of **LLMstudio** using `pip`. We suggest that you create and activate a new environment using `conda`
19
+
20
+ ```bash
21
+ pip install llmstudio-core
22
+ ```
23
+
24
+ Create a `.env` file at the same path you'll run **LLMstudio**
25
+
26
+ ```bash
27
+ OPENAI_API_KEY="sk-api_key"
28
+ GOOGLE_API_KEY="sk-api_key"
29
+ ```
30
+
31
+ Now you should be able to run **LLMstudio** Providers using the following code:
32
+
33
+ ```
34
+ # You can set OPENAI_API_KEY environment variable, add it to .env, or pass directly as api_key
35
+ import os
36
+ from llmstudio_core.providers import LLMCore as LLM
37
+ llm = LLM("vertexai", api_key=os.environ["GOOGLE_API_KEY"])
38
+ response = llm.chat("How are you", model="gemini-1.5-pro-latest")
39
+ print(response.chat_output, response.metrics)
40
+ ```
41
+ ## πŸ“– Documentation
42
+
43
+ - [Visit our docs to learn how the SDK works](https://docs.LLMstudio.ai) (coming soon)
44
+ - Checkout our [notebook examples](https://github.com/TensorOpsAI/LLMstudio/tree/main/examples) to follow along with interactive tutorials
45
+
46
+ ## πŸ‘¨β€πŸ’» Contributing
47
+
48
+ - Head on to our [Contribution Guide](https://github.com/TensorOpsAI/LLMstudio/tree/main/CONTRIBUTING.md) to see how you can help LLMstudio.
49
+ - Join our [Discord](https://discord.gg/GkAfPZR9wy) to talk with other LLMstudio enthusiasts.
50
+
51
+ ## Training
52
+
53
+ [![Banner](https://imgur.com/XTRFZ4m.png)](https://www.tensorops.ai/llm-studio-workshop)
54
+
55
+ ---
56
+
57
+ Thank you for choosing LLMstudio. Your journey to perfecting AI interactions starts here.
File without changes
@@ -0,0 +1,374 @@
1
+ providers:
2
+ anthropic:
3
+ id: anthropic
4
+ name: Anthropic
5
+ chat: true
6
+ embed: true
7
+ keys:
8
+ - ANTHROPIC_API_KEY
9
+ models:
10
+ claude-3-opus-20240229:
11
+ mode: chat
12
+ max_tokens: 200000
13
+ input_token_cost: 0.000015
14
+ output_token_cost: 0.000075
15
+ claude-3-sonnet-2024022:
16
+ mode: chat
17
+ max_tokens: 200000
18
+ input_token_cost: 0.000003
19
+ output_token_cost: 0.000015
20
+ claude-3-haiku-20240307:
21
+ mode: chat
22
+ max_tokens: 200000
23
+ input_token_cost: 0.00000025
24
+ output_token_cost: 0.00000125
25
+ claude-2.1:
26
+ mode: chat
27
+ max_tokens: 200000
28
+ input_token_cost: 0.000008
29
+ output_token_cost: 0.000024
30
+ claude-2:
31
+ mode: chat
32
+ max_tokens: 100000
33
+ input_token_cost: 0.000008
34
+ output_token_cost: 0.000024
35
+ claude-instant-1.2:
36
+ mode: chat
37
+ max_tokens: 100000
38
+ input_token_cost: 0.00000163
39
+ output_token_cost: 0.00000551
40
+ parameters:
41
+ temperature:
42
+ name: "Temperature"
43
+ type: float
44
+ default: 1
45
+ min: 0
46
+ max: 1
47
+ step: 0.01
48
+ max_tokens:
49
+ name: "Maximum tokens"
50
+ type: float
51
+ default: 256
52
+ min: 1
53
+ max: 4096
54
+ step: 0.01
55
+ top_p:
56
+ name: "Top P"
57
+ type: float
58
+ default: 1
59
+ min: 0
60
+ max: 1
61
+ step: 0.01
62
+ top_k:
63
+ name: "Top K"
64
+ type: float
65
+ default: 5
66
+ min: 0
67
+ max: 500
68
+ step: 1
69
+ ollama:
70
+ id: ollama
71
+ name: Ollama
72
+ chat: true
73
+ embed: true
74
+ keys:
75
+ models:
76
+ llama2:
77
+ mode: chat
78
+ max_tokens: 0
79
+ input_token_cost: 0
80
+ output_token_cost: 0
81
+ parameters:
82
+ temperature:
83
+ name: "Temperature"
84
+ type: float
85
+ default: 1
86
+ min: 0
87
+ max: 1
88
+ step: 0.01
89
+ max_tokens:
90
+ name: "Maximum tokens"
91
+ type: float
92
+ default: 256
93
+ min: 1
94
+ max: 4096
95
+ step: 0.01
96
+ top_p:
97
+ name: "Top P"
98
+ type: float
99
+ default: 1
100
+ min: 0
101
+ max: 1
102
+ step: 0.01
103
+ top_k:
104
+ name: "Top K"
105
+ type: float
106
+ default: 5
107
+ min: 0
108
+ max: 500
109
+ step: 1
110
+ openai:
111
+ id: openai
112
+ name: OpenAI
113
+ chat: true
114
+ embed: true
115
+ keys:
116
+ - OPENAI_API_KEY
117
+ models:
118
+ gpt-4o-mini:
119
+ mode: chat
120
+ max_tokens: 128000
121
+ input_token_cost: 0.00000015
122
+ output_token_cost: 0.00000060
123
+ gpt-4o:
124
+ mode: chat
125
+ max_tokens: 128000
126
+ input_token_cost: 0.000005
127
+ output_token_cost: 0.000015
128
+ gpt-4-turbo:
129
+ mode: chat
130
+ max_tokens: 128000
131
+ input_token_cost: 0.00001
132
+ output_token_cost: 0.00003
133
+ gpt-4:
134
+ mode: chat
135
+ max_tokens: 8192
136
+ input_token_cost: 0.00003
137
+ output_token_cost: 0.00006
138
+ gpt-3.5-turbo:
139
+ mode: chat
140
+ max_tokens: 16385
141
+ input_token_cost: 0.0000005
142
+ output_token_cost: 0.0000015
143
+ gpt-3.5-turbo-instruct:
144
+ mode: chat
145
+ max_tokens: 4096
146
+ input_token_cost: 0.0000015
147
+ output_token_cost: 0.000002
148
+ parameters:
149
+ temperature:
150
+ name: "Temperature"
151
+ type: float
152
+ default: 1
153
+ min: 0
154
+ max: 2
155
+ step: 0.01
156
+ max_tokens:
157
+ name: "Maximum length"
158
+ type: int
159
+ default: 256
160
+ min: 1
161
+ max: 4096
162
+ step: 1
163
+ top_p:
164
+ name: "Top P"
165
+ type: float
166
+ default: 1
167
+ min: 0
168
+ max: 1
169
+ step: 0.01
170
+ frequency_penalty:
171
+ name: "Frequency Penalty"
172
+ type: float
173
+ default: 0
174
+ min: 0
175
+ max: 2
176
+ step: 0.01
177
+ presence_penalty:
178
+ name: "Presence Penalty"
179
+ type: float
180
+ default: 0
181
+ min: 0
182
+ max: 2
183
+ step: 0.01
184
+ azure:
185
+ id: azure
186
+ name: Azure
187
+ chat: true
188
+ embed: true
189
+ keys:
190
+ - AZURE_API_KEY
191
+ - AZURE_API_ENDPOINT
192
+ - AZURE_API_VERSION
193
+ models:
194
+ gpt-4o-mini:
195
+ mode: chat
196
+ max_tokens: 128000
197
+ input_token_cost: 0.00000015
198
+ output_token_cost: 0.0000006
199
+ gpt-4o:
200
+ mode: chat
201
+ max_tokens: 128000
202
+ input_token_cost: 0.000005
203
+ output_token_cost: 0.000015
204
+ gpt-4-turbo:
205
+ mode: chat
206
+ max_tokens: 128000
207
+ input_token_cost: 0.00001
208
+ output_token_cost: 0.00003
209
+ gpt-4:
210
+ mode: chat
211
+ max_tokens: 8192
212
+ input_token_cost: 0.00003
213
+ output_token_cost: 0.00006
214
+ gpt-35-turbo:
215
+ mode: chat
216
+ max_tokens: 4097
217
+ input_token_cost: 0.0000005
218
+ output_token_cost: 0.0000015
219
+ Meta-Llama-3.1-405B-Instruct:
220
+ mode: chat
221
+ max_tokens: 128000
222
+ input_token_cost: 0.00533
223
+ output_token_cost: 0.016
224
+ Meta-Llama-3.1-70B-Instruct:
225
+ mode: chat
226
+ max_tokens: 128000
227
+ input_token_cost: 0.00268
228
+ output_token_cost: 0.00354
229
+ Meta-Llama-3.1-8B-Instruct:
230
+ mode: chat
231
+ max_tokens: 128000
232
+ input_token_cost: 0.0003
233
+ output_token_cost: 0.00061
234
+ Meta-Llama-3-70B-Instruct:
235
+ mode: chat
236
+ max_tokens: 8192
237
+ input_token_cost: 0.00378
238
+ output_token_cost: 0.01134
239
+ Meta-Llama-3-8B-Instruct:
240
+ mode: chat
241
+ max_tokens: 8192
242
+ input_token_cost: 0.00037
243
+ output_token_cost: 0.0011
244
+ Meta-Llama-2-70B:
245
+ mode: chat
246
+ max_tokens: 4096
247
+ input_token_cost: 0.00154
248
+ output_token_cost: 0.00177
249
+ Meta-Llama-2-70B-Chat:
250
+ mode: chat
251
+ max_tokens: 4096
252
+ input_token_cost: 0.00154
253
+ output_token_cost: 0.00177
254
+ Meta-Llama-2-13B-Chat:
255
+ mode: chat
256
+ max_tokens: 4096
257
+ input_token_cost: 0.00081
258
+ output_token_cost: 0.00094
259
+ Meta-Llama-2-7B:
260
+ mode: chat
261
+ max_tokens: 4096
262
+ input_token_cost: 0.00052
263
+ output_token_cost: 0.00067
264
+ parameters:
265
+ temperature:
266
+ name: "Temperature"
267
+ type: float
268
+ default: 1
269
+ min: 0
270
+ max: 2
271
+ step: 0.01
272
+ max_tokens:
273
+ name: "Maximum length"
274
+ type: int
275
+ default: 256
276
+ min: 1
277
+ max: 4096
278
+ step: 1
279
+ top_p:
280
+ name: "Top P"
281
+ type: float
282
+ default: 1
283
+ min: 0
284
+ max: 1
285
+ step: 0.01
286
+ frequency_penalty:
287
+ name: "Frequency Penalty"
288
+ type: float
289
+ default: 0
290
+ min: 0
291
+ max: 2
292
+ step: 0.01
293
+ presence_penalty:
294
+ name: "Presence Penalty"
295
+ type: float
296
+ default: 0
297
+ min: 0
298
+ max: 2
299
+ step: 0.01
300
+ vertexai:
301
+ id: vertexai
302
+ name: VertexAI
303
+ chat: true
304
+ embed: true
305
+ keys:
306
+ - GOOGLE_API_KEY
307
+ models:
308
+ gemini-1.5-flash:
309
+ mode: chat
310
+ max_tokens: 1000000
311
+ input_token_cost:
312
+ - range: [0, 128000]
313
+ cost: 0.00000035
314
+ - range: [128001, null]
315
+ cost: 0.0000007
316
+ output_token_cost:
317
+ - range: [0, 128000]
318
+ cost: 0.00000105
319
+ - range: [128001, null]
320
+ cost: 0.0000021
321
+ gemini-1.5-pro-latest:
322
+ mode: chat
323
+ max_tokens: 1000000
324
+ input_token_cost:
325
+ - range: [0, 128000]
326
+ cost: 0.00000035
327
+ - range: [128001, null]
328
+ cost: 0.0000007
329
+ output_token_cost:
330
+ - range: [0, 128000]
331
+ cost: 0.0000105
332
+ - range: [128001, null]
333
+ cost: 0.000021
334
+ gemini-1.0-pro:
335
+ mode: chat
336
+ max_tokens: 1000000
337
+ input_token_cost: 0.0000005
338
+ output_token_cost: 0.0000015
339
+ parameters:
340
+ temperature:
341
+ name: "Temperature"
342
+ type: float
343
+ default: 1
344
+ min: 0
345
+ max: 2
346
+ step: 0.01
347
+ max_tokens:
348
+ name: "Maximum length"
349
+ type: int
350
+ default: 256
351
+ min: 1
352
+ max: 4096
353
+ step: 1
354
+ top_p:
355
+ name: "Top P"
356
+ type: float
357
+ default: 1
358
+ min: 0
359
+ max: 1
360
+ step: 0.01
361
+ frequency_penalty:
362
+ name: "Frequency Penalty"
363
+ type: float
364
+ default: 0
365
+ min: 0
366
+ max: 2
367
+ step: 0.01
368
+ presence_penalty:
369
+ name: "Presence Penalty"
370
+ type: float
371
+ default: 0
372
+ min: 0
373
+ max: 2
374
+ step: 0.01
@@ -0,0 +1,6 @@
1
+ class CustomError(Exception):
2
+ """Base class for all custom exceptions"""
3
+
4
+
5
+ class ProviderError(CustomError):
6
+ """Raised when there is a validation error"""
@@ -0,0 +1,35 @@
1
+ # from llmstudio_core.providers.anthropic import AnthropicProvider #TODO: adpat it
2
+ from typing import Optional
3
+
4
+ from llmstudio_core.providers.azure import AzureProvider
5
+
6
+ # from llmstudio_core.providers.ollama import OllamaProvider #TODO: adapt it
7
+ from llmstudio_core.providers.openai import OpenAIProvider
8
+ from llmstudio_core.providers.provider import ProviderCore, provider_registry
9
+ from llmstudio_core.providers.vertexai import VertexAIProvider
10
+ from llmstudio_core.utils import _load_providers_config
11
+
12
+ _engine_config = _load_providers_config()
13
+
14
+
15
+ def LLMCore(provider: str, api_key: Optional[str] = None, **kwargs) -> ProviderCore:
16
+ """
17
+ Factory method to create an instance of a provider.
18
+
19
+ Args:
20
+ provider (str): The name of the provider.
21
+ api_key (Optional[str], optional): The API key for the provider. Defaults to None.
22
+
23
+ Returns:
24
+ ProviderCore: An instance of the provider.
25
+
26
+ Raises:
27
+ NotImplementedError: If the provider is not found in the provider map.
28
+ """
29
+ provider_config = _engine_config.providers.get(provider)
30
+ provider_class = provider_registry.get(provider_config.id)
31
+ if provider_class:
32
+ return provider_class(config=provider_config, api_key=api_key, **kwargs)
33
+ raise NotImplementedError(
34
+ f"Provider not found: {provider_config.id}. Available providers: {str(provider_registry.keys())}"
35
+ )