posthoganalytics 6.3.0__py3-none-any.whl → 6.3.1__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.
- posthoganalytics/ai/langchain/callbacks.py +29 -1
- posthoganalytics/version.py +1 -1
- {posthoganalytics-6.3.0.dist-info → posthoganalytics-6.3.1.dist-info}/METADATA +1 -1
- {posthoganalytics-6.3.0.dist-info → posthoganalytics-6.3.1.dist-info}/RECORD +7 -7
- {posthoganalytics-6.3.0.dist-info → posthoganalytics-6.3.1.dist-info}/WHEEL +0 -0
- {posthoganalytics-6.3.0.dist-info → posthoganalytics-6.3.1.dist-info}/licenses/LICENSE +0 -0
- {posthoganalytics-6.3.0.dist-info → posthoganalytics-6.3.1.dist-info}/top_level.txt +0 -0
|
@@ -5,6 +5,7 @@ except ImportError:
|
|
|
5
5
|
"Please install LangChain to use this feature: 'pip install langchain'"
|
|
6
6
|
)
|
|
7
7
|
|
|
8
|
+
import json
|
|
8
9
|
import logging
|
|
9
10
|
import time
|
|
10
11
|
from dataclasses import dataclass
|
|
@@ -29,6 +30,7 @@ from langchain_core.messages import (
|
|
|
29
30
|
HumanMessage,
|
|
30
31
|
SystemMessage,
|
|
31
32
|
ToolMessage,
|
|
33
|
+
ToolCall,
|
|
32
34
|
)
|
|
33
35
|
from langchain_core.outputs import ChatGeneration, LLMResult
|
|
34
36
|
from pydantic import BaseModel
|
|
@@ -629,12 +631,35 @@ def _extract_raw_esponse(last_response):
|
|
|
629
631
|
return ""
|
|
630
632
|
|
|
631
633
|
|
|
632
|
-
def
|
|
634
|
+
def _convert_lc_tool_calls_to_oai(
|
|
635
|
+
tool_calls: list[ToolCall],
|
|
636
|
+
) -> list[dict[str, Any]]:
|
|
637
|
+
try:
|
|
638
|
+
return [
|
|
639
|
+
{
|
|
640
|
+
"type": "function",
|
|
641
|
+
"id": tool_call["id"],
|
|
642
|
+
"function": {
|
|
643
|
+
"name": tool_call["name"],
|
|
644
|
+
"arguments": json.dumps(tool_call["args"]),
|
|
645
|
+
},
|
|
646
|
+
}
|
|
647
|
+
for tool_call in tool_calls
|
|
648
|
+
]
|
|
649
|
+
except KeyError:
|
|
650
|
+
return tool_calls
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
def _convert_message_to_dict(message: BaseMessage) -> dict[str, Any]:
|
|
633
654
|
# assistant message
|
|
634
655
|
if isinstance(message, HumanMessage):
|
|
635
656
|
message_dict = {"role": "user", "content": message.content}
|
|
636
657
|
elif isinstance(message, AIMessage):
|
|
637
658
|
message_dict = {"role": "assistant", "content": message.content}
|
|
659
|
+
if message.tool_calls:
|
|
660
|
+
message_dict["tool_calls"] = _convert_lc_tool_calls_to_oai(
|
|
661
|
+
message.tool_calls
|
|
662
|
+
)
|
|
638
663
|
elif isinstance(message, SystemMessage):
|
|
639
664
|
message_dict = {"role": "system", "content": message.content}
|
|
640
665
|
elif isinstance(message, ToolMessage):
|
|
@@ -647,6 +672,9 @@ def _convert_message_to_dict(message: BaseMessage) -> Dict[str, Any]:
|
|
|
647
672
|
if message.additional_kwargs:
|
|
648
673
|
message_dict.update(message.additional_kwargs)
|
|
649
674
|
|
|
675
|
+
if "content" in message_dict and not message_dict["content"]:
|
|
676
|
+
message_dict["content"] = ""
|
|
677
|
+
|
|
650
678
|
return message_dict
|
|
651
679
|
|
|
652
680
|
|
posthoganalytics/version.py
CHANGED
|
@@ -11,7 +11,7 @@ posthoganalytics/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
11
11
|
posthoganalytics/request.py,sha256=TaeySYpcvHMf5Ftf5KqqlO0VPJpirKBCRrThlS04Kew,6124
|
|
12
12
|
posthoganalytics/types.py,sha256=2rwhiZd9lvs37MiXEBADVdMKvcCvFXfAMgIUJ8KNTBs,10005
|
|
13
13
|
posthoganalytics/utils.py,sha256=-0w-OLcCaoldkbBebPzQyBzLJSo9G9yBOg8NDVz7La8,16088
|
|
14
|
-
posthoganalytics/version.py,sha256=
|
|
14
|
+
posthoganalytics/version.py,sha256=QZXrqI6X21wlR2zfls818OHusGGPo_YZf4UfdcGv4ds,87
|
|
15
15
|
posthoganalytics/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
posthoganalytics/ai/utils.py,sha256=5-2XfmetCs0v9otBoux7-IEG933wAnKLSGS6oYLqCkw,19529
|
|
17
17
|
posthoganalytics/ai/anthropic/__init__.py,sha256=fFhDOiRzTXzGQlgnrRDL-4yKC8EYIl8NW4a2QNR6xRU,368
|
|
@@ -21,7 +21,7 @@ posthoganalytics/ai/anthropic/anthropic_providers.py,sha256=y1_qc8Lbip-YDmpimPGg
|
|
|
21
21
|
posthoganalytics/ai/gemini/__init__.py,sha256=bMNBnJ6NO_PCQCwmxKIiw4adFuEQ06hFFBALt-aDW-0,174
|
|
22
22
|
posthoganalytics/ai/gemini/gemini.py,sha256=oi7VIPJLMEHPqRQwvAGwLjkaF0RZhvloCqOJgsQrmJ8,13285
|
|
23
23
|
posthoganalytics/ai/langchain/__init__.py,sha256=9CqAwLynTGj3ASAR80C3PmdTdrYGmu99tz0JL-HPFgI,70
|
|
24
|
-
posthoganalytics/ai/langchain/callbacks.py,sha256=
|
|
24
|
+
posthoganalytics/ai/langchain/callbacks.py,sha256=9WP09msvuq1dWFVsIlDINn1QL_QdX7yJ8foI7uU7FmQ,29519
|
|
25
25
|
posthoganalytics/ai/openai/__init__.py,sha256=_flZxkyaDZme9hxJsY31sMlq4nP1dtc75HmNgj-21Kg,197
|
|
26
26
|
posthoganalytics/ai/openai/openai.py,sha256=6bC3OxH9TP7EFkCGQRfxfcormVTAwLP4Wfj3ID3RwEc,23431
|
|
27
27
|
posthoganalytics/ai/openai/openai_async.py,sha256=0gEhTr-ePiOhS8h1WznQDSz_lJm1aferk5K1ZAMo-K0,23838
|
|
@@ -42,8 +42,8 @@ posthoganalytics/test/test_request.py,sha256=Zc0VbkjpVmj8mKokQm9rzdgTr0b1U44vvMY
|
|
|
42
42
|
posthoganalytics/test/test_size_limited_dict.py,sha256=-5IQjIEr_-Dql24M0HusdR_XroOMrtgiT0v6ZQCRvzo,774
|
|
43
43
|
posthoganalytics/test/test_types.py,sha256=bRPHdwVpP7hu7emsplU8UVyzSQptv6PaG5lAoOD_BtM,7595
|
|
44
44
|
posthoganalytics/test/test_utils.py,sha256=sqUTbfweVcxxFRd3WDMFXqPMyU6DvzOBeAOc68Py9aw,9620
|
|
45
|
-
posthoganalytics-6.3.
|
|
46
|
-
posthoganalytics-6.3.
|
|
47
|
-
posthoganalytics-6.3.
|
|
48
|
-
posthoganalytics-6.3.
|
|
49
|
-
posthoganalytics-6.3.
|
|
45
|
+
posthoganalytics-6.3.1.dist-info/licenses/LICENSE,sha256=wGf9JBotDkSygFj43m49oiKlFnpMnn97keiZKF-40vE,2450
|
|
46
|
+
posthoganalytics-6.3.1.dist-info/METADATA,sha256=rfwZmeIdtNRF30u2_F5RSi_SCm4ttMQu5xzs34JoN8c,6024
|
|
47
|
+
posthoganalytics-6.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
48
|
+
posthoganalytics-6.3.1.dist-info/top_level.txt,sha256=8QsNIqIkBh1p2TXvKp0Em9ZLZKwe3uIqCETyW4s1GOE,17
|
|
49
|
+
posthoganalytics-6.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|