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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langchain-b12
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: A reusable collection of tools and implementations for Langchain
5
5
  Author-email: Vincent Min <vincent.min@b12-consulting.com>
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "langchain-b12"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "A reusable collection of tools and implementations for Langchain"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -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
- "file": {
40
- "uri": f"gs://{bucket_name}/{file_name}",
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
- assert "file" in content, "Expected 'file' in content"
65
- file = content["file"]
66
- assert isinstance(file, dict), "Expected dict file"
67
- assert "uri" in file, "Expected 'uri' in content['file']"
68
- assert "mime_type" in file, "Expected 'mime_type' in content['file']"
69
- parts.append(
70
- types.Part.from_uri(file_uri=file["uri"], mime_type=file["mime_type"])
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.0"
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.60"
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/5b/75/95129aaada92980a002a31e002610a80af3c8967ae7884710372e89cdde0/langchain_core-0.3.60.tar.gz", hash = "sha256:63dd1bdf7939816115399522661ca85a2f3686a61440f2f46ebd86d1b028595b", size = 557456 }
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/2d/bc/344f5b11fdfe0e27f7064d2e829921a791461dc32e5ed285fe6325518c26/langchain_core-0.3.60-py3-none-any.whl", hash = "sha256:2ccdf06b12e699b1b0962bc02837056c075b4981c3d13f82a4d4c30bb22ea3dc", size = 437890 },
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.4"
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/77/ab/5250d56ad03884ab5efd07f734203943c8a8ab40d551e208af81d0257bf2/pydantic-2.11.4.tar.gz", hash = "sha256:32738d19d63a226a52eed76645a98ee07c1f410ee41d93b4afbfa85ed8111c2d", size = 786540 }
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/e7/12/46b65f3534d099349e38ef6ec98b1a5a81f42536d17e0ba382c28c67ba67/pydantic-2.11.4-py3-none-any.whl", hash = "sha256:d9615eaa9ac5a063471da949c8fc16376a84afb5024688b3ff885693506764eb", size = 443900 },
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