pylogue 0.3__py3-none-any.whl → 0.3.30__py3-none-any.whl

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: pylogue
3
- Version: 0.3
3
+ Version: 0.3.30
4
4
  Summary: A Chatbot UI built for AI agents
5
5
  Author-email: Yeshwanth Reddy <yyeshr@gmail.com>
6
6
  Maintainer-email: Yeshwanth Reddy <yyeshr@gmail.com>
@@ -20,6 +20,15 @@ Requires-Dist: mkdocs-minify-plugin>=0.8.0
20
20
  Requires-Dist: mkdocs-git-revision-date-localized-plugin>=1.4.7
21
21
  Requires-Dist: pymdown-extensions>=10.16.1
22
22
  Requires-Dist: python-fasthtml>=0.12.29
23
+ Requires-Dist: monsterui
24
+ Requires-Dist: logfire>=4.20.0
25
+ Requires-Dist: pydantic-ai>=1.48.0
26
+ Requires-Dist: fastsql>=2.1.2
27
+ Requires-Dist: duckdb>=1.4.4
28
+ Requires-Dist: altair>=6.0.0
29
+ Requires-Dist: pandas>=3.0.0
30
+ Requires-Dist: simple-salesforce>=1.12.9
31
+ Requires-Dist: authlib>=1.3.2
23
32
  Provides-Extra: dev
24
33
  Requires-Dist: coverage; extra == "dev"
25
34
  Requires-Dist: mypy; extra == "dev"
@@ -0,0 +1,26 @@
1
+ pylogue/core.py,sha256=kN1r_JnhuKg8JVLSAP7Ct49lkph8_Z_jZPI0gE4LtFc,30161
2
+ pylogue/embeds.py,sha256=wIQ3FGq8GQ5p47ucpfqTmYl1Oy150eldDyWyS3yreBc,785
3
+ pylogue/shell.py,sha256=SmeZuUA6w-keRfuExEKqpLGGCLXlRtlZ6mIS1BN2Gj8,11045
4
+ pylogue/integrations/__init__.py,sha256=1MyHq6P2jY8nNy7e6n5I25sc9I5U7GI-Uz578dpbysY,23
5
+ pylogue/integrations/pydantic_ai.py,sha256=vW9pgbccUoL4LGuq525iYoY7krEVwGV5I6DXHp1Vfpc,16621
6
+ pylogue/legacy/__init__.py,sha256=gDXS44jmg6hPtcg8IxTFRdyV-TGsjQTkT-5NjiapYZ4,319
7
+ pylogue/legacy/__pre_init__.py,sha256=NiQUAz7feHFR47QTpMwF324j61IVrOreZsk9wY11cds,153
8
+ pylogue/legacy/_modidx.py,sha256=IDAxgZ4opfun-D1eJ9qH1F0gvv-y5OzXlEDhak8BG30,14348
9
+ pylogue/legacy/cards.py,sha256=Bbm6sdjCurGu3YWuUgquCvL9amjuyhy9bn9YHJhXPL0,3649
10
+ pylogue/legacy/chat.py,sha256=enTtSXZMKTdi8Qa5XaQvK2JJTg0qa5CwmTADsrfMXWc,5239
11
+ pylogue/legacy/chatapp.py,sha256=PuJhUQobLx-ViGr2CFybfR_d1bYJgUS0dIOfgx_Gi58,12271
12
+ pylogue/legacy/design_system.py,sha256=Jl-akJoFDNWd3wIjWndAK1Gf8Rc4ENDKj1jJUhz5LJs,3499
13
+ pylogue/legacy/health.py,sha256=8LWhpVzdj2g6qUcErrg455_6WfOsv3lp82OLLwJPtug,443
14
+ pylogue/legacy/renderer.py,sha256=zEE7fwP4lDckFBPOj9Db0px7jBxpbyGEACk53R6H9KQ,8075
15
+ pylogue/legacy/service.py,sha256=e3GfbQrOPlRIj7j0CZZx_qN2ZI_polOuWqBMm7ySXqs,6917
16
+ pylogue/legacy/session.py,sha256=fUyGOFIG8b1clhyyw5c_dapdwrJyzd9K2bOc_qKBQcs,5382
17
+ pylogue/static/pylogue-core.css,sha256=kcN0DKwsbHLFk17ESOHCE8aD4LxZC-UYsRAESJV0dj4,6237
18
+ pylogue/static/pylogue-core.js,sha256=CcAXieqz_yoixdlNrNg1XCUZwo3AystlER6HYIuXhHs,9149
19
+ pylogue/static/pylogue-markdown.js,sha256=5bdzoRNTa2QCp9oaOmXdmkqeP3PQAko8bB68uMLTF_M,36482
20
+ pylogue-0.3.30.dist-info/licenses/AUTHORS.md,sha256=5Viska6TOr9uggc2olSr8VVnu6BFw_F6_64gP42CwQ4,157
21
+ pylogue-0.3.30.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ pylogue-0.3.30.dist-info/METADATA,sha256=aAT2JiYvhMq43XKvRCjCtrZyIxnxbIUWkeLp9htnGfs,1339
23
+ pylogue-0.3.30.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
24
+ pylogue-0.3.30.dist-info/entry_points.txt,sha256=ha0gwcGgtciKEhmFcMKJO1efTY9Spu1wcTHUopB1bec,40
25
+ pylogue-0.3.30.dist-info/top_level.txt,sha256=oEueWVdlRAUPQt8VfQdqFEqOWxvUObx3UIa3UYa3s6o,8
26
+ pylogue-0.3.30.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
pylogue/cards.py DELETED
@@ -1,174 +0,0 @@
1
- # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/0-Card.ipynb.
2
-
3
- # %% auto 0
4
- __all__ = ['CHAT_DIV_ID', 'ChatCard', 'render_chat_list', 'mk_inp']
5
-
6
- # %% ../../nbs/0-Card.ipynb 2
7
- from fasthtml.common import *
8
-
9
- # %% ../../nbs/0-Card.ipynb 4
10
- class ChatCard:
11
- def __init__(
12
- self,
13
- user_color: str = "#1C0069",
14
- assistant_color: str = "#004539",
15
- user_emoji: str = "🗣️",
16
- assistant_emoji: str = "🕵️‍♂️",
17
- max_width: str = "80%",
18
- card_max_width: str = "60%",
19
- font_size: str = "1.5em",
20
- mobile_font_size: str = "16px",
21
- padding: str = "1.25em",
22
- user_align: str = "right",
23
- assistant_align: str = "left",
24
- user_self_align: str = "flex-end",
25
- assistant_self_align: str = "flex-start",
26
- role_font_weight: str = "bold",
27
- role_font_size: str = "1.1em",
28
- role_margin_bottom: str = "8px",
29
- content_white_space: str = "normal",
30
- spinner_class: str = "spinner",
31
- ):
32
- self.colors = {
33
- "User": user_color,
34
- "Assistant": assistant_color,
35
- }
36
-
37
- self.emojis = {"User": user_emoji, "Assistant": assistant_emoji}
38
-
39
- self.alignments = {
40
- "User": {"text": user_align, "self": user_self_align},
41
- "Assistant": {"text": assistant_align, "self": assistant_self_align},
42
- }
43
-
44
- self.border_radii = {"User": "1em 1em 0em 1em", "Assistant": "1em 1em 1em 0em"}
45
-
46
- # Style configuration
47
- self.card_max_width = card_max_width
48
- self.max_width = max_width
49
- self.font_size = font_size
50
- self.mobile_font_size = mobile_font_size
51
- self.padding = padding
52
- self.role_font_weight = role_font_weight
53
- self.role_font_size = role_font_size
54
- self.role_margin_bottom = role_margin_bottom
55
- self.content_white_space = content_white_space
56
- self.spinner_class = spinner_class
57
-
58
- # Build style template
59
- self.style_template = f"""
60
- background: {{bg}}; color: {{text_color}}; padding: 10px; font-size: {self.font_size};
61
- max-width: min({self.card_max_width}, {self.max_width}); align-self: {{self_align}};
62
- text-align: {{text_align}}; border-radius: {{border_radius}};
63
- padding: {self.padding}"""
64
-
65
- def _get_text_color(self, bg_color: str) -> str:
66
- """
67
- Calculate whether to use black or white text based on background color luminance.
68
- Uses the relative luminance formula from WCAG guidelines.
69
- """
70
- # Remove # if present
71
- hex_color = bg_color.lstrip("#")
72
-
73
- # Convert hex to RGB
74
- r = int(hex_color[0:2], 16) / 255.0
75
- g = int(hex_color[2:4], 16) / 255.0
76
- b = int(hex_color[4:6], 16) / 255.0
77
-
78
- # Calculate relative luminance
79
- def adjust_channel(c):
80
- return c / 12.92 if c <= 0.03928 else ((c + 0.055) / 1.055) ** 2.4
81
-
82
- r, g, b = adjust_channel(r), adjust_channel(g), adjust_channel(b)
83
- luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b
84
-
85
- # Return white for dark backgrounds, black for light backgrounds
86
- return "#FFFFFF" if luminance < 0.5 else "#000000"
87
-
88
- def _get_style(self, role: str) -> str:
89
- """Generate CSS style string for a given role."""
90
- bg_color = self.colors[role]
91
- return self.style_template.format(
92
- bg=bg_color,
93
- text_color=self._get_text_color(bg_color),
94
- self_align=self.alignments[role]["self"],
95
- text_align=self.alignments[role]["text"],
96
- border_radius=self.border_radii[role],
97
- )
98
-
99
- def _get_role_style(self) -> str:
100
- """Generate CSS style string for role labels."""
101
- return f"font-weight: {self.role_font_weight}; font-size: {self.role_font_size}; display: block; margin-bottom: {self.role_margin_bottom};"
102
-
103
- def get_mobile_styles(self) -> str:
104
- """Generate CSS media query for mobile devices."""
105
- return f"""
106
- @media (max-width: 768px) {{
107
- .chat-card {{
108
- font-size: {self.mobile_font_size} !important;
109
- }}
110
- }}
111
- """
112
-
113
- def render(self, data: dict):
114
- """
115
- Render a chat card with the given data.
116
-
117
- Args:
118
- data: Dictionary containing:
119
- - role: "User" or "Assistant"
120
- - content: Message content (optional)
121
- - pending: Boolean indicating if message is loading (optional)
122
-
123
- Returns:
124
- FastHTML Div element representing the chat card
125
- """
126
- role = data["role"]
127
- content = data.get("content", "")
128
- pending = data.get("pending", False)
129
-
130
- style = self._get_style(role)
131
- emoji = self.emojis[role]
132
-
133
- if pending:
134
- spinner = Span(cls=self.spinner_class)
135
- return Div(f"{emoji} {role}: ", spinner, style=style, cls="chat-card")
136
-
137
- # Add 'marked' class to enable markdown rendering
138
- return Div(
139
- Span(
140
- U(f"{emoji} {role}: "),
141
- style=self._get_role_style(),
142
- ),
143
- Div(
144
- content, cls="marked", style=f"white-space: {self.content_white_space};"
145
- ),
146
- style=style,
147
- cls="chat-card",
148
- )
149
-
150
- def __call__(self, data: dict):
151
- """Make the class callable like the original function."""
152
- return self.render(data)
153
-
154
- # %% ../../nbs/0-Card.ipynb 7
155
- CHAT_DIV_ID = "chat-cards"
156
-
157
-
158
- def render_chat_list(messages: List[Dict[str, str]], ChatCard: ChatCard):
159
- return Div(
160
- Style(ChatCard.get_mobile_styles()),
161
- *[ChatCard(m) for m in messages],
162
- id=CHAT_DIV_ID,
163
- cls="chat-cards",
164
- style="display: flex; flex-direction: column; gap: 10px;",
165
- )
166
-
167
- # %% ../../nbs/0-Card.ipynb 9
168
- def mk_inp():
169
- return Input(
170
- id="msg",
171
- placeholder="Type a message...",
172
- autofocus=True,
173
- style="width: 60%; max-width: 600px; padding: 0.75em; font-size: 1em; border-radius: 0.5em",
174
- )
pylogue/renderer.py DELETED
@@ -1,139 +0,0 @@
1
- # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/3-Renderer.ipynb.
2
-
3
- # %% auto 0
4
- __all__ = ['ChatRenderer']
5
-
6
- # %% ../../nbs/3-Renderer.ipynb 1
7
- from typing import List, Dict, Any, Optional
8
- from fasthtml.common import *
9
- from .cards import ChatCard
10
- from .session import Message, ChatSession
11
-
12
- # %% ../../nbs/3-Renderer.ipynb 3
13
- class ChatRenderer:
14
- """Renders chat components with customizable styling."""
15
-
16
- CHAT_DIV_ID = "chat-cards"
17
-
18
- def __init__(
19
- self,
20
- card: Optional[ChatCard] = None,
21
- input_placeholder: str = "Type a message...",
22
- input_style: Optional[str] = None,
23
- chat_container_style: Optional[str] = None,
24
- ws_endpoint: str = "/ws",
25
- ):
26
- """
27
- Initialize ChatRenderer.
28
-
29
- Args:
30
- card: ChatCard instance for rendering messages
31
- input_placeholder: Placeholder text for input field
32
- input_style: Custom CSS style for input field
33
- chat_container_style: Custom CSS style for chat container
34
- ws_endpoint: WebSocket endpoint path
35
- """
36
- self.card = card or ChatCard()
37
- self.input_placeholder = input_placeholder
38
- self.ws_endpoint = ws_endpoint
39
- self.input_style = input_style or (
40
- "width: 60%; max-width: 600px; padding: 0.75em; "
41
- "font-size: 1em; border-radius: 0.5em"
42
- )
43
- self.chat_container_style = chat_container_style or (
44
- "display: flex; flex-direction: column; gap: 1em; margin: 3em;"
45
- )
46
-
47
- def render_message(self, message: Message) -> Any:
48
- """Render a single message."""
49
- return self.card(message.to_dict())
50
-
51
- def render_messages(self, messages: List[Message]) -> Any:
52
- """
53
- Render a list of messages in a container.
54
-
55
- Args:
56
- messages: List of Message objects to render
57
-
58
- Returns:
59
- FastHTML Div containing all rendered messages
60
- """
61
- # Add mobile-responsive margin CSS
62
- mobile_margin_css = """
63
- @media (max-width: 768px) {
64
- .chat-cards {
65
- margin: 1em !important;
66
- }
67
- }
68
- """
69
-
70
- return Div(
71
- Style(self.card.get_mobile_styles()),
72
- Style(mobile_margin_css),
73
- *[self.render_message(msg) for msg in messages],
74
- id=self.CHAT_DIV_ID,
75
- cls="chat-cards",
76
- style=self.chat_container_style,
77
- )
78
-
79
- def render_messages_from_dicts(self, message_dicts: List[Dict[str, Any]]) -> Any:
80
- """
81
- Render messages from dictionary representations.
82
-
83
- Args:
84
- message_dicts: List of message dictionaries
85
-
86
- Returns:
87
- FastHTML Div containing all rendered messages
88
- """
89
- messages = [Message.from_dict(d) for d in message_dicts]
90
- return self.render_messages(messages)
91
-
92
- def render_input(self, input_id: str = "msg", autofocus: bool = True) -> Any:
93
- """
94
- Render the message input field.
95
-
96
- Args:
97
- input_id: HTML ID for the input element
98
- autofocus: Whether to autofocus the input
99
-
100
- Returns:
101
- FastHTML Input element
102
- """
103
- return Input(
104
- id=input_id,
105
- placeholder=self.input_placeholder,
106
- autofocus=autofocus,
107
- style=self.input_style,
108
- )
109
-
110
- def render_form(
111
- self,
112
- form_id: str = "form",
113
- form_style: Optional[str] = None,
114
- ws_send: bool = True,
115
- ) -> Any:
116
- """
117
- Render the input form with WebSocket connection.
118
-
119
- Args:
120
- form_id: HTML ID for the form
121
- form_style: Custom CSS style for form
122
- ws_send: Whether form sends via WebSocket
123
-
124
- Returns:
125
- FastHTML Form element
126
- """
127
- form_style = form_style or (
128
- "display: flex; justify-content: center; "
129
- "margin-top: 20px; padding: 20px;"
130
- )
131
-
132
- return Form(
133
- self.render_input(),
134
- id=form_id,
135
- hx_ext="ws",
136
- ws_connect=self.ws_endpoint,
137
- ws_send=ws_send,
138
- style=form_style,
139
- )
@@ -1,17 +0,0 @@
1
- pylogue/__init__.py,sha256=gDXS44jmg6hPtcg8IxTFRdyV-TGsjQTkT-5NjiapYZ4,319
2
- pylogue/__pre_init__.py,sha256=NiQUAz7feHFR47QTpMwF324j61IVrOreZsk9wY11cds,153
3
- pylogue/_modidx.py,sha256=IDAxgZ4opfun-D1eJ9qH1F0gvv-y5OzXlEDhak8BG30,14348
4
- pylogue/cards.py,sha256=iu8fgkE2WLERAeawna5AY4-0_KqWhDGQ9NSj4Cygp2w,6041
5
- pylogue/chat.py,sha256=RyRADCZWxTjCM3W7FgIj0jQ8WrqhRBzbeFEvS9mTZq4,3982
6
- pylogue/chatapp.py,sha256=Pnpr4PR2qI8oHvTLynMr2n2DaCerEJeBSRMy7MF4AXs,10142
7
- pylogue/health.py,sha256=8LWhpVzdj2g6qUcErrg455_6WfOsv3lp82OLLwJPtug,443
8
- pylogue/renderer.py,sha256=nkFsSNiqMj98n3kPyLu77PnyiGBPLOXNvmXRb7-JQF8,4176
9
- pylogue/service.py,sha256=e3GfbQrOPlRIj7j0CZZx_qN2ZI_polOuWqBMm7ySXqs,6917
10
- pylogue/session.py,sha256=fUyGOFIG8b1clhyyw5c_dapdwrJyzd9K2bOc_qKBQcs,5382
11
- pylogue-0.3.dist-info/licenses/AUTHORS.md,sha256=5Viska6TOr9uggc2olSr8VVnu6BFw_F6_64gP42CwQ4,157
12
- pylogue-0.3.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- pylogue-0.3.dist-info/METADATA,sha256=GQDIfcrpAg9CUiAkcSAsn6BhmTisLmuVqu0H_dUQ84M,1057
14
- pylogue-0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- pylogue-0.3.dist-info/entry_points.txt,sha256=ha0gwcGgtciKEhmFcMKJO1efTY9Spu1wcTHUopB1bec,40
16
- pylogue-0.3.dist-info/top_level.txt,sha256=oEueWVdlRAUPQt8VfQdqFEqOWxvUObx3UIa3UYa3s6o,8
17
- pylogue-0.3.dist-info/RECORD,,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes