django-spire 0.16.12__py3-none-any.whl → 0.16.13__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.
Files changed (140) hide show
  1. django_spire/ai/admin.py +3 -1
  2. django_spire/ai/apps.py +2 -0
  3. django_spire/ai/chat/admin.py +15 -9
  4. django_spire/ai/chat/apps.py +4 -1
  5. django_spire/ai/chat/auth/controller.py +3 -1
  6. django_spire/ai/chat/choices.py +2 -0
  7. django_spire/ai/chat/intelligence/maps/intent_llm_map.py +8 -5
  8. django_spire/ai/chat/intelligence/prompts.py +4 -2
  9. django_spire/ai/chat/intelligence/workflows/chat_workflow.py +27 -28
  10. django_spire/ai/chat/message_intel.py +7 -4
  11. django_spire/ai/chat/models.py +8 -9
  12. django_spire/ai/chat/querysets.py +3 -1
  13. django_spire/ai/chat/responses.py +19 -10
  14. django_spire/ai/chat/tools.py +20 -15
  15. django_spire/ai/chat/urls/message_urls.py +2 -1
  16. django_spire/ai/chat/urls/page_urls.py +1 -0
  17. django_spire/ai/chat/views/message_request_views.py +2 -0
  18. django_spire/ai/chat/views/message_response_views.py +4 -4
  19. django_spire/ai/chat/views/message_views.py +2 -0
  20. django_spire/ai/chat/views/page_views.py +7 -2
  21. django_spire/ai/chat/views/template_views.py +2 -0
  22. django_spire/ai/decorators.py +13 -7
  23. django_spire/ai/mixins.py +4 -2
  24. django_spire/ai/models.py +7 -2
  25. django_spire/ai/prompt/bots.py +14 -32
  26. django_spire/ai/prompt/intel.py +1 -1
  27. django_spire/ai/prompt/prompts.py +7 -1
  28. django_spire/ai/prompt/system/bots.py +42 -75
  29. django_spire/ai/prompt/system/intel.py +5 -4
  30. django_spire/ai/prompt/system/prompts.py +5 -1
  31. django_spire/ai/prompt/system/system_prompt_cli.py +15 -9
  32. django_spire/ai/prompt/tests/test_bots.py +14 -11
  33. django_spire/ai/prompt/text_to_prompt_cli.py +5 -2
  34. django_spire/ai/prompt/tuning/bot_tuning_cli.py +14 -13
  35. django_spire/ai/prompt/tuning/bots.py +68 -116
  36. django_spire/ai/prompt/tuning/intel.py +1 -1
  37. django_spire/ai/prompt/tuning/mixins.py +2 -0
  38. django_spire/ai/prompt/tuning/prompt_tuning_cli.py +8 -8
  39. django_spire/ai/prompt/tuning/prompts.py +4 -2
  40. django_spire/ai/sms/admin.py +3 -1
  41. django_spire/ai/sms/apps.py +2 -0
  42. django_spire/ai/sms/decorators.py +2 -0
  43. django_spire/ai/sms/intel.py +4 -2
  44. django_spire/ai/sms/intelligence/workflows/sms_conversation_workflow.py +8 -8
  45. django_spire/ai/sms/models.py +16 -14
  46. django_spire/ai/sms/querysets.py +4 -1
  47. django_spire/ai/sms/tools.py +18 -16
  48. django_spire/ai/sms/urls.py +1 -1
  49. django_spire/ai/sms/views.py +2 -0
  50. django_spire/ai/tests/test_ai.py +3 -5
  51. django_spire/ai/urls.py +1 -0
  52. django_spire/consts.py +1 -1
  53. django_spire/contrib/seeding/field/django/seeder.py +6 -4
  54. django_spire/contrib/seeding/field/llm.py +1 -2
  55. django_spire/contrib/seeding/intelligence/bots/field_seeding_bots.py +7 -8
  56. django_spire/contrib/seeding/intelligence/bots/seeder_generator_bot.py +15 -16
  57. django_spire/contrib/seeding/intelligence/intel.py +1 -1
  58. django_spire/contrib/seeding/intelligence/prompts/factory.py +5 -7
  59. django_spire/contrib/seeding/intelligence/prompts/foreign_key_selection_prompt.py +3 -5
  60. django_spire/contrib/seeding/intelligence/prompts/generate_django_model_seeder_prompts.py +1 -2
  61. django_spire/contrib/seeding/intelligence/prompts/generic_relationship_selection_prompt.py +3 -5
  62. django_spire/contrib/seeding/intelligence/prompts/hierarchical_selection_prompt.py +1 -1
  63. django_spire/contrib/seeding/intelligence/prompts/model_field_choices_prompt.py +3 -3
  64. django_spire/contrib/seeding/intelligence/prompts/negation_prompt.py +1 -1
  65. django_spire/contrib/seeding/intelligence/prompts/objective_prompt.py +2 -4
  66. django_spire/contrib/seeding/management/commands/seeding.py +5 -2
  67. django_spire/contrib/seeding/model/base.py +12 -10
  68. django_spire/contrib/seeding/model/django/seeder.py +13 -10
  69. django_spire/contrib/seeding/tests/test_seeding.py +1 -1
  70. django_spire/knowledge/admin.py +2 -0
  71. django_spire/knowledge/apps.py +2 -0
  72. django_spire/knowledge/auth/controller.py +2 -0
  73. django_spire/knowledge/collection/admin.py +3 -0
  74. django_spire/knowledge/collection/forms.py +2 -0
  75. django_spire/knowledge/collection/models.py +4 -0
  76. django_spire/knowledge/collection/querysets.py +3 -3
  77. django_spire/knowledge/collection/seeding/seed.py +2 -0
  78. django_spire/knowledge/collection/tests/factories.py +2 -0
  79. django_spire/knowledge/collection/tests/test_services/test_transformation_service.py +2 -0
  80. django_spire/knowledge/collection/tests/test_urls/test_form_urls.py +2 -0
  81. django_spire/knowledge/collection/tests/test_urls/test_json_urls.py +2 -0
  82. django_spire/knowledge/collection/tests/test_urls/test_page_urls.py +2 -0
  83. django_spire/knowledge/collection/views/json_views.py +2 -0
  84. django_spire/knowledge/collection/views/page_views.py +2 -0
  85. django_spire/knowledge/context_processors.py +2 -0
  86. django_spire/knowledge/entry/services/tool_service.py +1 -0
  87. django_spire/knowledge/entry/services/transformation_services.py +0 -1
  88. django_spire/knowledge/entry/tests/factories.py +3 -0
  89. django_spire/knowledge/entry/tests/test_urls/test_form_urls.py +2 -0
  90. django_spire/knowledge/entry/tests/test_urls/test_json_urls.py +2 -0
  91. django_spire/knowledge/entry/tests/test_urls/test_page_urls.py +2 -0
  92. django_spire/knowledge/entry/urls/form_urls.py +1 -0
  93. django_spire/knowledge/entry/urls/json_urls.py +1 -0
  94. django_spire/knowledge/entry/urls/page_urls.py +1 -0
  95. django_spire/knowledge/entry/urls/template_urls.py +1 -0
  96. django_spire/knowledge/entry/version/admin.py +2 -0
  97. django_spire/knowledge/entry/version/block/admin.py +2 -0
  98. django_spire/knowledge/entry/version/block/blocks/heading_block.py +2 -0
  99. django_spire/knowledge/entry/version/block/blocks/sub_heading_block.py +2 -0
  100. django_spire/knowledge/entry/version/block/blocks/text_block.py +2 -0
  101. django_spire/knowledge/entry/version/block/maps.py +2 -0
  102. django_spire/knowledge/entry/version/block/models.py +2 -0
  103. django_spire/knowledge/entry/version/block/tests/factories.py +2 -0
  104. django_spire/knowledge/entry/version/block/tests/test_urls/test_json_urls.py +2 -0
  105. django_spire/knowledge/entry/version/block/views/json_views.py +2 -0
  106. django_spire/knowledge/entry/version/intelligence/bots/markdown_format_llm_bot.py +12 -9
  107. django_spire/knowledge/entry/version/maps.py +2 -0
  108. django_spire/knowledge/entry/version/models.py +2 -0
  109. django_spire/knowledge/entry/version/querysets.py +2 -0
  110. django_spire/knowledge/entry/version/seeding/seeder.py +1 -0
  111. django_spire/knowledge/entry/version/tests/factories.py +2 -0
  112. django_spire/knowledge/entry/version/tests/test_converters/test_docx_converter.py +3 -0
  113. django_spire/knowledge/entry/version/tests/test_urls/test_form_urls.py +2 -0
  114. django_spire/knowledge/entry/version/tests/test_urls/test_json_urls.py +2 -0
  115. django_spire/knowledge/entry/version/tests/test_urls/test_page_urls.py +2 -0
  116. django_spire/knowledge/entry/version/urls/form_urls.py +1 -0
  117. django_spire/knowledge/entry/version/urls/json_urls.py +1 -0
  118. django_spire/knowledge/entry/version/urls/page_urls.py +1 -0
  119. django_spire/knowledge/entry/version/urls/redirect_urls.py +1 -0
  120. django_spire/knowledge/entry/version/views/form_views.py +2 -0
  121. django_spire/knowledge/entry/version/views/json_views.py +2 -0
  122. django_spire/knowledge/entry/version/views/page_views.py +2 -0
  123. django_spire/knowledge/entry/version/views/redirect_views.py +2 -0
  124. django_spire/knowledge/exceptions.py +2 -0
  125. django_spire/knowledge/intelligence/bots/entry_search_llm_bot.py +5 -16
  126. django_spire/knowledge/intelligence/intel/collection_intel.py +3 -1
  127. django_spire/knowledge/intelligence/intel/entry_intel.py +3 -3
  128. django_spire/knowledge/intelligence/intel/message_intel.py +2 -0
  129. django_spire/knowledge/intelligence/maps/collection_map.py +9 -10
  130. django_spire/knowledge/intelligence/maps/entry_map.py +8 -9
  131. django_spire/knowledge/intelligence/workflows/knowledge_workflow.py +8 -6
  132. django_spire/knowledge/models.py +2 -0
  133. django_spire/knowledge/seeding/seed.py +2 -0
  134. django_spire/knowledge/templatetags/spire_knowledge_tags.py +3 -0
  135. django_spire/knowledge/urls/__init__.py +1 -0
  136. {django_spire-0.16.12.dist-info → django_spire-0.16.13.dist-info}/METADATA +5 -4
  137. {django_spire-0.16.12.dist-info → django_spire-0.16.13.dist-info}/RECORD +140 -140
  138. {django_spire-0.16.12.dist-info → django_spire-0.16.13.dist-info}/WHEEL +0 -0
  139. {django_spire-0.16.12.dist-info → django_spire-0.16.13.dist-info}/licenses/LICENSE.md +0 -0
  140. {django_spire-0.16.12.dist-info → django_spire-0.16.13.dist-info}/top_level.txt +0 -0
@@ -1,44 +1,26 @@
1
- from pathlib import Path
1
+ from __future__ import annotations
2
2
 
3
- from dandy.llm import BaseLlmBot
4
- from django.conf import settings
3
+ from dandy import Bot
5
4
 
6
5
  from django_spire.ai.prompt import prompts
7
6
  from django_spire.ai.prompt import intel
8
7
 
9
8
 
9
+ class DandyPythonPromptBot(Bot):
10
+ llm_role = prompts.dandy_prompt_python_file_instruction_bot_prompt()
10
11
 
11
- class DandyPythonPromptBot(BaseLlmBot):
12
- instructions_prompt = prompts.dandy_prompt_python_file_instruction_bot_prompt()
13
- intel_class = intel.DandyPromptPythonFileIntel
14
-
15
- @classmethod
16
- def process(
17
- cls,
18
- prompt: str,
19
-
20
- ) -> intel.DandyPromptPythonFileIntel:
21
- """
22
- Takes in an enhanced prompt and turn it into a python file that uses the dandy library.
23
- """
24
- return cls.process_prompt_to_intel(
25
- prompt=prompts.dandy_prompt_python_file_input_prompt(prompt)
12
+ def process(self, prompt: str) -> intel.DandyPromptPythonFileIntel:
13
+ return self.llm.prompt_to_intel(
14
+ prompt=prompts.dandy_prompt_python_file_input_prompt(prompt),
15
+ intel_class=intel.DandyPromptPythonFileIntel
26
16
  )
27
17
 
28
18
 
29
- class TextToMarkdownPromptBot(BaseLlmBot):
30
- instructions_prompt = prompts.text_to_markdown_instruction_bot_prompt()
31
- intel_class = intel.TextToMarkdownIntel
32
-
33
- @classmethod
34
- def process(
35
- cls,
36
- text: str,
19
+ class TextToMarkdownPromptBot(Bot):
20
+ llm_role = prompts.text_to_markdown_instruction_bot_prompt()
37
21
 
38
- ) -> intel.TextToMarkdownIntel:
39
- """
40
- Takes in user text and converts it to properly formatted Markdown.
41
- """
42
- return cls.process_prompt_to_intel(
43
- prompt=prompts.text_to_markdown_input_prompt(text)
22
+ def process(self, text: str) -> intel.TextToMarkdownIntel:
23
+ return self.llm.prompt_to_intel(
24
+ prompt=prompts.text_to_markdown_input_prompt(text),
25
+ intel_class=intel.TextToMarkdownIntel
44
26
  )
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from pathlib import Path
4
4
 
5
- from dandy.intel import BaseIntel
5
+ from dandy import BaseIntel
6
6
  from django.conf import settings
7
7
 
8
8
  _MARKDOWN_OUTPUT_PATH = Path(settings.BASE_DIR, '.markdown')
@@ -1,12 +1,15 @@
1
+ from __future__ import annotations
2
+
1
3
  from pathlib import Path
2
4
 
3
- from dandy.llm import Prompt
5
+ from dandy import Prompt
4
6
 
5
7
 
6
8
  _RELATIVE_BASE_DIR = Path(Path(__file__).parent.parent.parent.parent.resolve())
7
9
  dandy_prompting_path = Path(_RELATIVE_BASE_DIR, '.venv/Lib/site-packages/dandy/llm/prompt/prompt.py')
8
10
  dandy_tutorial_path = Path(_RELATIVE_BASE_DIR, 'django_spire/ai/prompt/docs/prompt_tutorial.md')
9
11
 
12
+
10
13
  def dandy_prompt_python_file_instruction_bot_prompt():
11
14
  return (
12
15
  Prompt()
@@ -37,6 +40,7 @@ def dandy_prompt_python_file_instruction_bot_prompt():
37
40
  .file(dandy_prompting_path)
38
41
  )
39
42
 
43
+
40
44
  def text_to_markdown_instruction_bot_prompt():
41
45
  return (
42
46
  Prompt()
@@ -67,6 +71,7 @@ def text_to_markdown_instruction_bot_prompt():
67
71
  .text('Return the converted Markdown content and a suitable filename with .md extension.')
68
72
  )
69
73
 
74
+
70
75
  def dandy_prompt_python_file_input_prompt(user_prompt: str):
71
76
  return (
72
77
  Prompt()
@@ -74,6 +79,7 @@ def dandy_prompt_python_file_input_prompt(user_prompt: str):
74
79
  .text(user_prompt)
75
80
  )
76
81
 
82
+
77
83
  def text_to_markdown_input_prompt(user_text: str):
78
84
  return (
79
85
  Prompt()
@@ -1,102 +1,69 @@
1
- from dandy.llm import BaseLlmBot, LlmConfigOptions
1
+ from __future__ import annotations
2
+
3
+ from dandy import Bot, LlmConfigOptions
2
4
 
3
5
  from django_spire.ai.prompt.system import prompts
4
6
  from django_spire.ai.prompt.system import intel
5
7
  from django_spire.ai.prompt.system.intel import SystemPromptIntel
6
8
 
7
9
 
8
- class RoleSystemPromptBot(BaseLlmBot):
9
- instructions_prompt = prompts.role_bot_prompt()
10
- intel_class = intel.SystemPromptResultIntel
11
- config_options = LlmConfigOptions(
12
- temperature=0.5
13
- )
14
-
15
- @classmethod
16
- def process(
17
- cls,
18
- user_story: str
19
-
20
- ) -> intel.SystemPromptResultIntel:
10
+ class RoleSystemPromptBot(Bot):
11
+ llm_role = prompts.role_bot_prompt()
12
+ llm_config_options = LlmConfigOptions(temperature=0.5)
21
13
 
22
- return cls.process_prompt_to_intel(
23
- prompt=prompts.system_user_input_prompt(user_story)
14
+ def process(self, user_story: str) -> intel.SystemPromptResultIntel:
15
+ return self.llm.prompt_to_intel(
16
+ prompt=prompts.system_user_input_prompt(user_story),
17
+ intel_class=intel.SystemPromptResultIntel
24
18
  )
25
19
 
26
20
 
27
- class TaskSystemPromptBot(BaseLlmBot):
28
- instructions_prompt = prompts.task_bot_prompt()
29
- intel_class = intel.SystemPromptResultIntel
30
- config_options = LlmConfigOptions(
31
- temperature=0.5
32
- )
21
+ class TaskSystemPromptBot(Bot):
22
+ llm_role = prompts.task_bot_prompt()
23
+ llm_config_options = LlmConfigOptions(temperature=0.5)
33
24
 
34
- @classmethod
35
- def process(
36
- cls,
37
- user_story: str
38
-
39
- ) -> intel.SystemPromptResultIntel:
40
-
41
- return cls.process_prompt_to_intel(
42
- prompt=prompts.system_user_input_prompt(user_story)
25
+ def process(self, user_story: str) -> intel.SystemPromptResultIntel:
26
+ return self.llm.prompt_to_intel(
27
+ prompt=prompts.system_user_input_prompt(user_story),
28
+ intel_class=intel.SystemPromptResultIntel
43
29
  )
44
30
 
45
31
 
46
- class GuidelinesSystemPromptBot(BaseLlmBot):
47
- instructions_prompt = prompts.guidelines_bot_prompt()
48
- intel_class = intel.SystemPromptResultIntel
49
- config_options = LlmConfigOptions(
50
- temperature=0.2
51
- )
52
-
53
- @classmethod
54
- def process(
55
- cls,
56
- user_story: str
32
+ class GuidelinesSystemPromptBot(Bot):
33
+ llm_role = prompts.guidelines_bot_prompt()
34
+ llm_config_options = LlmConfigOptions(temperature=0.2)
57
35
 
58
- ) -> intel.SystemPromptResultIntel:
59
-
60
- return cls.process_prompt_to_intel(
61
- prompt=prompts.system_user_input_prompt(user_story)
36
+ def process(self, user_story: str) -> intel.SystemPromptResultIntel:
37
+ return self.llm.prompt_to_intel(
38
+ prompt=prompts.system_user_input_prompt(user_story),
39
+ intel_class=intel.SystemPromptResultIntel
62
40
  )
63
41
 
64
42
 
65
- class OutputFormatSystemPromptBot(BaseLlmBot):
66
- instructions_prompt = prompts.output_format_bot_prompt()
67
- intel_class = intel.SystemPromptResultIntel
68
- config_options = LlmConfigOptions(
69
- temperature=0.5
70
- )
71
-
72
- @classmethod
73
- def process(
74
- cls,
75
- user_story: str
76
-
77
- ) -> intel.SystemPromptResultIntel:
43
+ class OutputFormatSystemPromptBot(Bot):
44
+ llm_role = prompts.output_format_bot_prompt()
45
+ llm_config_options = LlmConfigOptions(temperature=0.5)
78
46
 
79
- return cls.process_prompt_to_intel(
80
- prompt=prompts.system_user_input_prompt(user_story)
47
+ def process(self, user_story: str) -> intel.SystemPromptResultIntel:
48
+ return self.llm.prompt_to_intel(
49
+ prompt=prompts.system_user_input_prompt(user_story),
50
+ intel_class=intel.SystemPromptResultIntel
81
51
  )
82
52
 
83
53
 
84
- class SystemPromptBot(BaseLlmBot):
85
- instructions_prompt = prompts.system_prompt_instruction_bot_prompt()
86
- intel_class = intel.SystemPromptIntel
87
-
88
-
89
- @classmethod
90
- def process(
91
- cls,
92
- user_story: str
54
+ class SystemPromptBot(Bot):
55
+ llm_role = prompts.system_prompt_instruction_bot_prompt()
93
56
 
94
- ) -> intel.SystemPromptIntel:
57
+ def process(self, user_story: str) -> intel.SystemPromptIntel:
58
+ role_bot = RoleSystemPromptBot()
59
+ task_bot = TaskSystemPromptBot()
60
+ guidelines_bot = GuidelinesSystemPromptBot()
61
+ output_format_bot = OutputFormatSystemPromptBot()
95
62
 
96
- role_future = RoleSystemPromptBot.process_to_future(user_story)
97
- task_future = TaskSystemPromptBot.process_to_future(user_story)
98
- guidelines_future = GuidelinesSystemPromptBot.process_to_future(user_story)
99
- output_format_future = OutputFormatSystemPromptBot.process_to_future(user_story)
63
+ role_future = role_bot.process_to_future(user_story)
64
+ task_future = task_bot.process_to_future(user_story)
65
+ guidelines_future = guidelines_bot.process_to_future(user_story)
66
+ output_format_future = output_format_bot.process_to_future(user_story)
100
67
 
101
68
  role = role_future.result
102
69
  task = task_future.result
@@ -1,9 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
- from dandy.intel import BaseIntel
3
+ from dandy import BaseIntel
4
4
 
5
5
  from django_spire.ai.prompt.bots import DandyPythonPromptBot, TextToMarkdownPromptBot
6
- from django_spire.knowledge.entry.version.intelligence.bots.markdown_format_llm_bot import MarkdownFormatLlmBot
7
6
 
8
7
 
9
8
  class SystemPromptResultIntel(BaseIntel):
@@ -17,10 +16,12 @@ class SystemPromptIntel(BaseIntel):
17
16
  output_format: str | None
18
17
 
19
18
  def to_markdown(self):
20
- return TextToMarkdownPromptBot.process(self.to_string())
19
+ bot = TextToMarkdownPromptBot()
20
+ return bot.process(self.to_string())
21
21
 
22
22
  def to_python(self):
23
- return DandyPythonPromptBot.process(self.to_string())
23
+ bot = DandyPythonPromptBot()
24
+ return bot.process(self.to_string())
24
25
 
25
26
  def to_string(self):
26
27
  prompt = (
@@ -1,4 +1,7 @@
1
- from dandy.llm import Prompt
1
+ from __future__ import annotations
2
+
3
+ from dandy import Prompt
4
+
2
5
 
3
6
  def role_bot_prompt():
4
7
  return (
@@ -142,6 +145,7 @@ def system_prompt_instruction_bot_prompt():
142
145
  .text('Your response should be a complete system prompt that addresses the user\'s specific needs, ensuring it is structured as a system prompt for an LLM interaction. Extract the relevant information from the user\'s input to create this system prompt.')
143
146
  )
144
147
 
148
+
145
149
  def system_user_input_prompt(user_input: str):
146
150
  return (
147
151
  Prompt()
@@ -1,16 +1,23 @@
1
- from django_spire.ai.prompt.tuning.bots import SimplePromptTuningBot
2
- from dandy.recorder import Recorder
1
+ from __future__ import annotations
2
+
3
+ from dandy import Recorder
3
4
 
4
5
  from django_spire.ai.prompt.bots import DandyPythonPromptBot
5
6
  from django_spire.ai.prompt.system import bots
7
+ from django_spire.ai.prompt.tuning.bots import SimplePromptTuningBot
8
+
6
9
 
7
- def create_system_prompt_cli():
10
+ def create_system_prompt_cli() -> None:
8
11
  Recorder.start_recording(recording_name='system_prompt')
9
12
 
10
13
  user_story = input('Enter your user story: ')
11
- prompt = bots.SystemPromptBot.process(user_story)
14
+
15
+ bot = bots.SystemPromptBot()
16
+ prompt = bot.process(user_story)
12
17
  print(prompt)
13
18
 
19
+ tuning_bot = SimplePromptTuningBot()
20
+
14
21
  while True:
15
22
  print("\nEnter your feedback (or type 'stop' to finish):")
16
23
  feedback = input()
@@ -19,10 +26,7 @@ def create_system_prompt_cli():
19
26
  break
20
27
 
21
28
  print('Creating new prompt from feedback.....')
22
- new_prompt = (
23
- SimplePromptTuningBot()
24
- .process(prompt, feedback)
25
- )
29
+ new_prompt = tuning_bot.process(prompt, feedback)
26
30
  print('----------------------------------------------------')
27
31
  print()
28
32
  print(new_prompt.prompt)
@@ -33,5 +37,7 @@ def create_system_prompt_cli():
33
37
  Recorder.to_html_file(recording_name='system_prompt')
34
38
 
35
39
  prompt_file = input('Do you want to create a Prompt File y/n?')
40
+
36
41
  if prompt_file.strip().lower() == 'y':
37
- DandyPythonPromptBot().process(prompt)
42
+ python_bot = DandyPythonPromptBot()
43
+ python_bot.process(prompt)
@@ -1,9 +1,10 @@
1
+ from __future__ import annotations
2
+
1
3
  from django_spire.ai.prompt.system import bots
2
4
  from django_spire.core.tests.test_cases import BaseTestCase
3
5
 
4
6
 
5
7
  class PromptBotTestCase(BaseTestCase):
6
-
7
8
  def test_system_prompt_system_prompt(self):
8
9
  ISSUE_PROMPT = (
9
10
  "I am using jira to plan developer workloads And I want to be able to build very clear issues that"
@@ -13,16 +14,18 @@ class PromptBotTestCase(BaseTestCase):
13
14
  "before they get into the details of it "
14
15
  )
15
16
 
16
- role_bot = bots.RoleSystemPromptBot.process(ISSUE_PROMPT)
17
- self.assertIsNotNone(role_bot)
18
-
19
- task_bot = bots.TaskSystemPromptBot.process(ISSUE_PROMPT)
20
- self.assertIsNotNone(task_bot)
17
+ role_bot = bots.RoleSystemPromptBot()
18
+ role_result = role_bot.process(ISSUE_PROMPT)
19
+ self.assertIsNotNone(role_result)
21
20
 
21
+ task_bot = bots.TaskSystemPromptBot()
22
+ task_result = task_bot.process(ISSUE_PROMPT)
23
+ self.assertIsNotNone(task_result)
22
24
 
23
- guidelines_bot = bots.GuidelinesSystemPromptBot.process(ISSUE_PROMPT)
24
- self.assertIsNotNone(guidelines_bot)
25
+ guidelines_bot = bots.GuidelinesSystemPromptBot()
26
+ guidelines_result = guidelines_bot.process(ISSUE_PROMPT)
27
+ self.assertIsNotNone(guidelines_result)
25
28
 
26
- output_format_bot = bots.OutputFormatSystemPromptBot.process(ISSUE_PROMPT)
27
- self.assertIsNotNone(output_format_bot)
28
-
29
+ output_format_bot = bots.OutputFormatSystemPromptBot()
30
+ output_format_result = output_format_bot.process(ISSUE_PROMPT)
31
+ self.assertIsNotNone(output_format_result)
@@ -1,5 +1,8 @@
1
+ from __future__ import annotations
2
+
1
3
  from django_spire.ai.prompt.bots import DandyPythonPromptBot
2
4
 
5
+
3
6
  def text_to_prompt_cli(prompt: str):
4
- prompt = prompt
5
- DandyPythonPromptBot().process(prompt)
7
+ bot = DandyPythonPromptBot()
8
+ bot.process(prompt)
@@ -1,22 +1,24 @@
1
- from typing import Type
1
+ from __future__ import annotations
2
2
 
3
- from dandy.llm import BaseLlmBot, Prompt
4
- from dandy.recorder import Recorder
3
+ from dandy import Bot, Prompt, Recorder
5
4
 
6
5
  from django_spire.ai.prompt.bots import DandyPythonPromptBot
7
6
  from django_spire.ai.prompt.tuning.bots import SimplePromptTuningBot
8
7
 
9
8
 
10
- def bot_tuning_cli(bot: Type[BaseLlmBot], **bot_parmas):
9
+ def bot_tuning_cli(bot_class: type[Bot], **bot_params):
11
10
  Recorder.start_recording(recording_name='prompt_tuning')
12
11
 
13
- tuned_prompt = bot.instructions_prompt
12
+ bot = bot_class()
13
+ tuned_prompt = bot.llm_role
14
14
  print(tuned_prompt)
15
- bot_tuning = bot.process(**bot_parmas)
15
+ bot_tuning = bot.process(**bot_params)
16
16
  print(bot_tuning)
17
17
 
18
18
  print('----------------------------------------------------')
19
19
 
20
+ tuning_bot = SimplePromptTuningBot()
21
+
20
22
  while True:
21
23
  print("\nEnter your feedback (or type 'stop' to finish):")
22
24
  feedback = input()
@@ -26,10 +28,7 @@ def bot_tuning_cli(bot: Type[BaseLlmBot], **bot_parmas):
26
28
 
27
29
  print('Attempting to tune prompt.....')
28
30
 
29
- new_prompt = (
30
- SimplePromptTuningBot()
31
- .process(tuned_prompt, feedback)
32
- )
31
+ new_prompt = tuning_bot.process(tuned_prompt, feedback)
33
32
 
34
33
  print('----------------------NEW PROMPT START------------------------------')
35
34
  print()
@@ -38,8 +37,8 @@ def bot_tuning_cli(bot: Type[BaseLlmBot], **bot_parmas):
38
37
  print('----------------------NEW PROMPT END------------------------------')
39
38
  print()
40
39
  print('----------------------BOT TUNING START------------------------------')
41
- bot.instructions_prompt = Prompt().text(new_prompt.prompt)
42
- bot_tuning = bot.process(**bot_parmas)
40
+ bot.llm_role = Prompt().text(new_prompt.prompt)
41
+ bot_tuning = bot.process(**bot_params)
43
42
  print(bot_tuning)
44
43
  print('----------------------BOT TUNING END------------------------------')
45
44
 
@@ -51,5 +50,7 @@ def bot_tuning_cli(bot: Type[BaseLlmBot], **bot_parmas):
51
50
  Recorder.to_html_file(recording_name='prompt_tuning')
52
51
 
53
52
  output_prompt = input('Do you want to output the final prompt y/n?')
53
+
54
54
  if output_prompt.strip().lower() == 'y':
55
- DandyPythonPromptBot().process(tuned_prompt)
55
+ python_bot = DandyPythonPromptBot()
56
+ python_bot.process(tuned_prompt)