langchain-b12 0.1.0__tar.gz → 0.1.1__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.0
3
+ Version: 0.1.1
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
@@ -11,8 +11,6 @@ Description-Content-Type: text/markdown
11
11
 
12
12
  This repo hosts a collection of custom LangChain components.
13
13
 
14
- - ChatGenAI converts a sequence of LangChain messages to Google GenAI Content objects and vice versa.
15
-
16
14
  ## Installation
17
15
 
18
16
  To install this package, run
@@ -2,8 +2,6 @@
2
2
 
3
3
  This repo hosts a collection of custom LangChain components.
4
4
 
5
- - ChatGenAI converts a sequence of LangChain messages to Google GenAI Content objects and vice versa.
6
-
7
5
  ## Installation
8
6
 
9
7
  To install this package, run
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "langchain-b12"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "A reusable collection of tools and implementations for Langchain"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -145,13 +145,14 @@ class ChatGenAI(BaseChatModel):
145
145
  self, messages: list[BaseMessage]
146
146
  ) -> tuple[str | None, types.ContentListUnion]:
147
147
  contents = convert_messages_to_contents(messages)
148
- if isinstance(messages[-1], SystemMessage):
149
- system_instruction = messages[-1].content
150
- assert isinstance(
151
- system_instruction, str
152
- ), "System message content must be a string"
153
- else:
154
- system_instruction = None
148
+ system_message: SystemMessage | None = next(
149
+ (message for message in messages if isinstance(message, SystemMessage)),
150
+ None,
151
+ )
152
+ system_instruction = system_message.content if system_message else None
153
+ assert system_instruction is None or isinstance(
154
+ system_instruction, str
155
+ ), "System message content must be a string or None"
155
156
  return system_instruction, cast(types.ContentListUnion, contents)
156
157
 
157
158
  def get_num_tokens(self, text: str) -> int:
File without changes
File without changes
File without changes