futureagi 0.3.7__tar.gz → 0.4.1__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 (40) hide show
  1. {futureagi-0.3.7 → futureagi-0.4.1}/PKG-INFO +2 -1
  2. futureagi-0.4.1/fi/api/apikeys.py +147 -0
  3. {futureagi-0.3.7 → futureagi-0.4.1}/fi/api/auth.py +4 -2
  4. futureagi-0.4.1/fi/api/types.py +66 -0
  5. futureagi-0.4.1/fi/datasets/client.py +753 -0
  6. {futureagi-0.3.7 → futureagi-0.4.1}/fi/datasets/types.py +40 -7
  7. {futureagi-0.3.7 → futureagi-0.4.1}/fi/evals/__init__.py +1 -0
  8. {futureagi-0.3.7 → futureagi-0.4.1}/fi/evals/evaluator.py +4 -2
  9. {futureagi-0.3.7 → futureagi-0.4.1}/fi/evals/types.py +2 -2
  10. futureagi-0.4.1/fi/prompt/__init__.py +3 -0
  11. futureagi-0.4.1/fi/prompt/client.py +284 -0
  12. futureagi-0.4.1/fi/prompt/types.py +111 -0
  13. {futureagi-0.3.7 → futureagi-0.4.1}/fi/utils/errors.py +11 -0
  14. futureagi-0.4.1/fi/utils/routes.py +40 -0
  15. {futureagi-0.3.7 → futureagi-0.4.1}/pyproject.toml +2 -1
  16. futureagi-0.3.7/fi/api/types.py +0 -27
  17. futureagi-0.3.7/fi/datasets/client.py +0 -359
  18. futureagi-0.3.7/fi/utils/routes.py +0 -17
  19. {futureagi-0.3.7 → futureagi-0.4.1}/LICENSE.md +0 -0
  20. {futureagi-0.3.7 → futureagi-0.4.1}/README.md +0 -0
  21. {futureagi-0.3.7 → futureagi-0.4.1}/fi/__init__.py +0 -0
  22. {futureagi-0.3.7 → futureagi-0.4.1}/fi/api/__init__.py +0 -0
  23. {futureagi-0.3.7 → futureagi-0.4.1}/fi/client.py +0 -0
  24. {futureagi-0.3.7 → futureagi-0.4.1}/fi/datasets/__init__.py +0 -0
  25. {futureagi-0.3.7 → futureagi-0.4.1}/fi/evals/templates.py +0 -0
  26. {futureagi-0.3.7 → futureagi-0.4.1}/fi/integrations/__init__.py +0 -0
  27. {futureagi-0.3.7 → futureagi-0.4.1}/fi/integrations/providers/__init__.py +0 -0
  28. {futureagi-0.3.7 → futureagi-0.4.1}/fi/integrations/providers/types.py +0 -0
  29. {futureagi-0.3.7 → futureagi-0.4.1}/fi/testcases/__init__.py +0 -0
  30. {futureagi-0.3.7 → futureagi-0.4.1}/fi/testcases/conversational_test_case.py +0 -0
  31. {futureagi-0.3.7 → futureagi-0.4.1}/fi/testcases/general.py +0 -0
  32. {futureagi-0.3.7 → futureagi-0.4.1}/fi/testcases/llm_test_case.py +0 -0
  33. {futureagi-0.3.7 → futureagi-0.4.1}/fi/testcases/mllm_test_case.py +0 -0
  34. {futureagi-0.3.7 → futureagi-0.4.1}/fi/testcases/utils.py +0 -0
  35. {futureagi-0.3.7 → futureagi-0.4.1}/fi/utils/__init__.py +0 -0
  36. {futureagi-0.3.7 → futureagi-0.4.1}/fi/utils/constants.py +0 -0
  37. {futureagi-0.3.7 → futureagi-0.4.1}/fi/utils/executor.py +0 -0
  38. {futureagi-0.3.7 → futureagi-0.4.1}/fi/utils/logging.py +0 -0
  39. {futureagi-0.3.7 → futureagi-0.4.1}/fi/utils/types.py +0 -0
  40. {futureagi-0.3.7 → futureagi-0.4.1}/fi/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: futureagi
3
- Version: 0.3.7
3
+ Version: 0.4.1
4
4
  Summary: We help GenAI teams maintain high-accuracy for their Models in production.
5
5
  Author: Future AGI
6
6
  Author-email: no-reply@futureagi.com
@@ -21,6 +21,7 @@ Requires-Dist: pytz (==2024.1)
21
21
  Requires-Dist: requests (==2.32.3)
22
22
  Requires-Dist: requests-futures (==1.0.1)
23
23
  Requires-Dist: six (==1.16.0)
24
+ Requires-Dist: tqdm (>=4.67.1,<5.0.0)
24
25
  Requires-Dist: tzdata (==2024.1)
25
26
  Requires-Dist: urllib3 (==2.2.2)
26
27
  Description-Content-Type: text/markdown
@@ -0,0 +1,147 @@
1
+ from typing import List, Optional, Union
2
+
3
+ from requests import Response
4
+
5
+ from fi.api.auth import APIKeyAuth, ResponseHandler
6
+ from fi.api.types import ApiKey, HttpMethod, ModelProvider, RequestConfig
7
+ from fi.utils.routes import Routes
8
+
9
+
10
+ class ProviderAPIKeyResponseHandler(ResponseHandler[ApiKey, None]):
11
+ """Handles responses for API key operations"""
12
+
13
+ @classmethod
14
+ def _parse_success(cls, response: Response) -> Union[ApiKey, List[ApiKey]]:
15
+ data = response.json()
16
+ method = response.request.method
17
+ if method == HttpMethod.POST.value:
18
+ return {
19
+ "success": True,
20
+ }
21
+ elif method == HttpMethod.GET.value:
22
+ data = data["results"]
23
+ result = []
24
+ for api_key in data:
25
+ result.append(ApiKey(**api_key))
26
+ return result
27
+ else:
28
+ return data
29
+
30
+ @classmethod
31
+ def _handle_error(cls, response: Response) -> None:
32
+ if response.status_code >= 400:
33
+ response.raise_for_status()
34
+
35
+
36
+ class ProviderAPIKeyClient(APIKeyAuth):
37
+ """Client for API key operations
38
+
39
+ This client can be used in two ways:
40
+ 1. As class methods for simple one-off operations:
41
+ ProviderAPIKeyClient.set_api_key(api_key)
42
+
43
+ 2. As an instance for chained operations:
44
+ client = ProviderAPIKeyClient()
45
+ client.set(api_key).get(provider)
46
+ """
47
+
48
+ def __init__(
49
+ self,
50
+ api_key: ApiKey,
51
+ fi_api_key: Optional[str] = None,
52
+ fi_secret_key: Optional[str] = None,
53
+ fi_base_url: Optional[str] = None,
54
+ ):
55
+ """
56
+ Initialize the ProviderAPIKeyClient
57
+
58
+ Args:
59
+ fi_api_key (str): The API key for the organization
60
+ fi_secret_key (str): The secret key for the organization
61
+ fi_base_url (str): The base URL for the organization
62
+ api_key (ApiKey): The API key to set
63
+
64
+ Returns:
65
+ ProviderAPIKeyClient: The initialized client
66
+ """
67
+ super().__init__(fi_api_key, fi_secret_key, fi_base_url)
68
+ self.api_key = api_key
69
+
70
+ # Instance methods for chaining
71
+ def set(self) -> "ProviderAPIKeyClient":
72
+ """Create a new API key and return self for chaining"""
73
+ if self.api_key.key is None:
74
+ raise ValueError("API key is required")
75
+ response = self._set_api_key(self.api_key) # noqa: F841
76
+ return self
77
+
78
+ def get(self) -> Optional[ApiKey]:
79
+ """Get a specific API key by provider"""
80
+ response = self._get_api_key(self.api_key.provider)
81
+ self.api_key = response
82
+ return response
83
+
84
+ # Protected internal methods
85
+ def _set_api_key(self, api_key: ApiKey) -> ApiKey:
86
+ """Internal method for setting API key"""
87
+ response = self.request(
88
+ config=RequestConfig(
89
+ method=HttpMethod.POST,
90
+ url=self._base_url + "/" + Routes.model_hub_api_keys.value,
91
+ json={
92
+ "provider": api_key.provider.value,
93
+ "key": api_key.key,
94
+ },
95
+ ),
96
+ response_handler=ProviderAPIKeyResponseHandler,
97
+ )
98
+ return response
99
+
100
+ def _get_api_key(self, provider: ModelProvider) -> Optional[ApiKey]:
101
+ """Internal method to get API key by provider"""
102
+ response = self.request(
103
+ config=RequestConfig(
104
+ method=HttpMethod.GET,
105
+ url=self._base_url + "/" + Routes.model_hub_api_keys.value,
106
+ ),
107
+ response_handler=ProviderAPIKeyResponseHandler,
108
+ )
109
+ if response:
110
+ for api_key in response:
111
+ if api_key.provider == provider:
112
+ return api_key
113
+ return None
114
+
115
+ # Class methods for simple operations
116
+ @classmethod
117
+ def _get_instance(cls, api_key: ApiKey, **kwargs) -> "ProviderAPIKeyClient":
118
+ """Create a new ProviderAPIKeyClient instance"""
119
+ instance = cls(api_key, **kwargs) if isinstance(cls, type) else cls
120
+ instance.api_key = api_key
121
+ return instance
122
+
123
+ @classmethod
124
+ def set_api_key(cls, api_key: ApiKey, **kwargs) -> ApiKey:
125
+ """Class method for simple API key creation"""
126
+ instance = cls._get_instance(api_key, **kwargs)
127
+ return instance.set()
128
+
129
+ @classmethod
130
+ def get_api_key(cls, provider: ModelProvider, **kwargs) -> Optional[ApiKey]:
131
+ """Class method for simple API key retrieval"""
132
+ api_key = ApiKey(provider=provider)
133
+ instance = cls._get_instance(api_key, **kwargs)
134
+ return instance.get()
135
+
136
+ @classmethod
137
+ def list_api_keys(cls, **kwargs) -> List[ApiKey]:
138
+ """List all API keys for the organization"""
139
+ instance = cls._get_instance(ApiKey(), **kwargs)
140
+ response = instance.request(
141
+ config=RequestConfig(
142
+ method=HttpMethod.GET,
143
+ url=instance._base_url + "/" + Routes.model_hub_api_keys.value,
144
+ ),
145
+ response_handler=ProviderAPIKeyResponseHandler,
146
+ )
147
+ return response
@@ -16,7 +16,7 @@ from fi.utils.constants import (
16
16
  DEFAULT_TIMEOUT,
17
17
  SECRET_KEY_ENVVAR_NAME,
18
18
  )
19
- from fi.utils.errors import MissingAuthError
19
+ from fi.utils.errors import MissingAuthError, NoDatasetFound
20
20
  from fi.utils.executor import BoundedExecutor
21
21
 
22
22
  T = TypeVar("T")
@@ -29,7 +29,7 @@ class ResponseHandler(Generic[T, U], ABC):
29
29
  @classmethod
30
30
  def parse(cls, response: Response) -> Union[T, U]:
31
31
  """Parse the response into the expected type"""
32
- if not response.ok:
32
+ if not response.ok or response.status_code != 200:
33
33
  cls._handle_error(response)
34
34
  return cls._parse_success(response)
35
35
 
@@ -98,6 +98,8 @@ class HttpClient:
98
98
  return response
99
99
 
100
100
  except Exception as e:
101
+ if isinstance(e, NoDatasetFound):
102
+ raise e
101
103
  if attempt == config.retry_attempts - 1:
102
104
  raise e
103
105
  time.sleep(config.retry_delay)
@@ -0,0 +1,66 @@
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
+ files: Optional[Dict[str, Any]] = {}
23
+ data: Optional[Dict[str, Any]] = {}
24
+ json: Optional[Dict[str, Any]] = {}
25
+ timeout: Optional[int] = None
26
+ retry_attempts: int = 3
27
+ retry_delay: float = 1.0
28
+
29
+
30
+ class ModelProvider(str, Enum):
31
+ OPENAI = "openai"
32
+ ANTHROPIC = "anthropic"
33
+ GOOGLE = "google"
34
+ AZURE = "azure"
35
+ AWS = "aws"
36
+ COHERE = "cohere"
37
+ FIREWORKS = "fireworks_ai"
38
+ ANYSCALE = "anyscale"
39
+ PERPLEXITY = "perplexity"
40
+ DEEPINFRA = "deepinfra"
41
+ OLLAMA = "ollama"
42
+ CLOUDFLARE = "cloudflare"
43
+ VOYAGE = "voyage"
44
+ DATABRICKS = "databricks"
45
+ TEXT_COMPLETION_OPENAI = "text-completion-openai"
46
+ TEXT_COMPLETION_CODESTRAL = "text-completion-codestral"
47
+ FIREWORKS_EMBEDDING = "fireworks_ai-embedding-models"
48
+ VERTEX_AI_TEXT = "vertex_ai-text-models"
49
+ VERTEX_AI_CHAT = "vertex_ai-chat-models"
50
+ VERTEX_AI_CODE_TEXT = "vertex_ai-code-text-models"
51
+ SAGEMAKER = "sagemaker"
52
+ BEDROCK = "bedrock"
53
+ TOGETHER_AI = "together_ai"
54
+ MISTRAL = "mistral"
55
+ DEEPSEEK = "deepseek"
56
+ CODESTRAL = "codestral"
57
+ GROQ = "groq"
58
+ CEREBRAS = "cerebras"
59
+ FRIENDLIAI = "friendliai"
60
+ AZURE_AI = "azure_ai"
61
+ HUGGINGFACE = "huggingface"
62
+
63
+
64
+ class ApiKey(BaseModel):
65
+ provider: Optional[ModelProvider] = None
66
+ key: Optional[str] = None