llmir 0.0.4__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.
- {llmir-0.0.4 → llmir-0.0.5}/PKG-INFO +1 -1
- {llmir-0.0.4 → llmir-0.0.5}/llmir/adapter/__init__.py +4 -1
- {llmir-0.0.4 → llmir-0.0.5}/llmir/adapter/openai.py +28 -4
- {llmir-0.0.4 → llmir-0.0.5}/llmir.egg-info/PKG-INFO +1 -1
- {llmir-0.0.4 → llmir-0.0.5}/pyproject.toml +1 -1
- {llmir-0.0.4 → llmir-0.0.5}/README.md +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir/__init__.py +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir/chunks.py +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir/messages.py +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir/py.typed +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir/rich_repr.py +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir/roles.py +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir/tools.py +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir.egg-info/SOURCES.txt +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir.egg-info/dependency_links.txt +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir.egg-info/requires.txt +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/llmir.egg-info/top_level.txt +0 -0
- {llmir-0.0.4 → llmir-0.0.5}/setup.cfg +0 -0
|
@@ -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
3
|
from ..messages import AIMessages, AIMessageToolResponse
|
|
4
|
-
from ..chunks import AIChunk, AIChunkText, AIChunkImageURL, AIChunkFile
|
|
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:
|
|
18
|
+
image_url: OpenAIImageURLURL
|
|
16
19
|
|
|
17
|
-
|
|
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):
|
|
@@ -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 ==
|
|
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)}")
|
|
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
|
|
File without changes
|
|
File without changes
|