llumo 0.1.0__py3-none-any.whl

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.
llumo/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ from .client import LlumoClient
2
+ from .exceptions import LlumoAPIError
llumo/client.py ADDED
@@ -0,0 +1,76 @@
1
+ import requests
2
+ from .exceptions import LlumoAPIError
3
+
4
+ class LlumoClient:
5
+ """
6
+ A client to interact with Llumo API for evaluating AI-generated responses
7
+ """
8
+
9
+ base_url = "https://app.llumo.ai/api"
10
+
11
+ def __init__(self, api_key):
12
+ """
13
+ Initializes the LlumoClient with the given API key.
14
+
15
+ Parameters:
16
+ - api_key (str): The Llumo API key for authentication.
17
+ """
18
+ self.api_key = api_key
19
+
20
+
21
+ def EvaluateGrounded(self, outputText, groundTruthText, embeddingModelName="Google", metricsName="Cosine"):
22
+ """
23
+ Evaluates the groundedness of a response using a similarity metric.
24
+
25
+ Parameters:
26
+ - outputText (str): The generated output text to evaluate.
27
+ - groundTruthText (str): The reference ground truth text.
28
+ - embeddingModelName (str): Name of the embedding model to use. Default is "Google".
29
+ - metricsName (str): Similarity metric to apply (e.g., "Bleu"). Default is "Cosine".
30
+
31
+ Returns:
32
+ - dict: Contains statusCode, message, and evaluation data if successful.
33
+
34
+ Raises:
35
+ - LlumoAPIError for all specific error types.
36
+ """
37
+ url = f"{self.base_url}/external/grounded-external"
38
+
39
+ requestBody = {
40
+ "prompt": outputText,
41
+ "groundTruth": groundTruthText,
42
+ "embeddingModel": embeddingModelName,
43
+ "similarityMetric": metricsName,
44
+ }
45
+
46
+ headers = {
47
+ "Authorization": f"Bearer {self.api_key}",
48
+ "Content-Type": "application/json"
49
+ }
50
+
51
+ try:
52
+ res = requests.post(url=url, json=requestBody, headers=headers)
53
+
54
+ if res.status_code == 401:
55
+ raise LlumoAPIError.InvalidApiKey()
56
+
57
+ res.raise_for_status()
58
+ result = res.json()
59
+
60
+ if 'data' not in result:
61
+ raise LlumoAPIError.InvalidApiResponse()
62
+
63
+ return {
64
+ "statusCode": result['data'].get('statusCode'),
65
+ "message": result['data'].get('message'),
66
+ "analytics": result['data']
67
+ }
68
+
69
+ except requests.exceptions.HTTPError as e:
70
+ raise LlumoAPIError.RequestFailed(str(e))
71
+ except ValueError:
72
+ raise LlumoAPIError.InvalidJsonResponse()
73
+ except Exception as e:
74
+ raise LlumoAPIError.UnexpectedError(str(e))
75
+
76
+
llumo/exceptions.py ADDED
@@ -0,0 +1,30 @@
1
+ class LlumoAPIError(Exception):
2
+ """Base class for all Llumo SDK-related errors."""
3
+
4
+ def __init__(self, message):
5
+ self.message = message
6
+ super().__init__(self.message)
7
+
8
+ @staticmethod
9
+ def InvalidApiKey():
10
+ return LlumoAPIError("The provided API key is invalid or unauthorized")
11
+
12
+ @staticmethod
13
+ def InvalidApiResponse():
14
+ return LlumoAPIError("Invalid or UnexpectedError response from the API")
15
+
16
+ @staticmethod
17
+ def RequestFailed(detail="The request to the API failed"):
18
+ return LlumoAPIError(f"Request to the API failed: {detail}")
19
+
20
+ @staticmethod
21
+ def InvalidJsonResponse():
22
+ return LlumoAPIError("The API response is not in valid JSON format")
23
+
24
+ @staticmethod
25
+ def UnexpectedError(detail="An UnexpectedError error occurred"):
26
+ return LlumoAPIError(f"UnexpectedError error: {detail}")
27
+
28
+ @staticmethod
29
+ def EvalError(detail="Some error occured while processing"):
30
+ return LlumoAPIError(f"error: {detail}")
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: llumo
3
+ Version: 0.1.0
4
+ Summary: Python SDK for interacting with the Llumo ai API.
5
+ Home-page: https://www.llumo.ai/
6
+ Author: Llumo
7
+ Author-email: product@llumo.ai
8
+ License: Proprietary
9
+ Requires-Python: >=3.7
10
+ License-File: LICENSE
11
+ Requires-Dist: requests>=2.25.1
12
+ Requires-Dist: setuptools>=58.1.0
13
+ Requires-Dist: twine>=6.1.0
14
+ Requires-Dist: wheel>=0.45.1
15
+ Requires-Dist: build>=1.2.2.post1
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: home-page
19
+ Dynamic: license
20
+ Dynamic: license-file
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
@@ -0,0 +1,8 @@
1
+ llumo/__init__.py,sha256=WT0Y6g-MtJqIIMpH1AoWQfL-XraaQDtMbjApjBHRPqk,72
2
+ llumo/client.py,sha256=w1rd6uT4F-iwHty8xDqXy3Q5BM_9u1jgdSZvy032LQE,2468
3
+ llumo/exceptions.py,sha256=BQcLqfViMxPklGIPJnH1tfajdytvuGpd5Sidv4ta6h0,1039
4
+ llumo-0.1.0.dist-info/licenses/LICENSE,sha256=vMiqSi3KpDHq3RFxKiqdh10ZUF3PjE3nnntANU-HEu4,186
5
+ llumo-0.1.0.dist-info/METADATA,sha256=OcJtsjap9U3XwzxjR03V4VzITQbPkOO_JgCcSgg0qo0,593
6
+ llumo-0.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
7
+ llumo-0.1.0.dist-info/top_level.txt,sha256=d5zUTMI99llPtLRB8rtSrqELm_bOqX-bNC5IcwlDk88,6
8
+ llumo-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,4 @@
1
+ Copyright (c) 2025 Llumo AI
2
+
3
+ All rights reserved. This software is proprietary and confidential.
4
+ Unauthorized copying, distribution, or use of this software is strictly prohibited.
@@ -0,0 +1 @@
1
+ llumo