jehoctor-rag-demo 0.1.1.dev1__py3-none-any.whl → 0.2.1__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.
@@ -0,0 +1,110 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from textual.widgets import Input
6
+
7
+ if TYPE_CHECKING:
8
+ from collections.abc import Iterable
9
+
10
+ from rich.console import RenderableType
11
+ from rich.highlighter import Highlighter
12
+ from textual.events import Key
13
+ from textual.suggester import Suggester
14
+ from textual.validation import Validator
15
+ from textual.widget import Widget
16
+ from textual.widgets._input import InputType, InputValidationOn
17
+
18
+
19
+ class EscapableInput(Input):
20
+ """An input widget that deselects itself when the user presses escape.
21
+
22
+ Inherits all properties and methods from the :class:`textual.widgets.Input` class.
23
+ """
24
+
25
+ def __init__( # noqa: PLR0913
26
+ self,
27
+ value: str | None = None,
28
+ placeholder: str = "",
29
+ highlighter: Highlighter | None = None,
30
+ password: bool = False, # noqa: FBT001, FBT002
31
+ *,
32
+ restrict: str | None = None,
33
+ type: InputType = "text", # noqa: A002
34
+ max_length: int = 0,
35
+ suggester: Suggester | None = None,
36
+ validators: Validator | Iterable[Validator] | None = None,
37
+ validate_on: Iterable[InputValidationOn] | None = None,
38
+ valid_empty: bool = False,
39
+ select_on_focus: bool = True,
40
+ name: str | None = None,
41
+ id: str | None = None, # noqa: A002
42
+ classes: str | None = None,
43
+ disabled: bool = False,
44
+ tooltip: RenderableType | None = None,
45
+ compact: bool = False,
46
+ focus_on_escape: Widget | None = None,
47
+ ) -> None:
48
+ """Initialise the `EscapableInput` widget.
49
+
50
+ Args:
51
+ value: An optional default value for the input.
52
+ placeholder: Optional placeholder text for the input.
53
+ highlighter: An optional highlighter for the input.
54
+ password: Flag to say if the field should obfuscate its content.
55
+ restrict: A regex to restrict character inputs.
56
+ type: The type of the input.
57
+ max_length: The maximum length of the input, or 0 for no maximum length.
58
+ suggester: [`Suggester`][textual.suggester.Suggester] associated with this
59
+ input instance.
60
+ validators: An iterable of validators that the Input value will be checked against.
61
+ validate_on: Zero or more of the values "blur", "changed", and "submitted",
62
+ which determine when to do input validation. The default is to do
63
+ validation for all messages.
64
+ valid_empty: Empty values are valid.
65
+ select_on_focus: Whether to select all text on focus.
66
+ name: Optional name for the input widget.
67
+ id: Optional ID for the widget.
68
+ classes: Optional initial classes for the widget.
69
+ disabled: Whether the input is disabled or not.
70
+ tooltip: Optional tooltip.
71
+ compact: Enable compact style (without borders).
72
+ focus_on_escape: An optional widget to focus on when escape is pressed. Defaults to `None`.
73
+ """
74
+ super().__init__(
75
+ value=value,
76
+ placeholder=placeholder,
77
+ highlighter=highlighter,
78
+ password=password,
79
+ restrict=restrict,
80
+ type=type,
81
+ max_length=max_length,
82
+ suggester=suggester,
83
+ validators=validators,
84
+ validate_on=validate_on,
85
+ valid_empty=valid_empty,
86
+ select_on_focus=select_on_focus,
87
+ name=name,
88
+ id=id,
89
+ classes=classes,
90
+ disabled=disabled,
91
+ tooltip=tooltip,
92
+ compact=compact,
93
+ )
94
+ self.focus_on_escape = focus_on_escape
95
+
96
+ def on_key(self, event: Key) -> None:
97
+ """Deselect the input if the event is the escape key.
98
+
99
+ This method overrides the base :meth:`textual.widgets.Input.on_key` implementation.
100
+
101
+ Args:
102
+ event (Key): Event details, including the key pressed.
103
+ """
104
+ if event.key == "escape":
105
+ if self.focus_on_escape is not None:
106
+ self.focus_on_escape.focus()
107
+ else:
108
+ self.blur()
109
+ event.prevent_default()
110
+ event.stop()
@@ -1,11 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: jehoctor-rag-demo
3
- Version: 0.1.1.dev1
4
- Summary: Chat with Wikipedia
5
- Author: James Hoctor
6
- Author-email: James Hoctor <JEHoctor@protonmail.com>
7
- Requires-Python: >=3.13
8
- Description-Content-Type: text/markdown
9
-
10
- # RAG-demo
11
- Chat with Wikipedia
@@ -1,6 +0,0 @@
1
- rag_demo/__init__.py,sha256=STIqC0dNmRNCbDeEDuODLXSsOmuQsB5MC9Ii3el0TDk,54
2
- rag_demo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- jehoctor_rag_demo-0.1.1.dev1.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
4
- jehoctor_rag_demo-0.1.1.dev1.dist-info/entry_points.txt,sha256=3XjzSTMUH0sKTfuLk5yj8ilz0M-SF4_UuZAu-MVH8qM,40
5
- jehoctor_rag_demo-0.1.1.dev1.dist-info/METADATA,sha256=drDoEBvOOWd5XW3DCedSPqLq3HXkcJquTJ0A4HLi1EU,265
6
- jehoctor_rag_demo-0.1.1.dev1.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- chat = rag_demo:main
3
-