sinapsis 0.2.0__tar.gz → 0.2.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.
- {sinapsis-0.2.0 → sinapsis-0.2.2}/PKG-INFO +3 -1
- {sinapsis-0.2.0 → sinapsis-0.2.2}/pyproject.toml +4 -1
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/webapp/agent_gradio_helper.py +5 -1
- sinapsis-0.2.2/src/sinapsis/webapp/agent_webapp_utils.py +50 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/webapp/chatbot_base.py +8 -5
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis.egg-info/PKG-INFO +3 -1
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis.egg-info/requires.txt +3 -0
- sinapsis-0.2.0/src/sinapsis/webapp/agent_webapp_utils.py +0 -25
- {sinapsis-0.2.0 → sinapsis-0.2.2}/LICENSE +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/README.md +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/setup.cfg +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/__init__.py +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/bin/sinapsis_cli.py +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/templates/__init__.py +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/templates/display_hello_world.py +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/templates/hello_world.py +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis/webapp/__init__.py +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis.egg-info/SOURCES.txt +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis.egg-info/dependency_links.txt +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis.egg-info/entry_points.txt +0 -0
- {sinapsis-0.2.0 → sinapsis-0.2.2}/src/sinapsis.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sinapsis
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Modular and Universal AI platform
|
|
5
5
|
Author-email: SinapsisAI <dev@sinapsis.tech>
|
|
6
6
|
License: GNU AFFERO GENERAL PUBLIC LICENSE
|
|
@@ -674,6 +674,8 @@ Description-Content-Type: text/markdown
|
|
|
674
674
|
Requires-Dist: sinapsis-core>=0.1.0
|
|
675
675
|
Provides-Extra: all
|
|
676
676
|
Requires-Dist: sinapsis[dev]; extra == "all"
|
|
677
|
+
Provides-Extra: webapp
|
|
678
|
+
Requires-Dist: gradio>=5.23.3; extra == "webapp"
|
|
677
679
|
|
|
678
680
|
<h1 align="center">
|
|
679
681
|
<br>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sinapsis"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2"
|
|
4
4
|
description = "Modular and Universal AI platform"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "SinapsisAI", email = "dev@sinapsis.tech"},
|
|
@@ -26,6 +26,9 @@ sinapsis = "sinapsis.bin.sinapsis_cli:main"
|
|
|
26
26
|
all = [
|
|
27
27
|
"sinapsis[dev]",
|
|
28
28
|
]
|
|
29
|
+
webapp = [
|
|
30
|
+
"gradio>=5.23.3",
|
|
31
|
+
]
|
|
29
32
|
|
|
30
33
|
|
|
31
34
|
[tool.ruff]
|
|
@@ -35,6 +35,7 @@ def init_image_inference(
|
|
|
35
35
|
stream: bool = False,
|
|
36
36
|
image_input: gr.Image | None = gr.Image,
|
|
37
37
|
app_message: str | None = None,
|
|
38
|
+
examples: list[str] | None = None,
|
|
38
39
|
):
|
|
39
40
|
"""
|
|
40
41
|
Method to perform inference on the input from gradio
|
|
@@ -44,6 +45,7 @@ def init_image_inference(
|
|
|
44
45
|
stream (bool) : Whether to consume a single image (False) or a video (True)
|
|
45
46
|
image_input (gr.Image | None): Whether the app takes an input image or not
|
|
46
47
|
app_message (str | None): The message that shows up in the interface when starting it.
|
|
48
|
+
examples (list | None): Adds example images to the gradio app
|
|
47
49
|
"""
|
|
48
50
|
input_sources = ["webcam"]
|
|
49
51
|
if not stream:
|
|
@@ -60,6 +62,7 @@ def init_image_inference(
|
|
|
60
62
|
title=title,
|
|
61
63
|
flagging_mode="never",
|
|
62
64
|
article=app_message,
|
|
65
|
+
examples=examples,
|
|
63
66
|
)
|
|
64
67
|
return live_interface
|
|
65
68
|
|
|
@@ -117,10 +120,11 @@ def add_logo_and_title(page_title: str | None = None) -> None:
|
|
|
117
120
|
logo_path,
|
|
118
121
|
elem_id="sinapsis-logo",
|
|
119
122
|
width=800,
|
|
120
|
-
height=
|
|
123
|
+
height=150,
|
|
121
124
|
show_label=False,
|
|
122
125
|
show_download_button=False,
|
|
123
126
|
show_fullscreen_button=False,
|
|
127
|
+
scale=0.5,
|
|
124
128
|
)
|
|
125
129
|
|
|
126
130
|
gr.Markdown(f"# {page_title}", elem_id="title")
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from sinapsis_core.agent import Agent
|
|
6
|
+
from sinapsis_core.cli.run_agent_from_config import AgentMode
|
|
7
|
+
from sinapsis_core.data_containers.data_packet import DataContainer, ImagePacket
|
|
8
|
+
from sinapsis_core.utils.logging_utils import sinapsis_logger
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def infer_image(agent: Agent, image: Any) -> Any:
|
|
12
|
+
"""Method used in apps that require an image input
|
|
13
|
+
Args:
|
|
14
|
+
agent (Agent): Agent instance
|
|
15
|
+
image (Any): input from the gradio/streamlit app
|
|
16
|
+
Returns:
|
|
17
|
+
the final image content after agent execution
|
|
18
|
+
"""
|
|
19
|
+
if image is None:
|
|
20
|
+
return None
|
|
21
|
+
container = DataContainer()
|
|
22
|
+
container.images = [
|
|
23
|
+
ImagePacket(
|
|
24
|
+
content=image,
|
|
25
|
+
source="live_stream",
|
|
26
|
+
)
|
|
27
|
+
]
|
|
28
|
+
result_container = agent(container)
|
|
29
|
+
return result_container.images[-1].content
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def infer_video(agent: Agent, video: Any) -> Path:
|
|
33
|
+
"""Processes an input video using the CoTracker agent and returns the path to the output video.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
agent (Agent): Agent instance
|
|
37
|
+
video (Any): The input video file or path.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Path: The file path to the processed video.
|
|
41
|
+
"""
|
|
42
|
+
agent.update_template_attribute("VideoReaderCV2", "video_file_path", video)
|
|
43
|
+
agent.reset_state()
|
|
44
|
+
for _ in agent(None, AgentMode.GENERATOR):
|
|
45
|
+
pass
|
|
46
|
+
agent.topological_sort["VideoWriterCV2"].template_instance.video_writer_is_done()
|
|
47
|
+
sinapsis_logger.debug("Finished processing video")
|
|
48
|
+
path = agent.topological_sort["VideoWriterCV2"].metadata.attributes["destination_path"]
|
|
49
|
+
|
|
50
|
+
return Path(path)
|
|
@@ -8,6 +8,7 @@ from pydantic.dataclasses import dataclass
|
|
|
8
8
|
from sinapsis_core.cli.run_agent_from_config import generic_agent_builder
|
|
9
9
|
from sinapsis_core.data_containers.data_packet import DataContainer, TextPacket
|
|
10
10
|
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
11
|
+
from sinapsis_core.utils.logging_utils import sinapsis_logger
|
|
11
12
|
|
|
12
13
|
from sinapsis.webapp.agent_gradio_helper import add_logo_and_title, css_header
|
|
13
14
|
|
|
@@ -168,7 +169,9 @@ class BaseChatbot:
|
|
|
168
169
|
Returns:
|
|
169
170
|
tuple: A tuple with None and Gradio updates for interactivity.
|
|
170
171
|
"""
|
|
171
|
-
self.
|
|
172
|
+
with open(self.file_name, "w+", encoding="utf-8") as chat:
|
|
173
|
+
json.dump(self.chat_history, chat, indent=4)
|
|
174
|
+
chat.close()
|
|
172
175
|
self.agent = None
|
|
173
176
|
return gr.update(interactive=False), gr.update(interactive=False)
|
|
174
177
|
|
|
@@ -179,10 +182,11 @@ class BaseChatbot:
|
|
|
179
182
|
This method writes the current chat history to a file in JSON format,
|
|
180
183
|
then clears the history.
|
|
181
184
|
"""
|
|
182
|
-
with open(self.file_name, "w+", encoding="utf-8") as chat:
|
|
183
|
-
json.dump(self.chat_history, chat, indent=4)
|
|
184
|
-
chat.close()
|
|
185
185
|
self.chat_history = []
|
|
186
|
+
try:
|
|
187
|
+
os.remove(self.file_name)
|
|
188
|
+
except FileNotFoundError:
|
|
189
|
+
sinapsis_logger.warning("Chat history file does not exist")
|
|
186
190
|
|
|
187
191
|
def process_msg(self, message: str, conv_id: str) -> tuple[list, gr.Textbox, gr.Audio, str] | list:
|
|
188
192
|
"""
|
|
@@ -236,7 +240,6 @@ class BaseChatbot:
|
|
|
236
240
|
"""
|
|
237
241
|
|
|
238
242
|
conversation_id = gr.State()
|
|
239
|
-
|
|
240
243
|
(
|
|
241
244
|
chatbot,
|
|
242
245
|
chat_input,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sinapsis
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Modular and Universal AI platform
|
|
5
5
|
Author-email: SinapsisAI <dev@sinapsis.tech>
|
|
6
6
|
License: GNU AFFERO GENERAL PUBLIC LICENSE
|
|
@@ -674,6 +674,8 @@ Description-Content-Type: text/markdown
|
|
|
674
674
|
Requires-Dist: sinapsis-core>=0.1.0
|
|
675
675
|
Provides-Extra: all
|
|
676
676
|
Requires-Dist: sinapsis[dev]; extra == "all"
|
|
677
|
+
Provides-Extra: webapp
|
|
678
|
+
Requires-Dist: gradio>=5.23.3; extra == "webapp"
|
|
677
679
|
|
|
678
680
|
<h1 align="center">
|
|
679
681
|
<br>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Any
|
|
3
|
-
|
|
4
|
-
from sinapsis_core.agent import Agent
|
|
5
|
-
from sinapsis_core.data_containers.data_packet import DataContainer, ImagePacket
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def infer_image(agent: Agent, image: Any) -> Any:
|
|
9
|
-
"""Method used in apps that require an image input
|
|
10
|
-
Args:
|
|
11
|
-
agent (Agent): Agent instance
|
|
12
|
-
image (Any): input from the gradio/streamlit app
|
|
13
|
-
Returns:
|
|
14
|
-
the final image content after agent execution
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
container = DataContainer()
|
|
18
|
-
container.images = [
|
|
19
|
-
ImagePacket(
|
|
20
|
-
content=image,
|
|
21
|
-
source="live_stream",
|
|
22
|
-
)
|
|
23
|
-
]
|
|
24
|
-
result_container = agent(container)
|
|
25
|
-
return result_container.images[-1].content
|
|
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
|