pylogue 0.1.0__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.
@@ -0,0 +1,13 @@
1
+ =======
2
+ Credits
3
+ =======
4
+
5
+ Development Lead
6
+ ----------------
7
+
8
+ * Yeshwanth Reddy <yyeshr@gmail.com>
9
+
10
+ Contributors
11
+ ------------
12
+
13
+ None yet. Why not be the first?
@@ -0,0 +1,136 @@
1
+ .. highlight:: shell
2
+
3
+ ============
4
+ Contributing
5
+ ============
6
+
7
+ Contributions are welcome, and they are greatly appreciated! Every little bit
8
+ helps, and credit will always be given.
9
+
10
+ You can contribute in many ways:
11
+
12
+ Types of Contributions
13
+ ----------------------
14
+
15
+ Report Bugs
16
+ ~~~~~~~~~~~
17
+
18
+ Report bugs at https://github.com/sizhky/pylogue/issues.
19
+
20
+ If you are reporting a bug, please include:
21
+
22
+ * Your operating system name and version.
23
+ * Any details about your local setup that might be helpful in troubleshooting.
24
+ * Detailed steps to reproduce the bug.
25
+
26
+ Fix Bugs
27
+ ~~~~~~~~
28
+
29
+ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
30
+ wanted" is open to whoever wants to implement it.
31
+
32
+ Implement Features
33
+ ~~~~~~~~~~~~~~~~~~
34
+
35
+ Look through the GitHub issues for features. Anything tagged with "enhancement"
36
+ and "help wanted" is open to whoever wants to implement it.
37
+
38
+ Write Documentation
39
+ ~~~~~~~~~~~~~~~~~~~
40
+
41
+ Pylogue could always use more documentation, whether as part of the
42
+ official Pylogue docs, in docstrings, or even on the web in blog posts,
43
+ articles, and such.
44
+
45
+ Submit Feedback
46
+ ~~~~~~~~~~~~~~~
47
+
48
+ The best way to send feedback is to file an issue at https://github.com/sizhky/pylogue/issues.
49
+
50
+ If you are proposing a feature:
51
+
52
+ * Explain in detail how it would work.
53
+ * Keep the scope as narrow as possible, to make it easier to implement.
54
+ * Remember that this is a volunteer-driven project, and that contributions
55
+ are welcome :)
56
+
57
+ Get Started!
58
+ ------------
59
+
60
+ Ready to contribute? Here's how to set up `pylogue` for local development.
61
+
62
+ 1. Fork the `pylogue` repo on GitHub.
63
+ 2. Clone your fork locally::
64
+
65
+ $ git clone git@github.com:your_name_here/pylogue.git
66
+
67
+ 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
68
+
69
+ $ mkvirtualenv pylogue
70
+ $ cd pylogue/
71
+ $ python setup.py develop
72
+
73
+ 4. Create a branch for local development::
74
+
75
+ $ git checkout -b name-of-your-bugfix-or-feature
76
+
77
+ Now you can make your changes locally.
78
+
79
+ 5. When you're done making changes, check that your changes pass flake8 and the
80
+ tests, including testing other Python versions with tox::
81
+
82
+ $ make lint
83
+ $ make test
84
+ Or
85
+ $ make test-all
86
+
87
+ To get flake8 and tox, just pip install them into your virtualenv.
88
+
89
+ 6. Commit your changes and push your branch to GitHub::
90
+
91
+ $ git add .
92
+ $ git commit -m "Your detailed description of your changes."
93
+ $ git push origin name-of-your-bugfix-or-feature
94
+
95
+ 7. Submit a pull request through the GitHub website.
96
+
97
+ Pull Request Guidelines
98
+ -----------------------
99
+
100
+ Before you submit a pull request, check that it meets these guidelines:
101
+
102
+ 1. The pull request should include tests.
103
+ 2. If the pull request adds functionality, the docs should be updated. Put
104
+ your new functionality into a function with a docstring, and add the
105
+ feature to the list in README.rst.
106
+ 3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check
107
+ https://travis-ci.com/sizhky/pylogue/pull_requests
108
+ and make sure that the tests pass for all supported Python versions.
109
+
110
+ Tips
111
+ ----
112
+
113
+ To run a subset of tests::
114
+
115
+ $ pytest tests.test_pylogue
116
+
117
+ Deploying
118
+ ---------
119
+
120
+ A reminder for the maintainers on how to deploy.
121
+ Make sure all your changes are committed (including an entry in HISTORY.rst).
122
+ Then run::
123
+
124
+ $ bump2version patch # possible: major / minor / patch
125
+ $ git push
126
+ $ git push --tags
127
+
128
+ Travis will then deploy to PyPI if tests pass.
129
+
130
+ Code of Conduct
131
+ ---------------
132
+
133
+ Please note that this project is released with a `Contributor Code of Conduct`_.
134
+ By participating in this project you agree to abide by its terms.
135
+
136
+ .. _`Contributor Code of Conduct`: CODE_OF_CONDUCT.rst
pylogue-0.1.0/LICENSE ADDED
File without changes
@@ -0,0 +1,11 @@
1
+ include AUTHORS.md
2
+ include CONTRIBUTING.md
3
+ include LICENSE
4
+ include README.md
5
+
6
+ recursive-include tests *
7
+ recursive-exclude * __pycache__
8
+ recursive-exclude * *.py[co]
9
+
10
+ recursive-exclude docs
11
+ recursive-include Makefile make.bat *.jpg *.png *.gif
pylogue-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: pylogue
3
+ Version: 0.1.0
4
+ Summary: A Chatbot UI build for Pydantic-AI agents
5
+ Author-email: Yeshwanth Reddy <yyeshr@gmail.com>
6
+ Maintainer-email: Yeshwanth Reddy <yyeshr@gmail.com>
7
+ License: MIT license
8
+ Project-URL: bugs, https://github.com/sizhky/pylogue/issues
9
+ Project-URL: changelog, https://github.com/sizhky/pylogue/blob/master/changelog.md
10
+ Project-URL: homepage, https://github.com/sizhky/pylogue
11
+ Description-Content-Type: text/x-rst
12
+ License-File: LICENSE
13
+ License-File: AUTHORS.md
14
+ Requires-Dist: typer
15
+ Requires-Dist: nbdev
16
+ Requires-Dist: mkdocs-material>=9.6.18
17
+ Requires-Dist: mkdocs-mermaid2-plugin>=1.2.1
18
+ Requires-Dist: mkdocs-awesome-pages-plugin>=2.10.1
19
+ Requires-Dist: mkdocs-minify-plugin>=0.8.0
20
+ Requires-Dist: mkdocs-git-revision-date-localized-plugin>=1.4.7
21
+ Requires-Dist: pymdown-extensions>=10.16.1
22
+ Requires-Dist: python-fasthtml>=0.12.29
23
+ Provides-Extra: dev
24
+ Requires-Dist: coverage; extra == "dev"
25
+ Requires-Dist: mypy; extra == "dev"
26
+ Requires-Dist: pytest; extra == "dev"
27
+ Requires-Dist: ruff; extra == "dev"
28
+ Dynamic: license-file
@@ -0,0 +1,269 @@
1
+ # Pylogue - Full DI Chat Framework
2
+
3
+
4
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5
+
6
+ ## 🚀 Quick Start
7
+
8
+ ### Minimal Example (5 lines)
9
+
10
+ ``` python
11
+ from pylogue.chatapp import create_default_chat_app
12
+
13
+ async def my_responder(msg: str, context=None) -> str:
14
+ return f"You said: {msg}"
15
+
16
+ app = create_default_chat_app(responder=my_responder)
17
+ app.run(port=5001)
18
+ ```
19
+
20
+ ### Custom Styling
21
+
22
+ ``` python
23
+ from pylogue.card import ChatCard
24
+ from pylogue.chatapp import create_default_chat_app, ChatAppConfig
25
+
26
+ card = ChatCard(
27
+ user_color="#1a3a1a",
28
+ assistant_color="#1a1a3a",
29
+ user_emoji="👤",
30
+ assistant_emoji="🤖"
31
+ )
32
+
33
+ config = ChatAppConfig(
34
+ app_title="My Assistant",
35
+ bg_color="#0a0a0a"
36
+ )
37
+
38
+ app = create_default_chat_app(
39
+ responder=my_responder,
40
+ card=card,
41
+ config=config
42
+ )
43
+ ```
44
+
45
+ ## 🎨 Full DI Example
46
+
47
+ Complete control with dependency injection:
48
+
49
+ ``` python
50
+ from pylogue.chatapp import ChatApp, ChatAppConfig
51
+ from pylogue.session import InMemorySessionManager
52
+ from pylogue.service import ChatService
53
+ from pylogue.renderer import ChatRenderer
54
+ from pylogue.card import ChatCard
55
+
56
+ # 1. Configure components
57
+ session_manager = InMemorySessionManager()
58
+
59
+ chat_service = ChatService(
60
+ responder=my_responder,
61
+ context_provider=lambda s: s.get_messages()
62
+ )
63
+
64
+ renderer = ChatRenderer(
65
+ card=ChatCard(user_color="#2a2a2a")
66
+ )
67
+
68
+ config = ChatAppConfig(
69
+ app_title="Custom App"
70
+ )
71
+
72
+ # 2. Compose application
73
+ app = ChatApp(
74
+ session_manager=session_manager,
75
+ chat_service=chat_service,
76
+ renderer=renderer,
77
+ config=config
78
+ )
79
+
80
+ # 3. Run
81
+ app.run(port=5001)
82
+ ```
83
+
84
+ ## 🔌 Extensibility
85
+
86
+ ### Custom Session Storage
87
+
88
+ ``` python
89
+ from pylogue.session import SessionManager
90
+
91
+ class RedisSessionManager(SessionManager):
92
+ def __init__(self, redis_client):
93
+ self.redis = redis_client
94
+
95
+ def create_session(self, session_id, initial_messages):
96
+ # Store in Redis
97
+ pass
98
+
99
+ def get_session(self, session_id):
100
+ # Retrieve from Redis
101
+ pass
102
+ ```
103
+
104
+ ### Custom Responder (AI/LLM)
105
+
106
+ ``` python
107
+ class OpenAIResponder:
108
+ def __init__(self, api_key, model="gpt-4"):
109
+ self.client = OpenAI(api_key=api_key)
110
+ self.model = model
111
+
112
+ async def __call__(self, message: str, context=None) -> str:
113
+ # Call OpenAI API
114
+ response = await self.client.chat.completions.create(
115
+ model=self.model,
116
+ messages=[{"role": "user", "content": message}]
117
+ )
118
+ return response.choices[0].message.content
119
+ ```
120
+
121
+ ### Custom Error Handler
122
+
123
+ ``` python
124
+ class SlackErrorHandler:
125
+ def __init__(self, slack_webhook):
126
+ self.webhook = slack_webhook
127
+
128
+ def __call__(self, error: Exception, message: str) -> str:
129
+ # Send to Slack
130
+ requests.post(self.webhook, json={"text": f"Error: {error}"})
131
+ return "An error occurred. Team has been notified."
132
+ ```
133
+
134
+ ## 🧪 Testing
135
+
136
+ Each component is independently testable:
137
+
138
+ ``` python
139
+ # Test session management
140
+ from pylogue.session import ChatSession
141
+
142
+ session = ChatSession("test-id")
143
+ session.add_message("User", "Hello")
144
+ assert len(session) == 1
145
+
146
+ # Test service
147
+ from pylogue.service import ChatService
148
+
149
+ service = ChatService(responder=my_responder)
150
+ response = await service.process_message("Test")
151
+ assert "Test" in response
152
+
153
+ # Test renderer
154
+ from pylogue.renderer import ChatRenderer
155
+ from pylogue.session import Message
156
+
157
+ renderer = ChatRenderer()
158
+ messages = [Message(role="User", content="Hi")]
159
+ html = renderer.render_messages(messages)
160
+ # Assert HTML structure
161
+ ```
162
+
163
+ ## 📚 Examples
164
+
165
+ See `6-Examples.ipynb` for complete working examples:
166
+
167
+ 1. **Echo Bot** - Simplest possible implementation
168
+ 2. **Custom Styled Chat** - UI/UX customization
169
+ 3. **Context-Aware Assistant** - Uses conversation history
170
+ 4. **Code Assistant** - Syntax highlighting support
171
+ 5. **Supply Chain RCA** - Domain-specific implementation
172
+
173
+ ## 🔧 Configuration Options
174
+
175
+ ### ChatAppConfig
176
+
177
+ ``` python
178
+ @dataclass
179
+ class ChatAppConfig:
180
+ app_title: str = "Chat Application"
181
+ page_title: str = "Chat"
182
+ bg_color: str = "#1a1a1a"
183
+ header_style: str = "..."
184
+ ws_endpoint: str = "/ws"
185
+ markdown_enabled: bool = True
186
+ syntax_highlighting: bool = True
187
+ highlight_langs: List[str] = [...]
188
+ spinner_css: Optional[str] = None
189
+ initial_messages_factory: Optional[Callable] = None
190
+ ```
191
+
192
+ ### ChatCard
193
+
194
+ ``` python
195
+ ChatCard(
196
+ user_color: str = "#DCF8C6",
197
+ assistant_color: str = "#E6E6E6",
198
+ user_emoji: str = "🗣️",
199
+ assistant_emoji: str = "🕵️‍♂️",
200
+ width: str = "60%",
201
+ font_size: str = "1.5em",
202
+ padding: str = "1.25em",
203
+ border_radius: str = "1em",
204
+ # ... many more options
205
+ )
206
+ ```
207
+
208
+ ## 🎯 Design Principles
209
+
210
+ 1. **Separation of Concerns**: Each layer has a single responsibility
211
+ 2. **Dependency Injection**: All dependencies are explicit and
212
+ injectable
213
+ 3. **Protocol-Oriented**: Components communicate via
214
+ protocols/interfaces
215
+ 4. **Testability**: Every component can be tested in isolation
216
+ 5. **Extensibility**: Easy to swap implementations without changing
217
+ code
218
+ 6. **Composition over Inheritance**: Build complex apps from simple
219
+ parts
220
+
221
+ ## 🔄 Migration from Old Code
222
+
223
+ If you have existing code using global functions:
224
+
225
+ **Before:**
226
+
227
+ ``` python
228
+ user_messages = {} # Global state
229
+
230
+ def render_chat_list(messages):
231
+ # ...
232
+
233
+ def create_chat_app(responder):
234
+ # Tightly coupled
235
+ ```
236
+
237
+ **After:**
238
+
239
+ ``` python
240
+ app = create_default_chat_app(responder=your_responder)
241
+ # All state management, rendering, and logic handled cleanly
242
+ ```
243
+
244
+ ## 📖 Next Steps
245
+
246
+ 1. Read through the notebooks in order:
247
+
248
+ - `2-Session.ipynb` - Understand state management
249
+ - `3-Service.ipynb` - Learn business logic layer
250
+ - `4-Renderer.ipynb` - Explore presentation layer
251
+ - `5-ChatApp.ipynb` - See full integration
252
+ - `6-Examples.ipynb` - Working examples
253
+
254
+ 2. Try the examples in `6-Examples.ipynb`
255
+
256
+ 3. Build your own custom responder
257
+
258
+ 4. Deploy to production with your preferred hosting
259
+
260
+ ## 🤝 Contributing
261
+
262
+ This is a fully modular framework. To extend:
263
+
264
+ 1. Implement the relevant Protocol
265
+ 2. Inject your implementation
266
+ 3. Test independently
267
+ 4. Compose with other components
268
+
269
+ No need to modify core code!
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pylogue"
7
+ version = "0.1.0"
8
+ description = "A Chatbot UI build for Pydantic-AI agents"
9
+ readme = "README.rst"
10
+ authors = [
11
+ {name = "Yeshwanth Reddy", email = "yyeshr@gmail.com"}
12
+ ]
13
+ maintainers = [
14
+ {name = "Yeshwanth Reddy", email = "yyeshr@gmail.com"}
15
+ ]
16
+ classifiers = [
17
+
18
+ ]
19
+ license = {text = "MIT license"}
20
+ dependencies = [
21
+ "typer",
22
+ "nbdev",
23
+ "mkdocs-material>=9.6.18",
24
+ "mkdocs-mermaid2-plugin>=1.2.1",
25
+ "mkdocs-awesome-pages-plugin>=2.10.1",
26
+ "mkdocs-minify-plugin>=0.8.0",
27
+ "mkdocs-git-revision-date-localized-plugin>=1.4.7",
28
+ "pymdown-extensions>=10.16.1",
29
+ "python-fasthtml>=0.12.29",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "coverage", # testing
35
+ "mypy", # linting
36
+ "pytest", # testing
37
+ "ruff" # linting
38
+ ]
39
+
40
+ [project.urls]
41
+
42
+ bugs = "https://github.com/sizhky/pylogue/issues"
43
+ changelog = "https://github.com/sizhky/pylogue/blob/master/changelog.md"
44
+ homepage = "https://github.com/sizhky/pylogue"
45
+
46
+ [tool.setuptools]
47
+ package-dir = {"" = "src"}
48
+
49
+ [tool.setuptools.package-data]
50
+ "*" = ["*.*"]
51
+
52
+ [project.scripts]
53
+ pylogue = "pylogue:cli"
54
+
55
+ # Mypy
56
+ # ----
57
+
58
+ [tool.mypy]
59
+ files = "."
60
+
61
+ # Use strict defaults
62
+ strict = true
63
+ warn_unreachable = true
64
+ warn_no_return = true
65
+
66
+ [[tool.mypy.overrides]]
67
+ # Don't require test functions to include types
68
+ module = "tests.*"
69
+ allow_untyped_defs = true
70
+ disable_error_code = "attr-defined"
71
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ """Top-level package for Pylogue."""
2
+
3
+ __all__ = [
4
+ "__version__",
5
+ "__author__",
6
+ "__email__",
7
+ "cli",
8
+ "health",
9
+ ]
10
+
11
+ __author__ = """Yeshwanth Reddy"""
12
+ __email__ = "yyeshr@gmail.com"
13
+ __version__ = "0.1.0"
14
+
15
+ from .__pre_init__ import cli
16
+ from .health import *
@@ -0,0 +1,4 @@
1
+ """Console script for pylogue."""
2
+ import typer
3
+
4
+ cli = typer.Typer(name="pylogue", help="A Chatbot UI build for Pydantic-AI agents", no_args_is_help=True)