prompt-caller 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.
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/PKG-INFO +4 -2
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/prompt_caller/prompt_caller.py +32 -1
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/prompt_caller.egg-info/PKG-INFO +4 -2
- prompt_caller-0.0.5/prompt_caller.egg-info/requires.txt +6 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/setup.py +4 -2
- prompt_caller-0.0.3/prompt_caller.egg-info/requires.txt +0 -4
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/LICENSE +0 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/README.md +0 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/prompt_caller/__init__.py +0 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/prompt_caller/__main__.py +0 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/prompt_caller.egg-info/SOURCES.txt +0 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/prompt_caller.egg-info/dependency_links.txt +0 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/prompt_caller.egg-info/top_level.txt +0 -0
- {prompt_caller-0.0.3 → prompt_caller-0.0.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prompt_caller
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: This package is responsible for calling prompts in a specific format. It uses LangChain and OpenAI API
|
|
5
5
|
Home-page: https://github.com/ThiNepo/prompt-caller
|
|
6
6
|
Author: Thiago Nepomuceno
|
|
@@ -13,7 +13,9 @@ License-File: LICENSE
|
|
|
13
13
|
Requires-Dist: pyyaml>=6.0.2
|
|
14
14
|
Requires-Dist: python-dotenv>=1.0.1
|
|
15
15
|
Requires-Dist: Jinja2>=3.1.4
|
|
16
|
-
Requires-Dist: langchain-openai>=0.
|
|
16
|
+
Requires-Dist: langchain-openai>=0.3.5
|
|
17
|
+
Requires-Dist: openai>=1.63.0
|
|
18
|
+
Requires-Dist: pillow>=11.0.0
|
|
17
19
|
|
|
18
20
|
# PromptCaller
|
|
19
21
|
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
3
|
|
|
4
|
+
import requests
|
|
4
5
|
import yaml
|
|
5
6
|
from dotenv import load_dotenv
|
|
6
7
|
from jinja2 import Template
|
|
7
8
|
from langchain_core.messages import HumanMessage, SystemMessage
|
|
8
9
|
from langchain_openai import ChatOpenAI
|
|
10
|
+
from PIL import Image
|
|
9
11
|
from pydantic import BaseModel, Field, create_model
|
|
10
12
|
|
|
13
|
+
from io import BytesIO
|
|
14
|
+
import base64
|
|
15
|
+
|
|
11
16
|
load_dotenv()
|
|
12
17
|
|
|
13
18
|
|
|
@@ -32,7 +37,7 @@ class PromptCaller:
|
|
|
32
37
|
|
|
33
38
|
def _parseJSXBody(self, body):
|
|
34
39
|
elements = []
|
|
35
|
-
tag_pattern = r"<(system|user|assistant)>(.*?)</\1>"
|
|
40
|
+
tag_pattern = r"<(system|user|assistant|image)>(.*?)</\1>"
|
|
36
41
|
|
|
37
42
|
matches = re.findall(tag_pattern, body, re.DOTALL)
|
|
38
43
|
|
|
@@ -41,6 +46,15 @@ class PromptCaller:
|
|
|
41
46
|
|
|
42
47
|
return elements
|
|
43
48
|
|
|
49
|
+
def getImageBase64(self, url: str) -> str:
|
|
50
|
+
response = requests.get(url)
|
|
51
|
+
response.raise_for_status()
|
|
52
|
+
img = Image.open(BytesIO(response.content))
|
|
53
|
+
buffered = BytesIO()
|
|
54
|
+
img.save(buffered, format="PNG")
|
|
55
|
+
img_base64 = base64.b64encode(buffered.getvalue()).decode("utf-8")
|
|
56
|
+
return f"data:image/png;base64,{img_base64}"
|
|
57
|
+
|
|
44
58
|
def loadPrompt(self, promptName, context=None):
|
|
45
59
|
# initialize context
|
|
46
60
|
if context is None:
|
|
@@ -63,6 +77,23 @@ class PromptCaller:
|
|
|
63
77
|
if message.get("role") == "user":
|
|
64
78
|
messages.append(HumanMessage(content=message.get("content")))
|
|
65
79
|
|
|
80
|
+
if message.get("role") == "image":
|
|
81
|
+
base64_image = message.get("content")
|
|
82
|
+
|
|
83
|
+
if base64_image.startswith("http"):
|
|
84
|
+
base64_image = self.getImageBase64(base64_image)
|
|
85
|
+
|
|
86
|
+
messages.append(
|
|
87
|
+
HumanMessage(
|
|
88
|
+
content=[
|
|
89
|
+
{
|
|
90
|
+
"type": "image_url",
|
|
91
|
+
"image_url": {"url": base64_image},
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
|
|
66
97
|
return configuration, messages
|
|
67
98
|
|
|
68
99
|
def createPydanticModel(self, dynamic_dict):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prompt_caller
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: This package is responsible for calling prompts in a specific format. It uses LangChain and OpenAI API
|
|
5
5
|
Home-page: https://github.com/ThiNepo/prompt-caller
|
|
6
6
|
Author: Thiago Nepomuceno
|
|
@@ -13,7 +13,9 @@ License-File: LICENSE
|
|
|
13
13
|
Requires-Dist: pyyaml>=6.0.2
|
|
14
14
|
Requires-Dist: python-dotenv>=1.0.1
|
|
15
15
|
Requires-Dist: Jinja2>=3.1.4
|
|
16
|
-
Requires-Dist: langchain-openai>=0.
|
|
16
|
+
Requires-Dist: langchain-openai>=0.3.5
|
|
17
|
+
Requires-Dist: openai>=1.63.0
|
|
18
|
+
Requires-Dist: pillow>=11.0.0
|
|
17
19
|
|
|
18
20
|
# PromptCaller
|
|
19
21
|
|
|
@@ -35,7 +35,7 @@ class BdistWheelCommand(bdist_wheel):
|
|
|
35
35
|
|
|
36
36
|
setuptools.setup(
|
|
37
37
|
name="prompt_caller",
|
|
38
|
-
version="0.0.
|
|
38
|
+
version="0.0.5",
|
|
39
39
|
author="Thiago Nepomuceno",
|
|
40
40
|
author_email="thiago@neps.academy",
|
|
41
41
|
description="This package is responsible for calling prompts in a specific format. It uses LangChain and OpenAI API",
|
|
@@ -53,7 +53,9 @@ setuptools.setup(
|
|
|
53
53
|
"pyyaml>=6.0.2",
|
|
54
54
|
"python-dotenv>=1.0.1",
|
|
55
55
|
"Jinja2>=3.1.4",
|
|
56
|
-
"langchain-openai>=0.
|
|
56
|
+
"langchain-openai>=0.3.5",
|
|
57
|
+
"openai>=1.63.0",
|
|
58
|
+
"pillow>=11.0.0",
|
|
57
59
|
],
|
|
58
60
|
cmdclass={"sdist": SdistCommand, "bdist_wheel": BdistWheelCommand},
|
|
59
61
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|