futureagi 0.1.1__tar.gz → 0.2.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.
Files changed (45) hide show
  1. {futureagi-0.1.1 → futureagi-0.2.0}/LICENSE.md +1 -1
  2. futureagi-0.2.0/PKG-INFO +241 -0
  3. futureagi-0.2.0/README.md +214 -0
  4. futureagi-0.2.0/fi/__init__.py +1 -0
  5. futureagi-0.2.0/fi/api/__init__.py +3 -0
  6. futureagi-0.2.0/fi/api/auth.py +178 -0
  7. futureagi-0.2.0/fi/api/types.py +25 -0
  8. futureagi-0.2.0/fi/client.py +318 -0
  9. futureagi-0.2.0/fi/evals/__init__.py +148 -0
  10. futureagi-0.2.0/fi/evals/evaluator.py +184 -0
  11. futureagi-0.2.0/fi/evals/templates.py +971 -0
  12. futureagi-0.2.0/fi/evals/types.py +115 -0
  13. futureagi-0.2.0/fi/integrations/providers/__init__.py +3879 -0
  14. futureagi-0.2.0/fi/integrations/providers/types.py +29 -0
  15. futureagi-0.2.0/fi/testcases/__init__.py +6 -0
  16. futureagi-0.2.0/fi/testcases/conversational_test_case.py +22 -0
  17. futureagi-0.2.0/fi/testcases/general.py +22 -0
  18. futureagi-0.2.0/fi/testcases/llm_test_case.py +10 -0
  19. futureagi-0.2.0/fi/testcases/mllm_test_case.py +58 -0
  20. futureagi-0.2.0/fi/testcases/utils.py +24 -0
  21. futureagi-0.2.0/fi/utils/__init__.py +1 -0
  22. {futureagi-0.1.1 → futureagi-0.2.0}/fi/utils/constants.py +11 -6
  23. {futureagi-0.1.1 → futureagi-0.2.0}/fi/utils/errors.py +49 -21
  24. futureagi-0.1.1/fi/bounded_executor.py → futureagi-0.2.0/fi/utils/executor.py +1 -1
  25. {futureagi-0.1.1 → futureagi-0.2.0}/fi/utils/logging.py +2 -1
  26. futureagi-0.2.0/fi/utils/routes.py +16 -0
  27. {futureagi-0.1.1 → futureagi-0.2.0}/fi/utils/types.py +14 -9
  28. {futureagi-0.1.1 → futureagi-0.2.0}/fi/utils/utils.py +5 -4
  29. futureagi-0.2.0/pyproject.toml +35 -0
  30. futureagi-0.1.1/MANIFEST.in +0 -2
  31. futureagi-0.1.1/PKG-INFO +0 -250
  32. futureagi-0.1.1/README.md +0 -224
  33. futureagi-0.1.1/fi/__init__.py +0 -1
  34. futureagi-0.1.1/fi/client.py +0 -311
  35. futureagi-0.1.1/fi/examples/__init__.py +0 -0
  36. futureagi-0.1.1/fi/examples/rag_file.py +0 -29
  37. futureagi-0.1.1/fi/utils/__init__.py +0 -1
  38. futureagi-0.1.1/futureagi.egg-info/PKG-INFO +0 -250
  39. futureagi-0.1.1/futureagi.egg-info/SOURCES.txt +0 -21
  40. futureagi-0.1.1/futureagi.egg-info/dependency_links.txt +0 -1
  41. futureagi-0.1.1/futureagi.egg-info/requires.txt +0 -12
  42. futureagi-0.1.1/futureagi.egg-info/top_level.txt +0 -2
  43. futureagi-0.1.1/setup.cfg +0 -4
  44. futureagi-0.1.1/setup.py +0 -22
  45. {futureagi-0.1.1/docs → futureagi-0.2.0/fi/integrations}/__init__.py +0 -0
@@ -13,4 +13,4 @@ Redistribution and use in source and binary forms, with or without modification,
13
13
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14
14
  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15
15
  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
16
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.1
2
+ Name: futureagi
3
+ Version: 0.2.0
4
+ Summary: We help GenAI teams maintain high-accuracy for their Models in production.
5
+ Author: FutureAgi
6
+ Requires-Python: >3.9
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Requires-Dist: certifi (==2024.6.2)
13
+ Requires-Dist: charset-normalizer (==3.3.2)
14
+ Requires-Dist: idna (==3.7)
15
+ Requires-Dist: numpy (==1.26.4)
16
+ Requires-Dist: pandas (==2.2.2)
17
+ Requires-Dist: pydantic (>=2.9.2,<3.0.0)
18
+ Requires-Dist: python-dateutil (==2.9.0.post0)
19
+ Requires-Dist: pytz (==2024.1)
20
+ Requires-Dist: requests (==2.32.3)
21
+ Requires-Dist: requests-futures (==1.0.1)
22
+ Requires-Dist: six (==1.16.0)
23
+ Requires-Dist: tzdata (==2024.1)
24
+ Requires-Dist: urllib3 (==2.2.2)
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Future AGI
28
+
29
+ ![Company Logo](https://github.com/future-agi/client/blob/main/Logo.png)
30
+
31
+ Welcome to Future AGI - Empowering GenAI Teams with Advanced Performance Management
32
+
33
+ # Overview
34
+
35
+ Future AGI provides a cutting-edge platform designed to help GenAI teams maintain peak model accuracy in production environments.
36
+ Our solution is purpose-built, scalable, and delivers results 10x faster than traditional methods.
37
+
38
+ **Key Features**
39
+
40
+ * **_Simplified GenAI Performance Management_**: Streamline your workflow and focus on developing cutting-edge AI models.
41
+ * **_Instant Evaluation_**: Score outputs without human-in-the-loop or ground truth, increasing QA team efficiency by up to 10x.
42
+ * **_Advanced Error Analytics_**: Gain ready-to-use insights with comprehensive error tagging and segmentation.
43
+ * **_Configurable Metrics_**: Define custom metrics tailored to your specific use case for precise model evaluation.
44
+
45
+ # Quickstart
46
+ **Installation**
47
+
48
+ To install the client, you can clone the repository or install the library:
49
+
50
+ Install the library in an environment using Python >= 3.6.
51
+ ```
52
+ $ pip3 install futureagi
53
+ ```
54
+ Or clone the repo:
55
+
56
+ ```
57
+ $ git clone https://github.com/future-agi/client
58
+ ```
59
+
60
+ **Initialisation**
61
+
62
+ To initialise the Future AGI Client, you need to provide your fi_api_key and fi_secret_key, which are associated with your Future AGI account.
63
+
64
+ Get your service API key When you create an account, we generate a service API key. You will need this API Key and your Space Key for logging authentication.
65
+ Instrument your code Python Client If you are using the Future AGI python client, add a few lines to your code to log your data. Logs are sent to us asynchronously.
66
+
67
+ ```
68
+ from fi.client import Client
69
+
70
+ fi_api_key = os.environ["FI_API_KEY"]
71
+ fi_secret_key = os.environ["FI_SECRET_KEY"]
72
+ base_url = os.environ["FI_API_URL"]
73
+
74
+ client = Client(fi_api_key=fi_api_key, fi_secret_key=fi_secret_key,
75
+ max_workers=8,
76
+ max_queue_bound=5000,
77
+ timeout=200,
78
+ additional_headers=None,
79
+ )
80
+ ```
81
+
82
+ **Initialises the Future AGI Client**
83
+ * _fi_api_key_: provided API key associated with your account.
84
+ * _fi_secret_key_: provided identifier to connect records to spaces.
85
+ * _uri_: URI to send your records to Future AGI client.
86
+ * _max_workers_: maximum number of concurrent requests to Future AGI. Defaults to 8.
87
+ * _max_queue_bound_: maximum number of concurrent future objects generated for publishing to Future AGI. Defaults to 5000.
88
+ * _timeout_: how long to wait for the server to send data before giving up. Defaults to 200.
89
+ * _additional_headers_: Dictionary of additional headers to append to request
90
+
91
+ You can also set these keys as environment variables:
92
+ ```
93
+ export FI_API_KEY=your_api_key
94
+ export FI_SECRET_KEY=your_secret_key
95
+ ```
96
+ And then initialise the client without passing the keys directly:
97
+
98
+ ```
99
+ from fi.utils.types import ModelTypes, Environments
100
+
101
+ client.log(
102
+ model_id="your_model_id",
103
+ model_type=ModelTypes.GENERATIVE_LLM,
104
+ environment=Environments.PRODUCTION,
105
+ model_version="1.0.0",
106
+ prediction_timestamp=1625216400,
107
+ conversation={
108
+ "chat_history": [
109
+ {"role": "user", "content": "How do I implement a neural network in Python?"}
110
+ ]
111
+ },
112
+ tags={"project": "AI project"}
113
+ )
114
+ ```
115
+
116
+ **Parameters**
117
+ * _model_id_: The ID of the model. Must be a string.
118
+ * _model_type_: The type of the model. Must be an instance of ModelTypes.
119
+ * _environment_: The environment in which the model is running. Must be an instance of Environments.
120
+ * _model_version_: The version of the model. Must be a string.
121
+ * _prediction_timestamp_: (Optional) The timestamp of the prediction. Must be an integer.
122
+ * _conversation_: The conversation data. Must be a dictionary containing either chat_history or chat_graph.
123
+ * _tags_: (Optional) Additional tags for the event. Must be a dictionary.
124
+
125
+ **_[For full details, see our docs.](https://docs.futureagi.com/)_**
126
+
127
+
128
+ **Conversation Format**
129
+
130
+ **Chat History**
131
+ The chat_history must be a list of dictionaries with the following keys:
132
+ * _role_: The role of the participant (e.g., “user”, “assistant”). Must be a string.
133
+ * _content_: The content of the message. Must be a string.
134
+ * _context_: (Optional) The context of the message. Must be a list of pairs of strings in the format [["", ""]...].
135
+
136
+ **Chat History with conversation ID**
137
+ The chat_history must be a list of dictionaries with the following keys:
138
+ * _conversation_id_: The ID of the conversation. Must be a string.
139
+ * _role_: The role of the participant (e.g., “user”, “assistant”). Must be a string.
140
+ * _content_: The content of the message. Must be a string.
141
+ * _context_: (Optional) The context of the message. Must be a list of pairs of strings in the format [["", ""]...].
142
+
143
+ **Chat Graph**
144
+ The chat_graph must be a dictionary with the following keys:
145
+ * _conversation_id_: The ID of the conversation. Must be a string.
146
+ * _nodes_: A list of nodes, each containing:
147
+ * _message_: A dictionary with the message details.
148
+ * _node_id_: The ID of the node. Must be a string.
149
+ * _parent_id_: The ID of the parent node. Must be a string.
150
+ * _timestamp_: The timestamp of the node. Must be an integer.
151
+
152
+
153
+ 1. **Logging data individually:** For example, "chat_history" may include a list of dictionaries where each dictionary represents a message with attributes like "role" (str) and "content" (str) .
154
+
155
+ ```
156
+ {
157
+ "chat_history": [
158
+ {
159
+ "role": "user",
160
+ "content": "Who won the world series in 2020?"
161
+ },
162
+ {
163
+ "role": "assistant",
164
+ "content": "The Los Angeles Dodgers won the World Series in 2020."
165
+ }
166
+ ]
167
+ }
168
+ ```
169
+
170
+ 1. **Logging data all at once:** This involves logging structured conversations in a unified format:
171
+ ```
172
+ [{
173
+ "conversation_id": "",
174
+ "title": "",
175
+ "root_node": "",
176
+ "metadata": {},
177
+ "nodes": [{
178
+ "parent_node": "",
179
+ "child_node": "",
180
+ "message": {
181
+ "id": "",
182
+ "author": {
183
+ "role": "assistant",
184
+ "metadata": {}
185
+ },
186
+ "content": {
187
+ "content_type": "text",
188
+ "parts": [
189
+ "The user is interested to do this task..."
190
+ ]
191
+ }
192
+ "context": ""
193
+ }
194
+ }]
195
+ }]
196
+ ```
197
+ **Error Handling**
198
+ The client raises specific exceptions for different types of errors:
199
+ * _AuthError_: Raised if the API key or secret key is missing.
200
+ * _InvalidAdditionalHeaders_: Raised if there are conflicting additional headers.
201
+ * _InvalidValueType_: Raised if a parameter has an invalid type.
202
+ * _InvalidSupportedType_: Raised if a model type is not supported.
203
+ * _MissingRequiredKey_: Raised if a required key is missing.
204
+ * _InvalidVectorLength_: Raised if the vector length is invalid.
205
+
206
+ # FAQ’s:
207
+
208
+ 1. Q: How do you give a performance score without human in the loop?
209
+
210
+ Our secret Sauce is a Critique AI agent that can deliver powerful evaluation framework without need for human in the loop. What’s more is that it is 100% configurable as per new evolving use cases. Now anything that you can imagine your AI system should deliver - you can configure our platform to manage it.
211
+
212
+ 2. Q: What all inputs Future AGI platform needs?
213
+
214
+ We would need only the input-output database, training dataset if available, and User-analytics. We do not need to understand the model and how it is taking decisions.
215
+
216
+ 3. Q: I don't want to share data with Future AGI, can I still use it?
217
+
218
+ Yes, you can now install our SDK in your private cloud and take advantage of our strong platform to align your AI system to your users.
219
+
220
+
221
+ 4. Q: My use case is unique, would you provide service to customise your platform as per my use case?
222
+
223
+ Our platform is 100% customisable and easy to configure for all types of models and modalities by the AI teams. However, our customer-success engineer would be happy to assist you for figuring out solutions to your unique use cases.
224
+
225
+ 5. Q: My app uses multiple models with multiple modalities, can you work with images and videos also?
226
+
227
+ Yes we can.
228
+
229
+ 6. Q: How much time does it take to integrate the Future AGI platform? How much bandwidth would be required?
230
+
231
+ It takes just 2 minutes to integrate a few lines of code and your data starts showing on our platform. Try it today.
232
+
233
+
234
+ # Resources
235
+
236
+ **Website**: https://www.futureagi.com/
237
+
238
+ **Documentation**: https://docs.futureagi.com/
239
+
240
+ **PyPI** : https://pypi.org/project/futureagi/
241
+
@@ -0,0 +1,214 @@
1
+ # Future AGI
2
+
3
+ ![Company Logo](https://github.com/future-agi/client/blob/main/Logo.png)
4
+
5
+ Welcome to Future AGI - Empowering GenAI Teams with Advanced Performance Management
6
+
7
+ # Overview
8
+
9
+ Future AGI provides a cutting-edge platform designed to help GenAI teams maintain peak model accuracy in production environments.
10
+ Our solution is purpose-built, scalable, and delivers results 10x faster than traditional methods.
11
+
12
+ **Key Features**
13
+
14
+ * **_Simplified GenAI Performance Management_**: Streamline your workflow and focus on developing cutting-edge AI models.
15
+ * **_Instant Evaluation_**: Score outputs without human-in-the-loop or ground truth, increasing QA team efficiency by up to 10x.
16
+ * **_Advanced Error Analytics_**: Gain ready-to-use insights with comprehensive error tagging and segmentation.
17
+ * **_Configurable Metrics_**: Define custom metrics tailored to your specific use case for precise model evaluation.
18
+
19
+ # Quickstart
20
+ **Installation**
21
+
22
+ To install the client, you can clone the repository or install the library:
23
+
24
+ Install the library in an environment using Python >= 3.6.
25
+ ```
26
+ $ pip3 install futureagi
27
+ ```
28
+ Or clone the repo:
29
+
30
+ ```
31
+ $ git clone https://github.com/future-agi/client
32
+ ```
33
+
34
+ **Initialisation**
35
+
36
+ To initialise the Future AGI Client, you need to provide your fi_api_key and fi_secret_key, which are associated with your Future AGI account.
37
+
38
+ Get your service API key When you create an account, we generate a service API key. You will need this API Key and your Space Key for logging authentication.
39
+ Instrument your code Python Client If you are using the Future AGI python client, add a few lines to your code to log your data. Logs are sent to us asynchronously.
40
+
41
+ ```
42
+ from fi.client import Client
43
+
44
+ fi_api_key = os.environ["FI_API_KEY"]
45
+ fi_secret_key = os.environ["FI_SECRET_KEY"]
46
+ base_url = os.environ["FI_API_URL"]
47
+
48
+ client = Client(fi_api_key=fi_api_key, fi_secret_key=fi_secret_key,
49
+ max_workers=8,
50
+ max_queue_bound=5000,
51
+ timeout=200,
52
+ additional_headers=None,
53
+ )
54
+ ```
55
+
56
+ **Initialises the Future AGI Client**
57
+ * _fi_api_key_: provided API key associated with your account.
58
+ * _fi_secret_key_: provided identifier to connect records to spaces.
59
+ * _uri_: URI to send your records to Future AGI client.
60
+ * _max_workers_: maximum number of concurrent requests to Future AGI. Defaults to 8.
61
+ * _max_queue_bound_: maximum number of concurrent future objects generated for publishing to Future AGI. Defaults to 5000.
62
+ * _timeout_: how long to wait for the server to send data before giving up. Defaults to 200.
63
+ * _additional_headers_: Dictionary of additional headers to append to request
64
+
65
+ You can also set these keys as environment variables:
66
+ ```
67
+ export FI_API_KEY=your_api_key
68
+ export FI_SECRET_KEY=your_secret_key
69
+ ```
70
+ And then initialise the client without passing the keys directly:
71
+
72
+ ```
73
+ from fi.utils.types import ModelTypes, Environments
74
+
75
+ client.log(
76
+ model_id="your_model_id",
77
+ model_type=ModelTypes.GENERATIVE_LLM,
78
+ environment=Environments.PRODUCTION,
79
+ model_version="1.0.0",
80
+ prediction_timestamp=1625216400,
81
+ conversation={
82
+ "chat_history": [
83
+ {"role": "user", "content": "How do I implement a neural network in Python?"}
84
+ ]
85
+ },
86
+ tags={"project": "AI project"}
87
+ )
88
+ ```
89
+
90
+ **Parameters**
91
+ * _model_id_: The ID of the model. Must be a string.
92
+ * _model_type_: The type of the model. Must be an instance of ModelTypes.
93
+ * _environment_: The environment in which the model is running. Must be an instance of Environments.
94
+ * _model_version_: The version of the model. Must be a string.
95
+ * _prediction_timestamp_: (Optional) The timestamp of the prediction. Must be an integer.
96
+ * _conversation_: The conversation data. Must be a dictionary containing either chat_history or chat_graph.
97
+ * _tags_: (Optional) Additional tags for the event. Must be a dictionary.
98
+
99
+ **_[For full details, see our docs.](https://docs.futureagi.com/)_**
100
+
101
+
102
+ **Conversation Format**
103
+
104
+ **Chat History**
105
+ The chat_history must be a list of dictionaries with the following keys:
106
+ * _role_: The role of the participant (e.g., “user”, “assistant”). Must be a string.
107
+ * _content_: The content of the message. Must be a string.
108
+ * _context_: (Optional) The context of the message. Must be a list of pairs of strings in the format [["", ""]...].
109
+
110
+ **Chat History with conversation ID**
111
+ The chat_history must be a list of dictionaries with the following keys:
112
+ * _conversation_id_: The ID of the conversation. Must be a string.
113
+ * _role_: The role of the participant (e.g., “user”, “assistant”). Must be a string.
114
+ * _content_: The content of the message. Must be a string.
115
+ * _context_: (Optional) The context of the message. Must be a list of pairs of strings in the format [["", ""]...].
116
+
117
+ **Chat Graph**
118
+ The chat_graph must be a dictionary with the following keys:
119
+ * _conversation_id_: The ID of the conversation. Must be a string.
120
+ * _nodes_: A list of nodes, each containing:
121
+ * _message_: A dictionary with the message details.
122
+ * _node_id_: The ID of the node. Must be a string.
123
+ * _parent_id_: The ID of the parent node. Must be a string.
124
+ * _timestamp_: The timestamp of the node. Must be an integer.
125
+
126
+
127
+ 1. **Logging data individually:** For example, "chat_history" may include a list of dictionaries where each dictionary represents a message with attributes like "role" (str) and "content" (str) .
128
+
129
+ ```
130
+ {
131
+ "chat_history": [
132
+ {
133
+ "role": "user",
134
+ "content": "Who won the world series in 2020?"
135
+ },
136
+ {
137
+ "role": "assistant",
138
+ "content": "The Los Angeles Dodgers won the World Series in 2020."
139
+ }
140
+ ]
141
+ }
142
+ ```
143
+
144
+ 1. **Logging data all at once:** This involves logging structured conversations in a unified format:
145
+ ```
146
+ [{
147
+ "conversation_id": "",
148
+ "title": "",
149
+ "root_node": "",
150
+ "metadata": {},
151
+ "nodes": [{
152
+ "parent_node": "",
153
+ "child_node": "",
154
+ "message": {
155
+ "id": "",
156
+ "author": {
157
+ "role": "assistant",
158
+ "metadata": {}
159
+ },
160
+ "content": {
161
+ "content_type": "text",
162
+ "parts": [
163
+ "The user is interested to do this task..."
164
+ ]
165
+ }
166
+ "context": ""
167
+ }
168
+ }]
169
+ }]
170
+ ```
171
+ **Error Handling**
172
+ The client raises specific exceptions for different types of errors:
173
+ * _AuthError_: Raised if the API key or secret key is missing.
174
+ * _InvalidAdditionalHeaders_: Raised if there are conflicting additional headers.
175
+ * _InvalidValueType_: Raised if a parameter has an invalid type.
176
+ * _InvalidSupportedType_: Raised if a model type is not supported.
177
+ * _MissingRequiredKey_: Raised if a required key is missing.
178
+ * _InvalidVectorLength_: Raised if the vector length is invalid.
179
+
180
+ # FAQ’s:
181
+
182
+ 1. Q: How do you give a performance score without human in the loop?
183
+
184
+ Our secret Sauce is a Critique AI agent that can deliver powerful evaluation framework without need for human in the loop. What’s more is that it is 100% configurable as per new evolving use cases. Now anything that you can imagine your AI system should deliver - you can configure our platform to manage it.
185
+
186
+ 2. Q: What all inputs Future AGI platform needs?
187
+
188
+ We would need only the input-output database, training dataset if available, and User-analytics. We do not need to understand the model and how it is taking decisions.
189
+
190
+ 3. Q: I don't want to share data with Future AGI, can I still use it?
191
+
192
+ Yes, you can now install our SDK in your private cloud and take advantage of our strong platform to align your AI system to your users.
193
+
194
+
195
+ 4. Q: My use case is unique, would you provide service to customise your platform as per my use case?
196
+
197
+ Our platform is 100% customisable and easy to configure for all types of models and modalities by the AI teams. However, our customer-success engineer would be happy to assist you for figuring out solutions to your unique use cases.
198
+
199
+ 5. Q: My app uses multiple models with multiple modalities, can you work with images and videos also?
200
+
201
+ Yes we can.
202
+
203
+ 6. Q: How much time does it take to integrate the Future AGI platform? How much bandwidth would be required?
204
+
205
+ It takes just 2 minutes to integrate a few lines of code and your data starts showing on our platform. Try it today.
206
+
207
+
208
+ # Resources
209
+
210
+ **Website**: https://www.futureagi.com/
211
+
212
+ **Documentation**: https://docs.futureagi.com/
213
+
214
+ **PyPI** : https://pypi.org/project/futureagi/
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
@@ -0,0 +1,3 @@
1
+ from fi.api.auth import APIKeyAuth # noqa: F401
2
+
3
+ __all__ = ["APIKeyAuth"]
@@ -0,0 +1,178 @@
1
+ import os
2
+ import time
3
+ from abc import ABC, abstractmethod
4
+ from typing import Dict, Generic, Optional, TypeVar, Union
5
+
6
+ from requests import Response
7
+ from requests_futures.sessions import FuturesSession
8
+
9
+ from fi.api.types import RequestConfig
10
+ from fi.integrations.providers.types import ApiKeyName
11
+ from fi.utils.constants import (
12
+ API_KEY_ENVVAR_NAME,
13
+ BASE_URL,
14
+ DEFAULT_MAX_QUEUE,
15
+ DEFAULT_MAX_WORKERS,
16
+ DEFAULT_TIMEOUT,
17
+ SECRET_KEY_ENVVAR_NAME,
18
+ )
19
+ from fi.utils.errors import AuthError
20
+ from fi.utils.executor import BoundedExecutor
21
+
22
+ T = TypeVar("T")
23
+
24
+
25
+ class ResponseHandler(Generic[T], ABC):
26
+ """Handles response parsing and validation"""
27
+
28
+ @classmethod
29
+ def parse(cls, response: Response) -> T:
30
+ """Parse the response into the expected type"""
31
+ if not response.ok:
32
+ cls._handle_error(response)
33
+ return cls._parse_success(response)
34
+
35
+ @classmethod
36
+ @abstractmethod
37
+ def _parse_success(cls, response: Response) -> T:
38
+ """Parse successful response"""
39
+ pass
40
+
41
+ @classmethod
42
+ @abstractmethod
43
+ def _handle_error(cls, response: Response) -> None:
44
+ """Handle error responses"""
45
+ pass
46
+
47
+
48
+ class HttpClient:
49
+ """Base HTTP client with improved request handling"""
50
+
51
+ def __init__(
52
+ self,
53
+ base_url: Optional[str] = None,
54
+ session: Optional[FuturesSession] = None,
55
+ default_headers: Optional[Dict[str, str]] = None,
56
+ **kwargs,
57
+ ):
58
+ self._base_url = base_url.rstrip("/") if base_url else BASE_URL.rstrip("/")
59
+ self._session = session or FuturesSession(
60
+ executor=BoundedExecutor(
61
+ bound=kwargs.get("max_queue", DEFAULT_MAX_QUEUE),
62
+ max_workers=kwargs.get("max_workers", DEFAULT_MAX_WORKERS),
63
+ ),
64
+ )
65
+ self._default_headers = default_headers or {}
66
+ self._default_timeout = kwargs.get("timeout", DEFAULT_TIMEOUT)
67
+
68
+ def request(
69
+ self,
70
+ config: RequestConfig,
71
+ response_handler: Optional[ResponseHandler[T]] = None,
72
+ ) -> Union[Response, T]:
73
+ """Make an HTTP request with retries and response handling"""
74
+
75
+ url = config.url
76
+ headers = {**self._default_headers, **(config.headers or {})}
77
+ params = config.params or {}
78
+ json = config.json or {}
79
+ timeout = config.timeout or self._default_timeout
80
+ for attempt in range(config.retry_attempts):
81
+ try:
82
+ response = self._session.request(
83
+ method=config.method.value,
84
+ url=url,
85
+ headers=headers,
86
+ params=params,
87
+ json=json,
88
+ timeout=timeout,
89
+ ).result()
90
+
91
+ if response_handler:
92
+ return response_handler.parse(response=response)
93
+ return response
94
+
95
+ except Exception as e:
96
+ if attempt == config.retry_attempts - 1:
97
+ raise e
98
+ time.sleep(config.retry_delay)
99
+
100
+ def close(self):
101
+ """Close the client session"""
102
+ self._session.close()
103
+
104
+
105
+ class APIKeyAuth(HttpClient):
106
+ _fi_api_key: str = None
107
+ _fi_secret_key: str = None
108
+
109
+ def __init__(
110
+ self,
111
+ fi_api_key: Optional[str] = None,
112
+ fi_secret_key: Optional[str] = None,
113
+ fi_base_url: Optional[str] = None,
114
+ **kwargs,
115
+ ):
116
+ self.__class__._fi_api_key = fi_api_key or os.environ.get(API_KEY_ENVVAR_NAME)
117
+ self.__class__._fi_secret_key = fi_secret_key or os.environ.get(
118
+ SECRET_KEY_ENVVAR_NAME
119
+ )
120
+ if self._fi_api_key is None or self._fi_secret_key is None:
121
+ raise AuthError(self._fi_api_key, self._fi_secret_key)
122
+
123
+ super().__init__(
124
+ base_url=fi_base_url,
125
+ default_headers={
126
+ "X-Api-Key": self._fi_api_key,
127
+ "X-Secret-Key": self._fi_secret_key,
128
+ },
129
+ **kwargs,
130
+ )
131
+
132
+
133
+ class APIKeyManager(APIKeyAuth):
134
+ _instance = None
135
+
136
+ def __new__(cls):
137
+ if cls._instance is None:
138
+ cls._instance = super().__new__(cls)
139
+ cls._instance._initialize()
140
+ return cls._instance
141
+
142
+ @property
143
+ def url(self) -> str:
144
+ return self.BASE_URL + "/model_hub/api-keys"
145
+
146
+ @property
147
+ def headers(self) -> dict:
148
+ return {
149
+ "X-Api-Key": self._fi_api_key,
150
+ "X-Secret-Key": self._fi_secret_key,
151
+ }
152
+
153
+ def _initialize(self):
154
+ self._api_keys: Dict[ApiKeyName, Optional[str]] = {
155
+ key: os.getenv(key.value) for key in ApiKeyName
156
+ }
157
+
158
+ def get_api_key(self, provider: ApiKeyName) -> Optional[str]:
159
+ if provider not in self._api_keys:
160
+ raise ValueError(f"Provider {provider} not found in API keys") # noqa: E713
161
+ return self._api_keys[provider]
162
+
163
+ def set_api_key(self, provider: ApiKeyName, key: str) -> None:
164
+ self._api_keys[provider] = key
165
+
166
+ def validate_required_keys(self, required_providers: list[ApiKeyName]) -> bool:
167
+ if not required_providers:
168
+ return True
169
+
170
+ missing_keys = [
171
+ provider.value
172
+ for provider in required_providers
173
+ if provider not in self._api_keys
174
+ ]
175
+
176
+ if missing_keys:
177
+ raise ValueError(f"Missing required API keys: {', '.join(missing_keys)}")
178
+ return True
@@ -0,0 +1,25 @@
1
+ from enum import Enum
2
+ from typing import Any, Dict, Optional
3
+
4
+ from pydantic import BaseModel
5
+
6
+
7
+ class HttpMethod(Enum):
8
+ GET = "GET"
9
+ POST = "POST"
10
+ PUT = "PUT"
11
+ DELETE = "DELETE"
12
+ PATCH = "PATCH"
13
+
14
+
15
+ class RequestConfig(BaseModel):
16
+ """Configuration for an HTTP request"""
17
+
18
+ method: HttpMethod
19
+ url: str
20
+ headers: Optional[Dict[str, str]] = {}
21
+ params: Optional[Dict[str, Any]] = {}
22
+ json: Optional[Dict[str, Any]] = {}
23
+ timeout: Optional[int] = None
24
+ retry_attempts: int = 3
25
+ retry_delay: float = 1.0