llmir 0.0.3__tar.gz → 0.0.5__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: llmir
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Core message and tool IR for LLM pipelines
5
5
  Author: Mathis Siebert
6
6
  Requires-Python: >=3.11
@@ -1,4 +1,4 @@
1
- from .openai import to_openai, OpenAIMessage, OpenAIMessageToolResponse, OpenAIContent, OpenAITextContent, OpenAIImageURLContent
1
+ from .openai import to_openai, OpenAIMessage, OpenAIMessageToolResponse, OpenAIContent, OpenAITextContent, OpenAIImageURLContent, OpenAIImageURLURL, OpenAIToolCallContent, OpenAIToolCallFunction
2
2
 
3
3
  __all__ = [
4
4
  "to_openai",
@@ -7,4 +7,7 @@ __all__ = [
7
7
  "OpenAIContent",
8
8
  "OpenAITextContent",
9
9
  "OpenAIImageURLContent",
10
+ "OpenAIImageURLURL",
11
+ "OpenAIToolCallContent",
12
+ "OpenAIToolCallFunction",
10
13
  ]
@@ -1,20 +1,35 @@
1
1
  from typing import TypedDict, Literal, Union
2
2
 
3
- from ..messages import AIMessage, AIMessageToolResponse
4
- from ..chunks import AIChunk, AIChunkText, AIChunkImageURL, AIChunkFile
3
+ from ..messages import AIMessages, AIMessageToolResponse
4
+ from ..chunks import AIChunk, AIChunkText, AIChunkImageURL, AIChunkFile, AIChunkToolCall
5
5
  import base64
6
+ import json
6
7
 
7
8
 
8
9
  class OpenAITextContent(TypedDict):
9
10
  type: Literal["text"]
10
11
  text: str
11
12
 
13
+ class OpenAIImageURLURL(TypedDict):
14
+ url: str
12
15
 
13
16
  class OpenAIImageURLContent(TypedDict):
14
17
  type: Literal["image_url"]
15
- image_url: dict[str, str]
18
+ image_url: OpenAIImageURLURL
16
19
 
17
- OpenAIContent = Union[OpenAITextContent, OpenAIImageURLContent]
20
+
21
+ class OpenAIToolCallFunction(TypedDict):
22
+ name: str
23
+ arguments: str
24
+
25
+ class OpenAIToolCallContent(TypedDict):
26
+ id: str
27
+ type: Literal["function"]
28
+ function: OpenAIToolCallFunction
29
+
30
+
31
+
32
+ OpenAIContent = Union[OpenAITextContent, OpenAIImageURLContent, OpenAIToolCallContent]
18
33
 
19
34
 
20
35
  class OpenAIMessage(TypedDict):
@@ -26,7 +41,7 @@ class OpenAIMessageToolResponse(OpenAIMessage):
26
41
  name: str
27
42
 
28
43
 
29
- def to_openai(messages: list[AIMessage]) -> list[OpenAIMessage]:
44
+ def to_openai(messages: list[AIMessages]) -> list[OpenAIMessage]:
30
45
 
31
46
 
32
47
  result: list[OpenAIMessage] = []
@@ -77,7 +92,7 @@ def chunk_to_openai(chunk: AIChunk) -> OpenAIContent:
77
92
  "url": f"data:{chunk.mimetype};base64,{base64_data}",
78
93
  }
79
94
  )
80
- elif chunk.mimetype == ("text/plain"):
95
+ elif chunk.mimetype == "text/plain":
81
96
  text = chunk.bytes.decode(encoding="utf-8")
82
97
  return OpenAITextContent(
83
98
  type="text",
@@ -85,5 +100,14 @@ def chunk_to_openai(chunk: AIChunk) -> OpenAIContent:
85
100
  )
86
101
  else:
87
102
  raise ValueError(f"Unsupported file type for OpenAI: {chunk.mimetype}")
103
+ case AIChunkToolCall():
104
+ return OpenAIToolCallContent(
105
+ id=chunk.id,
106
+ type="function",
107
+ function=OpenAIToolCallFunction(
108
+ name=chunk.name,
109
+ arguments=json.dumps(chunk.arguments)
110
+ )
111
+ )
88
112
  case _:
89
113
  raise ValueError(f"Unsupported chunk type: {type(chunk)}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llmir
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Core message and tool IR for LLM pipelines
5
5
  Author: Mathis Siebert
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llmir"
3
- version = "0.0.3"
3
+ version = "0.0.5"
4
4
  description = "Core message and tool IR for LLM pipelines"
5
5
  authors = [{ name="Mathis Siebert" }]
6
6
  requires-python = ">=3.11"
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
File without changes