blue-assistant 4.9.1__tar.gz → 4.17.1__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.
Files changed (41) hide show
  1. {blue_assistant-4.9.1/blue_assistant.egg-info → blue_assistant-4.17.1}/PKG-INFO +2 -2
  2. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/README.md +1 -1
  3. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/chat.sh +1 -1
  4. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/__init__.py +1 -1
  5. blue_assistant-4.17.1/blue_assistant/chat/context.py +79 -0
  6. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/chat/functions.py +13 -2
  7. {blue_assistant-4.9.1 → blue_assistant-4.17.1/blue_assistant.egg-info}/PKG-INFO +2 -2
  8. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant.egg-info/SOURCES.txt +1 -0
  9. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/LICENSE +0 -0
  10. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/MANIFEST.in +0 -0
  11. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/abcli.sh +0 -0
  12. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/actions.sh +0 -0
  13. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/alias.sh +0 -0
  14. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  15. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/browse.sh +0 -0
  16. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  17. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/tests/chat.sh +0 -0
  18. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/tests/help.sh +0 -0
  19. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  20. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/README.py +0 -0
  21. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/__main__.py +0 -0
  22. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/chat/__init__.py +0 -0
  23. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/chat/__main__.py +0 -0
  24. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/config.env +0 -0
  25. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/env.py +0 -0
  26. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/functions.py +0 -0
  27. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/help/__init__.py +0 -0
  28. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/help/__main__.py +0 -0
  29. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/help/chat.py +0 -0
  30. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/help/functions.py +0 -0
  31. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/host.py +0 -0
  32. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/logger.py +0 -0
  33. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/sample.env +0 -0
  34. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant/urls.py +0 -0
  35. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  36. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant.egg-info/requires.txt +0 -0
  37. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/blue_assistant.egg-info/top_level.txt +0 -0
  38. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/pyproject.toml +0 -0
  39. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/requirements.txt +0 -0
  40. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/setup.cfg +0 -0
  41. {blue_assistant-4.9.1 → blue_assistant-4.17.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.9.1
3
+ Version: 4.17.1
4
4
  Summary: 🌀 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -62,4 +62,4 @@ graph LR
62
62
 
63
63
  [![pylint](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-assistant.svg)](https://pypi.org/project/blue-assistant/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-assistant)](https://pypistats.org/packages/blue-assistant)
64
64
 
65
- built by 🌀 [`blue_options-4.205.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌀 [`blue_assistant-4.9.1`](https://github.com/kamangir/blue-assistant).
65
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌀 [`blue_assistant-4.17.1`](https://github.com/kamangir/blue-assistant).
@@ -23,4 +23,4 @@ graph LR
23
23
 
24
24
  [![pylint](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-assistant.svg)](https://pypi.org/project/blue-assistant/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-assistant)](https://pypistats.org/packages/blue-assistant)
25
25
 
26
- built by 🌀 [`blue_options-4.205.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌀 [`blue_assistant-4.9.1`](https://github.com/kamangir/blue-assistant).
26
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌀 [`blue_assistant-4.17.1`](https://github.com/kamangir/blue-assistant).
@@ -7,7 +7,7 @@ function blue_assistant_chat() {
7
7
  local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun))
8
8
 
9
9
  local chat_options=$2
10
- local interactive=$(abcli_option_int "$options" interact 1)
10
+ local interactive=$(abcli_option_int "$chat_options" interact 1)
11
11
 
12
12
  local object_name=$(abcli_clarify_object $3 chat-$(abcli_string_timestamp))
13
13
  [[ "$do_download" == 1 ]] &&
@@ -4,7 +4,7 @@ ICON = "🌀"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.9.1"
7
+ VERSION = "4.17.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -0,0 +1,79 @@
1
+ from blue_objects.metadata import post_to_object, get_from_object
2
+ from blue_options.terminal.functions import hr
3
+
4
+ from blue_assistant import ICON
5
+ from blue_assistant.logger import logger
6
+
7
+
8
+ class ChatContext:
9
+ def __init__(
10
+ self,
11
+ object_name: str,
12
+ load_history: bool = True,
13
+ ):
14
+ self.ended: bool = False
15
+
16
+ self.object_name = object_name
17
+
18
+ self.history = (
19
+ get_from_object(
20
+ self.object_name,
21
+ "history",
22
+ [],
23
+ )
24
+ if load_history
25
+ else []
26
+ )
27
+
28
+ def chat(
29
+ self,
30
+ interactive: bool = True,
31
+ verbose: bool = False,
32
+ ) -> bool:
33
+ logger.info('Type in "help" for help.')
34
+
35
+ while True:
36
+ prompt = input(f"{ICON} > ") if interactive else ""
37
+
38
+ if not self.process_prompt(prompt):
39
+ return False
40
+
41
+ if self.ended or not interactive:
42
+ break
43
+
44
+ print(hr(width=21))
45
+
46
+ return True
47
+
48
+ def process_prompt(self, prompt: str) -> bool:
49
+ if prompt in ["help", "?", ""]:
50
+ return self.show_help()
51
+
52
+ if prompt in ["quit", "exit", "q"]:
53
+ self.ended = True
54
+ return True
55
+
56
+ logger.info(f"🪄 {prompt}")
57
+
58
+ self.history.append(
59
+ {
60
+ "prompt": prompt,
61
+ }
62
+ )
63
+
64
+ return True
65
+
66
+ def save(self) -> bool:
67
+ return post_to_object(
68
+ self.object_name,
69
+ "history",
70
+ self.history,
71
+ )
72
+
73
+ def show_help(self) -> bool:
74
+ for command, description in {
75
+ "help": "show this help.",
76
+ "quit": "quit the chat.",
77
+ }.items():
78
+ logger.info(f"{command}: {description}")
79
+ return True
@@ -1,6 +1,7 @@
1
1
  from blueness import module
2
2
 
3
3
  from blue_assistant import NAME
4
+ from blue_assistant.chat.context import ChatContext
4
5
  from blue_assistant.logger import logger
5
6
 
6
7
 
@@ -11,6 +12,7 @@ def chat(
11
12
  object_name: str,
12
13
  interactive: bool = True,
13
14
  verbose: bool = False,
15
+ load_history: bool = True,
14
16
  ) -> bool:
15
17
  logger.info(
16
18
  "{}.chat -{}> {}".format(
@@ -20,6 +22,15 @@ def chat(
20
22
  )
21
23
  )
22
24
 
23
- logger.info("🪄")
25
+ context = ChatContext(
26
+ object_name,
27
+ load_history=load_history,
28
+ )
29
+
30
+ if not context.chat(
31
+ interactive=interactive,
32
+ verbose=verbose,
33
+ ):
34
+ return False
24
35
 
25
- return True
36
+ return context.save()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.9.1
3
+ Version: 4.17.1
4
4
  Summary: 🌀 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -62,4 +62,4 @@ graph LR
62
62
 
63
63
  [![pylint](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-assistant.svg)](https://pypi.org/project/blue-assistant/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-assistant)](https://pypistats.org/packages/blue-assistant)
64
64
 
65
- built by 🌀 [`blue_options-4.205.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌀 [`blue_assistant-4.9.1`](https://github.com/kamangir/blue-assistant).
65
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌀 [`blue_assistant-4.17.1`](https://github.com/kamangir/blue-assistant).
@@ -31,6 +31,7 @@ blue_assistant/.abcli/tests/help.sh
31
31
  blue_assistant/.abcli/tests/version.sh
32
32
  blue_assistant/chat/__init__.py
33
33
  blue_assistant/chat/__main__.py
34
+ blue_assistant/chat/context.py
34
35
  blue_assistant/chat/functions.py
35
36
  blue_assistant/help/__init__.py
36
37
  blue_assistant/help/__main__.py
File without changes
File without changes