osmosis-ai 0.1.6__py3-none-any.whl → 0.1.7__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.

Potentially problematic release.


This version of osmosis-ai might be problematic. Click here for more details.

osmosis_ai/consts.py CHANGED
@@ -2,15 +2,16 @@ from enum import Enum
2
2
 
3
3
  # Extract package metadata
4
4
  package_name = "osmosis-ai"
5
- package_version = "0.1.6"
5
+ package_version = "0.1.7"
6
6
 
7
7
  indent = 2 # Number of spaces to use for indentation in pretty print
8
- osmosis_api_url = "https://ftgrv77m9f.execute-api.us-west-2.amazonaws.com/prod"
8
+ osmosis_api_url = "https://osmosis.gulp.dev"
9
9
 
10
10
  DEFAULT_LOG_DESTINATION = "none" # "none" or "stdout" or "stderr" or "file"
11
11
 
12
+
12
13
  class LogDestination(Enum):
13
14
  NONE = "none"
14
15
  STDOUT = "stdout"
15
16
  STDERR = "stderr"
16
- FILE = "file"
17
+ FILE = "file"
osmosis_ai/logger.py CHANGED
@@ -8,7 +8,7 @@ import os
8
8
  from .consts import LogDestination, DEFAULT_LOG_DESTINATION
9
9
 
10
10
  # Create logger
11
- logger = logging.getLogger('osmosis_ai')
11
+ logger = logging.getLogger("osmosis_ai")
12
12
  logger.setLevel(logging.INFO)
13
13
 
14
14
  # Default configuration - no logging
@@ -18,6 +18,7 @@ logger.propagate = False
18
18
  log_destination = DEFAULT_LOG_DESTINATION
19
19
  logger.log_destination = log_destination
20
20
 
21
+
21
22
  def set_log_destination(destination: LogDestination) -> None:
22
23
  """
23
24
  Set the log destination for the logger
@@ -26,6 +27,7 @@ def set_log_destination(destination: LogDestination) -> None:
26
27
  log_destination = destination
27
28
  logger.log_destination = destination
28
29
 
30
+
29
31
  def configure_logger() -> None:
30
32
  """
31
33
  Configure the logger based on the log_destination setting in consts.py
@@ -33,7 +35,7 @@ def configure_logger() -> None:
33
35
  # Remove any existing handlers
34
36
  for handler in logger.handlers[:]:
35
37
  logger.removeHandler(handler)
36
-
38
+
37
39
  # Configure based on log_destination
38
40
  if log_destination == "none":
39
41
  # No logging
@@ -54,18 +56,22 @@ def configure_logger() -> None:
54
56
  handler = logging.StreamHandler(sys.stderr)
55
57
  logger.addHandler(handler)
56
58
  logger.warning(f"Invalid log_destination: {log_destination}, using stderr")
57
-
59
+
58
60
  # Set formatter
59
- formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
61
+ formatter = logging.Formatter(
62
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
63
+ )
60
64
  for handler in logger.handlers:
61
65
  handler.setFormatter(formatter)
62
66
 
67
+
63
68
  # Initialize the logger on module import
64
69
  configure_logger()
65
70
 
71
+
66
72
  # Function to force reconfiguration if log_destination is changed
67
73
  def reconfigure_logger() -> None:
68
74
  """
69
75
  Reconfigure the logger, should be called if log_destination changes
70
76
  """
71
- configure_logger()
77
+ configure_logger()
osmosis_ai/utils.py CHANGED
@@ -6,8 +6,10 @@ import json
6
6
  from datetime import datetime, timezone
7
7
  from typing import Any, Dict
8
8
  import xxhash
9
+
9
10
  # Import constants
10
11
  from .consts import osmosis_api_url
12
+
11
13
  # Import logger
12
14
  from .logger import logger
13
15
 
@@ -16,10 +18,11 @@ enabled = True
16
18
  osmosis_api_key = None # Will be set by init()
17
19
  _initialized = False
18
20
 
21
+
19
22
  def init(api_key: str) -> None:
20
23
  """
21
24
  Initialize osmosiswith the OSMOSIS API key.
22
-
25
+
23
26
  Args:
24
27
  api_key: The OSMOSIS API key for logging LLM usage
25
28
  """
@@ -27,18 +30,23 @@ def init(api_key: str) -> None:
27
30
  osmosis_api_key = api_key
28
31
  _initialized = True
29
32
 
33
+
30
34
  def disable_osmosis() -> None:
31
35
  global enabled
32
36
  enabled = False
33
37
 
38
+
34
39
  def enable_osmosis() -> None:
35
40
  global enabled
36
41
  enabled = True
37
42
 
38
- def send_to_osmosis(query: Dict[str, Any], response: Dict[str, Any], status: int = 200) -> None:
43
+
44
+ def send_to_osmosis(
45
+ query: Dict[str, Any], response: Dict[str, Any], status: int = 200
46
+ ) -> None:
39
47
  """
40
48
  Send query and response data to the OSMOSIS API using AWS Firehose.
41
-
49
+
42
50
  Args:
43
51
  query: The query/request data
44
52
  response: The response data
@@ -54,35 +62,36 @@ def send_to_osmosis(query: Dict[str, Any], response: Dict[str, Any], status: int
54
62
  try:
55
63
  # Import requests only when needed
56
64
  import requests
57
-
65
+
58
66
  # Create headers
59
- headers = {
60
- "Content-Type": "application/json",
61
- "x-api-key": osmosis_api_key
62
- }
63
-
67
+ headers = {"Content-Type": "application/json", "x-api-key": osmosis_api_key}
68
+
64
69
  # Prepare main data payload
65
70
  data = {
66
- "owner": xxhash.xxh32(osmosis_api_key.encode('utf-8')).hexdigest(),
71
+ "owner": xxhash.xxh32(osmosis_api_key.encode("utf-8")).hexdigest(),
67
72
  "date": int(datetime.now(timezone.utc).timestamp()),
68
73
  "query": query,
69
74
  "response": response,
70
- "status": status
75
+ "status": status,
71
76
  }
72
77
 
73
78
  logger.info(f"Sending data to OSMOSIS API: {data}")
74
-
79
+
75
80
  # Send main data payload
76
81
  response_data = requests.post(
77
- f"{osmosis_api_url}/data",
82
+ f"{osmosis_api_url}/ingest",
78
83
  headers=headers,
79
- data=json.dumps(data).replace('\n', '') + '\n'
84
+ data=json.dumps(data).replace("\n", "") + "\n",
80
85
  )
81
-
86
+
82
87
  if response_data.status_code != 200:
83
- logger.warning(f"OSMOSIS API returned status {response_data.status_code} for data")
84
-
88
+ logger.warning(
89
+ f"OSMOSIS API returned status {response_data.status_code} for data with error: {response_data.text}"
90
+ )
91
+
85
92
  except ImportError:
86
- logger.warning("Requests library not installed. Please install it with 'pip install requests'.")
93
+ logger.warning(
94
+ "Requests library not installed. Please install it with 'pip install requests'."
95
+ )
87
96
  except Exception as e:
88
- logger.warning(f"Failed to send data to OSMOSIS API: {str(e)}")
97
+ logger.warning(f"Failed to send data to OSMOSIS API: {str(e)}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osmosis-ai
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Monkey patches LLM client libraries to print all prompts and responses
5
5
  Author-email: Gulp AI <jake@gulp.ai>
6
6
  License: MIT License
@@ -0,0 +1,15 @@
1
+ osmosis_ai/__init__.py,sha256=esOnyFqlu7-AKuxTV5fkLVb34-kvCReMEDFkFpxBH7M,4374
2
+ osmosis_ai/consts.py,sha256=1HavvPFM9nJCDqy1RK7VH_g9MbAgXNyBqN8Rt3FAeDE,408
3
+ osmosis_ai/logger.py,sha256=J2Yw_QMGqXySzJlj_QQqHLs52S1oKYXoELnU66YCAuI,2170
4
+ osmosis_ai/utils.py,sha256=pJDJTO1ov0Nyyj6UMbPGZIAPyoF-wY9QM3hYoxtIuo4,2490
5
+ osmosis_ai/adapters/__init__.py,sha256=MlS3aGG8AQqQUQlV196sPdChTvfenK6ZdSaP0Tsr8eQ,262
6
+ osmosis_ai/adapters/anthropic.py,sha256=Q9pb_AxgaSTyjNYkGGZL5mslyVnfTbGI04WbxLDhvLA,22959
7
+ osmosis_ai/adapters/langchain.py,sha256=oVIIRmpdadgozoysJBxoJsTVwJcjrtoA63SjRchXr9E,27673
8
+ osmosis_ai/adapters/langchain_anthropic.py,sha256=qWtcNAQ3tQpJfTttV9y5mMCkPujuRodoFkaoYx9pOW8,14557
9
+ osmosis_ai/adapters/langchain_openai.py,sha256=8sq4vGSqm96-UjeeiW0ZGWMOUXiv85A1BLGwaeboBF8,24815
10
+ osmosis_ai/adapters/openai.py,sha256=B-dNQvA8XcmX4kB5ZZGf4EoS_VAVZPo3aTfem_xe-8I,39437
11
+ osmosis_ai-0.1.7.dist-info/licenses/LICENSE,sha256=WLvxAm2-fPuT8qECE6ejD8ezG9btIanJl7zysXvtQgM,1064
12
+ osmosis_ai-0.1.7.dist-info/METADATA,sha256=wVZ0LQAJIfGKinOoQrgCUKwCOf667InqQxOYIWBBv_Q,9255
13
+ osmosis_ai-0.1.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
14
+ osmosis_ai-0.1.7.dist-info/top_level.txt,sha256=UPNRTKIBSrxsJVNxwXnLCqSoBS4bAiL_3jMtjvf5zEY,11
15
+ osmosis_ai-0.1.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.0.2)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,15 +0,0 @@
1
- osmosis_ai/__init__.py,sha256=nQJwkT7efmsSQ0ydygcH1OUW8y2rKxHCnwKD-Br51Co,4266
2
- osmosis_ai/consts.py,sha256=EqrQmFe6kXMHgK5J2xdtzUFnuRVaV3KDDsbQATQphwo,441
3
- osmosis_ai/logger.py,sha256=eG-GJoUo7bcrFkLOS0HGzCSbshaZRoowjSI0ZsUZH1U,2160
4
- osmosis_ai/utils.py,sha256=_CLtNAxli8bTzIzDY86MWefpJpFoAdta9RHC2DnEpP0,2470
5
- osmosis_ai/adapters/__init__.py,sha256=IOaShk3HYVdKYRd6aPLu1Shvt_LeUjYaCrtOE3BIrJw,262
6
- osmosis_ai/adapters/anthropic.py,sha256=GzTw03L9zth7GjCKEbNgEgDQQApwohmm6MpWbsa52CE,21796
7
- osmosis_ai/adapters/langchain.py,sha256=s_T7LM-o8VR3UMGeudj-XSjC_jDQvAHHAWdgTUJcOKA,26397
8
- osmosis_ai/adapters/langchain_anthropic.py,sha256=VME8PJMjjtikL00JiFaH7VWtySAWJ9eYez2gFyhGN8U,13350
9
- osmosis_ai/adapters/langchain_openai.py,sha256=1Jo3X5Yv14SztvidLZM4usdnF8lcjxhVhECO85hgWl4,22908
10
- osmosis_ai/adapters/openai.py,sha256=8pVtVkD5rUGI5tpNmGIYVBTOyPmheQTknmGHNDjrYd8,38620
11
- osmosis_ai-0.1.6.dist-info/licenses/LICENSE,sha256=WLvxAm2-fPuT8qECE6ejD8ezG9btIanJl7zysXvtQgM,1064
12
- osmosis_ai-0.1.6.dist-info/METADATA,sha256=Yl84ihmD7UbC7lS0atAC7lIriauKyXXKq0DNZ0oxVK8,9255
13
- osmosis_ai-0.1.6.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
14
- osmosis_ai-0.1.6.dist-info/top_level.txt,sha256=UPNRTKIBSrxsJVNxwXnLCqSoBS4bAiL_3jMtjvf5zEY,11
15
- osmosis_ai-0.1.6.dist-info/RECORD,,