langchain-b12 0.1.1__tar.gz → 0.1.2__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.
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/PKG-INFO +1 -1
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/pyproject.toml +1 -1
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/src/langchain_b12/genai/genai_utils.py +66 -15
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/uv.lock +7 -7
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/.gitignore +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/.python-version +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/.vscode/extensions.json +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/Makefile +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/README.md +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/src/langchain_b12/__init__.py +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/src/langchain_b12/genai/embeddings.py +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/src/langchain_b12/genai/genai.py +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/src/langchain_b12/py.typed +0 -0
- {langchain_b12-0.1.1 → langchain_b12-0.1.2}/tests/test_genai.py +0 -0
|
@@ -24,22 +24,37 @@ def multi_content_to_part(
|
|
|
24
24
|
Args:
|
|
25
25
|
contents: A sequence of dictionaries representing content. Examples:
|
|
26
26
|
[
|
|
27
|
-
{
|
|
27
|
+
{ # Text content
|
|
28
28
|
"type": "text",
|
|
29
29
|
"text": "This is a text message"
|
|
30
30
|
},
|
|
31
|
-
{
|
|
31
|
+
{ # Image content from base64 encoded string with OpenAI format
|
|
32
32
|
"type": "image_url",
|
|
33
33
|
"image_url": {
|
|
34
34
|
"url": f"data:{mime_type};base64,{encoded_artifact}"
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
-
{
|
|
37
|
+
{ # Image content fro base64 encoded string with LangChain format
|
|
38
|
+
"type": "image",
|
|
39
|
+
"source_type": "base64",
|
|
40
|
+
"data": "<base64 string>",
|
|
41
|
+
"mime_type": "image/jpeg",
|
|
42
|
+
},
|
|
43
|
+
{ # Image content from URL
|
|
44
|
+
"type": "image",
|
|
45
|
+
"source_type": "url",
|
|
46
|
+
"url": "https://...",
|
|
47
|
+
},
|
|
48
|
+
{ # File content from base64 encoded string
|
|
49
|
+
"type": "file",
|
|
50
|
+
"source_type": "base64",
|
|
51
|
+
"mime_type": "application/pdf",
|
|
52
|
+
"data": "<base64 data string>",
|
|
53
|
+
},
|
|
54
|
+
{ # File content from URL
|
|
38
55
|
"type": "file",
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"mime_type": mime_type,
|
|
42
|
-
}
|
|
56
|
+
"source_type": "url",
|
|
57
|
+
"url": "https://...",
|
|
43
58
|
}
|
|
44
59
|
]
|
|
45
60
|
"""
|
|
@@ -60,15 +75,51 @@ def multi_content_to_part(
|
|
|
60
75
|
mime_type = header.split(":", 1)[1].split(";", 1)[0]
|
|
61
76
|
data = base64.b64decode(encoded_data)
|
|
62
77
|
parts.append(types.Part.from_bytes(data=data, mime_type=mime_type))
|
|
78
|
+
elif content["type"] == "image":
|
|
79
|
+
if "data" in content:
|
|
80
|
+
assert isinstance(content["data"], str), "Expected str data"
|
|
81
|
+
assert "mime_type" in content, "Expected 'mime_type' in content"
|
|
82
|
+
assert isinstance(content["mime_type"], str), "Expected str mime_type"
|
|
83
|
+
data = base64.b64decode(content["data"])
|
|
84
|
+
parts.append(
|
|
85
|
+
types.Part.from_bytes(data=data, mime_type=content["mime_type"])
|
|
86
|
+
)
|
|
87
|
+
elif "url" in content:
|
|
88
|
+
assert isinstance(content["url"], str), "Expected str url"
|
|
89
|
+
mime_type = content.get("mime_type", None)
|
|
90
|
+
assert mime_type is None or isinstance(
|
|
91
|
+
mime_type, str
|
|
92
|
+
), "Expected str mime_type"
|
|
93
|
+
parts.append(
|
|
94
|
+
types.Part.from_uri(file_uri=content["url"], mime_type=mime_type)
|
|
95
|
+
)
|
|
96
|
+
else:
|
|
97
|
+
raise ValueError(
|
|
98
|
+
"Expected either 'data' or 'url' in content for image type"
|
|
99
|
+
)
|
|
63
100
|
elif content["type"] == "file":
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
101
|
+
if "data" in content:
|
|
102
|
+
assert isinstance(content["data"], str), "Expected str data"
|
|
103
|
+
assert "mime_type" in content, "Expected 'mime_type' in content"
|
|
104
|
+
assert isinstance(content["mime_type"], str), "Expected str mime_type"
|
|
105
|
+
data = base64.b64decode(content["data"])
|
|
106
|
+
parts.append(
|
|
107
|
+
types.Part.from_bytes(data=data, mime_type=content["mime_type"])
|
|
108
|
+
)
|
|
109
|
+
elif "url" in content:
|
|
110
|
+
assert isinstance(content["url"], str), "Expected str url"
|
|
111
|
+
assert content["url"], "File URI is required"
|
|
112
|
+
mime_type = content.get("mime_type", None)
|
|
113
|
+
assert mime_type is None or isinstance(
|
|
114
|
+
mime_type, str
|
|
115
|
+
), "Expected str mime_type"
|
|
116
|
+
parts.append(
|
|
117
|
+
types.Part.from_uri(file_uri=content["url"], mime_type=mime_type)
|
|
118
|
+
)
|
|
119
|
+
else:
|
|
120
|
+
raise ValueError(
|
|
121
|
+
"Expected either 'data' or 'url' in content for file type"
|
|
122
|
+
)
|
|
72
123
|
else:
|
|
73
124
|
raise ValueError(f"Unknown content type: {content['type']}")
|
|
74
125
|
return parts
|
|
@@ -259,7 +259,7 @@ wheels = [
|
|
|
259
259
|
|
|
260
260
|
[[package]]
|
|
261
261
|
name = "langchain-b12"
|
|
262
|
-
version = "0.1.
|
|
262
|
+
version = "0.1.2"
|
|
263
263
|
source = { editable = "." }
|
|
264
264
|
dependencies = [
|
|
265
265
|
{ name = "langchain-core" },
|
|
@@ -282,7 +282,7 @@ google = [{ name = "google-genai", specifier = ">=1.16.1" }]
|
|
|
282
282
|
|
|
283
283
|
[[package]]
|
|
284
284
|
name = "langchain-core"
|
|
285
|
-
version = "0.3.
|
|
285
|
+
version = "0.3.61"
|
|
286
286
|
source = { registry = "https://pypi.org/simple" }
|
|
287
287
|
dependencies = [
|
|
288
288
|
{ name = "jsonpatch" },
|
|
@@ -293,9 +293,9 @@ dependencies = [
|
|
|
293
293
|
{ name = "tenacity" },
|
|
294
294
|
{ name = "typing-extensions" },
|
|
295
295
|
]
|
|
296
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
296
|
+
sdist = { url = "https://files.pythonhosted.org/packages/fd/4d/9a0ce842ce01f85e9aa707412108096a029668c88b18c7a446aa45fdf2b4/langchain_core-0.3.61.tar.gz", hash = "sha256:67ba08d4cf58616050047ef3a07887a72607fea9b6b4522dff9e7579a1adbe75", size = 558241 }
|
|
297
297
|
wheels = [
|
|
298
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
298
|
+
{ url = "https://files.pythonhosted.org/packages/0b/81/db64e50399e05100bbb8c4e76a6c21d57e32d637110149a4c51d77954012/langchain_core-0.3.61-py3-none-any.whl", hash = "sha256:62cddbda7fb6085b6096bb4f3ad69642ebb0585bde7b210edc61dd0af33f2ea4", size = 438345 },
|
|
299
299
|
]
|
|
300
300
|
|
|
301
301
|
[[package]]
|
|
@@ -419,7 +419,7 @@ wheels = [
|
|
|
419
419
|
|
|
420
420
|
[[package]]
|
|
421
421
|
name = "pydantic"
|
|
422
|
-
version = "2.11.
|
|
422
|
+
version = "2.11.5"
|
|
423
423
|
source = { registry = "https://pypi.org/simple" }
|
|
424
424
|
dependencies = [
|
|
425
425
|
{ name = "annotated-types" },
|
|
@@ -427,9 +427,9 @@ dependencies = [
|
|
|
427
427
|
{ name = "typing-extensions" },
|
|
428
428
|
{ name = "typing-inspection" },
|
|
429
429
|
]
|
|
430
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
430
|
+
sdist = { url = "https://files.pythonhosted.org/packages/f0/86/8ce9040065e8f924d642c58e4a344e33163a07f6b57f836d0d734e0ad3fb/pydantic-2.11.5.tar.gz", hash = "sha256:7f853db3d0ce78ce8bbb148c401c2cdd6431b3473c0cdff2755c7690952a7b7a", size = 787102 }
|
|
431
431
|
wheels = [
|
|
432
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
432
|
+
{ url = "https://files.pythonhosted.org/packages/b5/69/831ed22b38ff9b4b64b66569f0e5b7b97cf3638346eb95a2147fdb49ad5f/pydantic-2.11.5-py3-none-any.whl", hash = "sha256:f9c26ba06f9747749ca1e5c94d6a85cb84254577553c8785576fd38fa64dc0f7", size = 444229 },
|
|
433
433
|
]
|
|
434
434
|
|
|
435
435
|
[[package]]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|