dandy 0.6.0__tar.gz → 0.7.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.
Files changed (177) hide show
  1. {dandy-0.6.0 → dandy-0.7.0}/CHANGELOG.md +51 -0
  2. dandy-0.7.0/CONTRIBUTORS.md +9 -0
  3. {dandy-0.6.0 → dandy-0.7.0}/PKG-INFO +4 -4
  4. dandy-0.7.0/README.md +194 -0
  5. {dandy-0.6.0 → dandy-0.7.0}/dandy/bot/llm_bot.py +23 -7
  6. dandy-0.7.0/dandy/cli/llm/assistant/assistant.py +24 -0
  7. dandy-0.7.0/dandy/cli/llm/evaluate/evaluate.py +70 -0
  8. dandy-0.7.0/dandy/cli/llm/evaluate/intelligence/prompts/prompt_evaluation_prompts.py +40 -0
  9. dandy-0.7.0/dandy/cli/llm/generate/generate.py +54 -0
  10. {dandy-0.6.0/dandy/cli → dandy-0.7.0/dandy/cli/llm}/generate/intelligence/prompts/generate_llm_bot_prompts.py +5 -1
  11. dandy-0.7.0/dandy/cli/main.py +95 -0
  12. dandy-0.7.0/dandy/cli/utils.py +26 -0
  13. dandy-0.7.0/dandy/conf.py +46 -0
  14. dandy-0.7.0/dandy/const.py +11 -0
  15. dandy-0.7.0/dandy/debug/debug.py +177 -0
  16. {dandy-0.6.0 → dandy-0.7.0}/dandy/debug/html/debug_recorder_output_template.html +1 -1
  17. dandy-0.7.0/dandy/default_settings.py +31 -0
  18. {dandy-0.6.0/dandy/workflow → dandy-0.7.0/dandy/future}/exceptions.py +1 -1
  19. {dandy-0.6.0 → dandy-0.7.0}/dandy/future/future.py +3 -3
  20. dandy-0.7.0/dandy/llm/conf.py +53 -0
  21. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/config/config.py +28 -56
  22. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/config/ollama.py +4 -4
  23. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/config/openai.py +4 -3
  24. dandy-0.7.0/dandy/llm/config/options.py +84 -0
  25. dandy-0.7.0/dandy/llm/config/utils.py +4 -0
  26. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/exceptions.py +0 -2
  27. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/prompt/prompt.py +38 -9
  28. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/prompt/snippet.py +33 -16
  29. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/request/ollama.py +3 -0
  30. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/request/openai.py +3 -0
  31. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/request/request.py +5 -2
  32. dandy-0.7.0/dandy/llm/service/__init__.py +1 -0
  33. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/service/debug.py +2 -2
  34. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/service/service.py +18 -19
  35. dandy-0.7.0/dandy/llm/tokens/utils.py +5 -0
  36. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/utils.py +1 -6
  37. dandy-0.7.0/dandy/utils.py +8 -0
  38. {dandy-0.6.0 → dandy-0.7.0}/dandy.egg-info/PKG-INFO +4 -4
  39. {dandy-0.6.0 → dandy-0.7.0}/dandy.egg-info/SOURCES.txt +35 -16
  40. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/crew/intelligence/intel.py +1 -0
  41. dandy-0.6.0/example/run.py → dandy-0.7.0/example/run_example.py +3 -4
  42. {dandy-0.6.0 → dandy-0.7.0}/setup.py +4 -4
  43. dandy-0.7.0/tests/cli/assistant/test_assistant.py +14 -0
  44. dandy-0.7.0/tests/cli/evaluate/test_evaluate.py +22 -0
  45. dandy-0.7.0/tests/cli/generate/test_generate.py +17 -0
  46. dandy-0.7.0/tests/cli/test_cli.py +28 -0
  47. {dandy-0.6.0 → dandy-0.7.0}/tests/debug/test_debug.py +11 -0
  48. dandy-0.7.0/tests/future/__init__.py +0 -0
  49. {dandy-0.6.0 → dandy-0.7.0}/tests/future/test_future.py +5 -5
  50. dandy-0.7.0/tests/handler/__init__.py +0 -0
  51. dandy-0.7.0/tests/llm/__init__.py +0 -0
  52. dandy-0.7.0/tests/llm/config/__init__.py +0 -0
  53. dandy-0.7.0/tests/llm/config/test_config_options.py +30 -0
  54. {dandy-0.6.0 → dandy-0.7.0}/tests/llm/config/test_ollama_config.py +4 -3
  55. dandy-0.7.0/tests/llm/prompt/__init__.py +0 -0
  56. dandy-0.7.0/tests/llm/prompt/test_prompt.py +53 -0
  57. dandy-0.7.0/tests/llm/request/__init__.py +0 -0
  58. {dandy-0.6.0 → dandy-0.7.0}/tests/llm/request/test_request.py +2 -2
  59. dandy-0.7.0/tests/llm/service/__init__.py +0 -0
  60. dandy-0.7.0/tests/test_example.py +17 -0
  61. dandy-0.7.0/tests/test_settings.py +12 -0
  62. dandy-0.7.0/tests/workflow/__init__.py +0 -0
  63. dandy-0.6.0/CONTRIBUTORS.md +0 -7
  64. dandy-0.6.0/README.md +0 -156
  65. dandy-0.6.0/dandy/bot/events.py +0 -5
  66. dandy-0.6.0/dandy/cli/assistant/assistant.py +0 -14
  67. dandy-0.6.0/dandy/cli/generate/generate.py +0 -34
  68. dandy-0.6.0/dandy/cli/main.py +0 -72
  69. dandy-0.6.0/dandy/cli/settings.py +0 -16
  70. dandy-0.6.0/dandy/cli/test/test.py +0 -22
  71. dandy-0.6.0/dandy/contrib/bots/seed_llm_bot.py +0 -33
  72. dandy-0.6.0/dandy/debug/debug.py +0 -121
  73. dandy-0.6.0/dandy/future/exceptions.py +0 -9
  74. dandy-0.6.0/dandy/llm/service/__init__.py +0 -1
  75. dandy-0.6.0/dandy/workflow/events.py +0 -5
  76. dandy-0.6.0/tests/llm/prompt/test_prompt.py +0 -11
  77. dandy-0.6.0/tests/test_dandy.py +0 -31
  78. {dandy-0.6.0 → dandy-0.7.0}/LICENSE.md +0 -0
  79. {dandy-0.6.0 → dandy-0.7.0}/MANIFEST.in +0 -0
  80. {dandy-0.6.0 → dandy-0.7.0}/dandy/__init__.py +0 -0
  81. {dandy-0.6.0 → dandy-0.7.0}/dandy/bot/__init__.py +0 -0
  82. {dandy-0.6.0 → dandy-0.7.0}/dandy/bot/bot.py +0 -0
  83. {dandy-0.6.0 → dandy-0.7.0}/dandy/bot/exceptions.py +0 -0
  84. {dandy-0.6.0 → dandy-0.7.0}/dandy/cli/__init__.py +0 -0
  85. {dandy-0.6.0/dandy/cli/assistant → dandy-0.7.0/dandy/cli/llm}/__init__.py +0 -0
  86. {dandy-0.6.0/dandy/cli/generate → dandy-0.7.0/dandy/cli/llm/assistant}/__init__.py +0 -0
  87. {dandy-0.6.0/dandy/cli/generate/intelligence → dandy-0.7.0/dandy/cli/llm/evaluate}/__init__.py +0 -0
  88. {dandy-0.6.0/dandy/cli/generate/intelligence/prompts → dandy-0.7.0/dandy/cli/llm/evaluate/intelligence}/__init__.py +0 -0
  89. {dandy-0.6.0/dandy/cli/test → dandy-0.7.0/dandy/cli/llm/evaluate/intelligence/prompts}/__init__.py +0 -0
  90. {dandy-0.6.0/dandy/contrib → dandy-0.7.0/dandy/cli/llm/generate}/__init__.py +0 -0
  91. {dandy-0.6.0/dandy/core → dandy-0.7.0/dandy/cli/llm/generate/intelligence}/__init__.py +0 -0
  92. {dandy-0.6.0/dandy/debug → dandy-0.7.0/dandy/cli/llm/generate/intelligence/prompts}/__init__.py +0 -0
  93. {dandy-0.6.0/dandy/future → dandy-0.7.0/dandy/contrib}/__init__.py +0 -0
  94. {dandy-0.6.0 → dandy-0.7.0}/dandy/contrib/bots/__init__.py +0 -0
  95. {dandy-0.6.0 → dandy-0.7.0}/dandy/contrib/bots/choice_llm_bot.py +0 -0
  96. {dandy-0.6.0/dandy/handler → dandy-0.7.0/dandy/core}/__init__.py +0 -0
  97. {dandy-0.6.0 → dandy-0.7.0}/dandy/core/exceptions.py +0 -0
  98. {dandy-0.6.0 → dandy-0.7.0}/dandy/core/singleton.py +0 -0
  99. {dandy-0.6.0 → dandy-0.7.0}/dandy/core/type_vars.py +0 -0
  100. {dandy-0.6.0 → dandy-0.7.0}/dandy/core/url.py +0 -0
  101. {dandy-0.6.0 → dandy-0.7.0}/dandy/core/utils.py +0 -0
  102. {dandy-0.6.0/dandy/llm/request → dandy-0.7.0/dandy/debug}/__init__.py +0 -0
  103. {dandy-0.6.0 → dandy-0.7.0}/dandy/debug/events.py +0 -0
  104. {dandy-0.6.0 → dandy-0.7.0}/dandy/debug/exceptions.py +0 -0
  105. {dandy-0.6.0 → dandy-0.7.0}/dandy/debug/utils.py +0 -0
  106. {dandy-0.6.0/example → dandy-0.7.0/dandy/future}/__init__.py +0 -0
  107. {dandy-0.6.0/example/pirate → dandy-0.7.0/dandy/handler}/__init__.py +0 -0
  108. {dandy-0.6.0 → dandy-0.7.0}/dandy/handler/handler.py +0 -0
  109. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/__init__.py +0 -0
  110. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/config/__init__.py +0 -0
  111. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/prompt/__init__.py +0 -0
  112. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/prompt/utils.py +0 -0
  113. {dandy-0.6.0/example/pirate/crew → dandy-0.7.0/dandy/llm/request}/__init__.py +0 -0
  114. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/request/message.py +0 -0
  115. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/service/events.py +0 -0
  116. {dandy-0.6.0 → dandy-0.7.0}/dandy/llm/service/prompts.py +0 -0
  117. {dandy-0.6.0/example/pirate/crew/intelligence → dandy-0.7.0/dandy/llm/tokens}/__init__.py +0 -0
  118. {dandy-0.6.0 → dandy-0.7.0}/dandy/workflow/__init__.py +0 -0
  119. {dandy-0.6.0 → dandy-0.7.0}/dandy/workflow/workflow.py +0 -0
  120. {dandy-0.6.0 → dandy-0.7.0}/dandy.egg-info/dependency_links.txt +0 -0
  121. {dandy-0.6.0 → dandy-0.7.0}/dandy.egg-info/entry_points.txt +0 -0
  122. {dandy-0.6.0 → dandy-0.7.0}/dandy.egg-info/not-zip-safe +0 -0
  123. {dandy-0.6.0 → dandy-0.7.0}/dandy.egg-info/requires.txt +0 -0
  124. {dandy-0.6.0 → dandy-0.7.0}/dandy.egg-info/top_level.txt +0 -0
  125. {dandy-0.6.0/example/pirate/crew/intelligence/bots → dandy-0.7.0/example}/__init__.py +0 -0
  126. {dandy-0.6.0/example/pirate/intelligence → dandy-0.7.0/example/pirate}/__init__.py +0 -0
  127. {dandy-0.6.0/example/pirate/intelligence/workflow → dandy-0.7.0/example/pirate/crew}/__init__.py +0 -0
  128. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/crew/enums.py +0 -0
  129. {dandy-0.6.0/example/pirate/monster → dandy-0.7.0/example/pirate/crew/intelligence}/__init__.py +0 -0
  130. {dandy-0.6.0/example/pirate/monster/intelligence → dandy-0.7.0/example/pirate/crew/intelligence/bots}/__init__.py +0 -0
  131. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/crew/intelligence/bots/crew_generation_llm_bot.py +0 -0
  132. {dandy-0.6.0/example/pirate/monster/intelligence/bots → dandy-0.7.0/example/pirate/intelligence}/__init__.py +0 -0
  133. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/intelligence/configs.py +0 -0
  134. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/intelligence/prompts.py +0 -0
  135. {dandy-0.6.0/example/pirate/monster → dandy-0.7.0/example/pirate/intelligence}/workflow/__init__.py +0 -0
  136. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/intelligence/workflow/pirate_story_workflow.py +0 -0
  137. {dandy-0.6.0/example/pirate/ship → dandy-0.7.0/example/pirate/monster}/__init__.py +0 -0
  138. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/monster/datasets.py +0 -0
  139. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/monster/enums.py +0 -0
  140. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/monster/intel.py +0 -0
  141. {dandy-0.6.0/example/pirate/ship → dandy-0.7.0/example/pirate/monster}/intelligence/__init__.py +0 -0
  142. {dandy-0.6.0/example/pirate/ship → dandy-0.7.0/example/pirate/monster}/intelligence/bots/__init__.py +0 -0
  143. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/monster/intelligence/bots/monster_llm_bots.py +0 -0
  144. {dandy-0.6.0/example/pirate/world → dandy-0.7.0/example/pirate/monster/workflow}/__init__.py +0 -0
  145. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/monster/workflow/monster_generation_workflow.py +0 -0
  146. {dandy-0.6.0/example/pirate/world/intelligence → dandy-0.7.0/example/pirate/ship}/__init__.py +0 -0
  147. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/ship/datasets.py +0 -0
  148. {dandy-0.6.0/example/pirate/world/intelligence/bots → dandy-0.7.0/example/pirate/ship/intelligence}/__init__.py +0 -0
  149. {dandy-0.6.0/tests → dandy-0.7.0/example/pirate/ship/intelligence/bots}/__init__.py +0 -0
  150. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/ship/intelligence/bots/ship_selection_llm_bot.py +0 -0
  151. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/ship/intelligence/intel.py +0 -0
  152. {dandy-0.6.0/tests/bot → dandy-0.7.0/example/pirate/world}/__init__.py +0 -0
  153. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/world/datasets.py +0 -0
  154. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/world/intel.py +0 -0
  155. {dandy-0.6.0/tests/contrib → dandy-0.7.0/example/pirate/world/intelligence}/__init__.py +0 -0
  156. {dandy-0.6.0/tests/contrib → dandy-0.7.0/example/pirate/world/intelligence}/bots/__init__.py +0 -0
  157. {dandy-0.6.0 → dandy-0.7.0}/example/pirate/world/intelligence/bots/ocean_selection_llm_bot.py +0 -0
  158. {dandy-0.6.0 → dandy-0.7.0}/pyproject.toml +0 -0
  159. {dandy-0.6.0 → dandy-0.7.0}/setup.cfg +0 -0
  160. {dandy-0.6.0/tests/core → dandy-0.7.0/tests}/__init__.py +0 -0
  161. {dandy-0.6.0/tests/debug → dandy-0.7.0/tests/bot}/__init__.py +0 -0
  162. {dandy-0.6.0 → dandy-0.7.0}/tests/bot/test_bot.py +0 -0
  163. {dandy-0.6.0/tests/future → dandy-0.7.0/tests/cli}/__init__.py +0 -0
  164. {dandy-0.6.0/tests/handler → dandy-0.7.0/tests/cli/assistant}/__init__.py +0 -0
  165. {dandy-0.6.0/tests/llm → dandy-0.7.0/tests/cli/evaluate}/__init__.py +0 -0
  166. {dandy-0.6.0/tests/llm/config → dandy-0.7.0/tests/cli/generate}/__init__.py +0 -0
  167. {dandy-0.6.0/tests/llm/prompt → dandy-0.7.0/tests/contrib}/__init__.py +0 -0
  168. {dandy-0.6.0/tests/llm/request → dandy-0.7.0/tests/contrib/bots}/__init__.py +0 -0
  169. {dandy-0.6.0 → dandy-0.7.0}/tests/contrib/bots/test_choice_llm_bot.py +0 -0
  170. {dandy-0.6.0/tests/llm/service → dandy-0.7.0/tests/core}/__init__.py +0 -0
  171. {dandy-0.6.0 → dandy-0.7.0}/tests/core/test_utils.py +0 -0
  172. {dandy-0.6.0/tests/workflow → dandy-0.7.0/tests/debug}/__init__.py +0 -0
  173. {dandy-0.6.0 → dandy-0.7.0}/tests/handler/test_handler.py +0 -0
  174. {dandy-0.6.0 → dandy-0.7.0}/tests/llm/prompt/test_snippet.py +0 -0
  175. {dandy-0.6.0 → dandy-0.7.0}/tests/llm/service/test_service.py +0 -0
  176. {dandy-0.6.0 → dandy-0.7.0}/tests/llm/test_utils.py +0 -0
  177. {dandy-0.6.0 → dandy-0.7.0}/tests/workflow/test_workflow.py +0 -0
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.7.0
4
+
5
+ ### Major Improvement
6
+
7
+ - All the changes in v0.7.0 should reduce the over all code required to work with dandy by up to 50%.
8
+
9
+ ### Features
10
+
11
+ - Project structure improvement with new settings file.
12
+ - All projects going forward will require a "dandy_settings.py" file in the root of your project.
13
+ - This file will also need a "BASE_PATH" str variable set to the root of your project.
14
+ - This file will also need a "LLM_CONFIGS" dict variable with a "DEFAULT" llm config.
15
+ - Debug recorder can now output to a json string or file.
16
+ - Added randomize seed to LLM config that will randomize the seed every time the config is used.
17
+ - Added new evaluate cli command for evaluating your dandy code -e --evaluate.
18
+ - Currently only supports Prompt evaluation.
19
+ - ALLOW_DEBUG_RECORDING was added to the settings for project wide control of the debug recorder.
20
+ - defaulted to False.
21
+ - You can now select your llm config from the cli using the -l --llm-config flag.
22
+
23
+ ### Changes
24
+
25
+ - Updated the readme to match the new project structure.
26
+ - All settings and llm configs are now managed through the dandy settings module.
27
+ - The environment variable "DANDY_SETTINGS_MODULE" can be used to specify the settings module to be used.
28
+ - The system will default to look for a "dandy_settings.py" file in the current working directory or sys.path.
29
+ - Moved a lot of project wide constants into the "const.py" file.
30
+
31
+ ### Fixes
32
+
33
+ - Fixed the user "dandy_settings.py" not loading properly with in the internal dandy modules.
34
+ - Fixed readme to match new project structure and configuration setup.
35
+ - Fixed the cli to properly use the dandy_settings.py file in the current working directory.
36
+ - Improved testing coverage across the whole project.
37
+
38
+ ## v0.6.1
39
+
40
+ ### Features
41
+
42
+ - Added heading and sub headings to the prompt class.
43
+
44
+ ### Changes
45
+
46
+ - Improved testing across the whole project.
47
+ - Prompt assembly is more reliable and consistent if you want empty lines you need to use the .line_break method.
48
+
49
+ ### Fixes
50
+
51
+ - Fixed lots of prompt formatting issues.
52
+ - Futures properly raise an exception when they time out.
53
+
3
54
  ## v0.6.0
4
55
 
5
56
  ### Features
@@ -0,0 +1,9 @@
1
+ # Contibutors
2
+
3
+ ### Austin Sauer
4
+
5
+ ### Nathan Johnson
6
+
7
+ ### Wesley Howery
8
+
9
+ ### Brayden Carlson
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dandy
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Intelligence Bot Framework
5
5
  Home-page: https://github.com/stratusadv/dandy
6
6
  Author: Nathan Johnson
@@ -27,16 +27,16 @@ License: Copyright (c) 2024 Stratus Advanced Technologies and Contributors.
27
27
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28
28
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29
29
  OTHER DEALINGS IN THE SOFTWARE.
30
- Keywords: dandy,ai,llm,agent,prompt,gpt
30
+ Keywords: dandy,ai,llm,agent,prompt,gpt,boty
31
31
  Classifier: Development Status :: 5 - Production/Stable
32
32
  Classifier: License :: OSI Approved :: MIT License
33
33
  Classifier: Operating System :: OS Independent
34
- Classifier: Programming Language :: Python :: 3
35
34
  Classifier: Programming Language :: Python :: 3.10
36
35
  Classifier: Programming Language :: Python :: 3.11
37
36
  Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
38
38
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
39
39
  Requires-Python: >=3.10
40
40
  License-File: LICENSE.md
41
41
 
42
- Dandy is a framework for developing programmatic intelligent bots and workflows. It's opinionated, magical, and designed to be incredibly pythonic.
42
+ Dandy is a framework for developing programmatic intelligent bots and workflows. It's opinionated, usefully magical, and designed to be incredibly pythonic.
dandy-0.7.0/README.md ADDED
@@ -0,0 +1,194 @@
1
+ <p align="center">
2
+ <img src="./docs/images/dandy_logo_512.png" alt="Dandy AI Framework">
3
+ </p>
4
+
5
+
6
+ Dandy is an intelligence framework for developing programmatic intelligent bots and workflows.
7
+ It's opinionated, simple and designed to be incredibly pythonic putting the project and developers first.
8
+
9
+ ### Why Did We Create Another AI Framework?
10
+
11
+ Artificial intelligence programming is a very different experience than conventional programming as it's very probabilistic.
12
+ Based on our experience most of the existing frameworks / libraries are designed to focus more on deterministic outcomes which is not realistic or in our opinion beneficial.
13
+
14
+ We created Dandy to focus on the flow and validation of data with your artificial intelligence systems to allow you to embrace the probabilistic nature of artificial intelligence.
15
+ Our approach is to focus on batteries included with strong tooling to help build great interactions and lowers the barrier to entry for developers.
16
+
17
+ ### Pydantic is Everyones Friend
18
+
19
+ This project critically relies on the use of pydantic to handle the flow and validation of data with your artificial intelligence systems.
20
+ Make sure you have a good foundation on the use of pydantic before continuing.
21
+
22
+ Please visit https://docs.pydantic.dev/latest/ for more information on pydantic and how to utilize it.
23
+
24
+ For bigger examples please check out the [example](https://github.com/stratusadv/dandy/tree/main/example) directory in this repository.
25
+
26
+ ### Installation
27
+
28
+ ``` bash
29
+ pip install dandy
30
+ ```
31
+
32
+ ### Recommended Project Structure
33
+
34
+ ```
35
+ cookie_recipe/ <-- This would be for each of your modules
36
+ __init__.py
37
+ your_code.py
38
+ ...
39
+ ...
40
+ intelligence/ <-- Dandy related code should be in this directory
41
+ __init__.py
42
+ bots/
43
+ __init__.py
44
+ cookie_recipe_llm_bot.py <-- Should contain one bot alone (can include, models and prompts specific to this bot)
45
+ cookie_recipe_safety_llm_bot.py
46
+ cookie_recipe_review_llm_bot.py
47
+ ...
48
+ ...
49
+ intel/
50
+ __init__.py
51
+ cookie_recipe_intel.py <-- Pydantic Model Classes in all of these files must be postfixed with "Intel" ex: "SelectIntel"
52
+ cookie_recipe_story_intel.py
53
+ cookie_recipe_marketing_intel.py
54
+ ...
55
+ ...
56
+ prompts/
57
+ __init__.py
58
+ cookie_recipe_prompts.py <-- All of these files would contain prompts that would be shared across the project
59
+ cookie_recipe_email_prompts.py
60
+ cookie_recipe_instructions_prompts.py
61
+ ...
62
+ ...
63
+ workflows/
64
+ __init__.py
65
+ cookie_recipe_generation_workflow.py <-- In most cases this workflow would be used to interact with the user
66
+ ...
67
+ ...
68
+
69
+ dandy_settings.py <-- Contains Settings, LLM configs for the entire project
70
+ ```
71
+
72
+ ### Setting Up Dandy
73
+
74
+ It's recommended that you use "DANDY_SETTINGS_MODULE" set in your environment variables pointed towards your dandy settings file.
75
+ If no environment variable is set, it will look for "dandy_settings.py" in the current working directory or sys.path.
76
+
77
+ ```python
78
+ # dandy_settings.py
79
+
80
+ import os
81
+ from pathlib import Path
82
+
83
+ # This is used for controlling the debug recorder in development and should be set to false in production
84
+
85
+ ALLOW_DEBUG_RECORDING: bool = True
86
+
87
+ # You should set this to the root directory of your project the default will be the current working directory
88
+
89
+ BASE_PATH = Path.resolve(Path(__file__)).parent
90
+
91
+ # Other DEFAULT Settings - See dandy/settings.py for all options
92
+
93
+ DEFAULT_LLM_TEMPERATURE: float = 0.7
94
+ DEFAULT_LLM_SEED: int = 77
95
+ DEFAULT_LLM_RANDOMIZE_SEED: bool = False
96
+ DEFAULT_LLM_MAX_INPUT_TOKENS: int = 8000
97
+ DEFAULT_LLM_MAX_OUTPUT_TOKENS: int = 4000
98
+ DEFAULT_LLM_CONNECTION_RETRY_COUNT: int = 10
99
+ DEFAULT_LLM_PROMPT_RETRY_COUNT: int = 2
100
+
101
+ # These are some example LLM configs you may only need one of these, you must have a "DEFAULT" LLM config
102
+
103
+ LLM_CONFIGS = {
104
+ 'DEFAULT': {
105
+ 'TYPE': 'ollama',
106
+ 'HOST': os.getenv("OLLAMA_HOST"),
107
+ 'PORT': int(os.getenv("OLLAMA_PORT", 11434)),
108
+ 'API_KEY': os.getenv("OLLAMA_API_KEY"),
109
+ 'MODEL': 'llama3.1:8b-instruct-q4_K_M',
110
+ },
111
+ 'OLLAMA_LLAMA_3_2_3B_SMALL': {
112
+ 'TYPE': 'ollama',
113
+ 'HOST': os.getenv("OLLAMA_HOST"),
114
+ 'PORT': int(os.getenv("OLLAMA_PORT", 11434)),
115
+ 'API_KEY': os.getenv("OLLAMA_API_KEY"),
116
+ 'MODEL': 'llama3.2:3b-instruct-q4_K_M',
117
+
118
+ # You can override any of the default settings for each LLM config
119
+
120
+ 'TEMPERATURE': 0.2,
121
+ 'SEED': 65,
122
+ 'RANDOMIZE_SEED': False,
123
+ 'MAX_INPUT_TOKENS': 500,
124
+ 'MAX_OUTPUT_TOKENS': 200,
125
+ },
126
+ 'OPENAI_GPT_3_5_TURBO': {
127
+ 'TYPE': 'openai',
128
+ 'HOST': os.getenv("OPENAI_HOST"),
129
+ 'PORT': int(os.getenv("OPENAI_PORT", 443)),
130
+ 'API_KEY': os.getenv("OPEN_API_KEY"),
131
+ 'MODEL': 'gpt-3.5-turbo',
132
+ },
133
+ }
134
+
135
+ ```
136
+
137
+ ### Basic Usage Example
138
+
139
+ ```python
140
+ # cookie_recipe_llm_bot.py
141
+
142
+ from typing import List
143
+ from pydantic import BaseModel
144
+
145
+ from dandy.bot import LlmBot
146
+ from dandy.llm import Prompt
147
+ from dandy.llm.conf import llm_configs
148
+
149
+
150
+ class CookieRecipeIngredientIntel(BaseModel):
151
+ name: str
152
+ unit_type: str
153
+ quantity: float
154
+
155
+
156
+ class CookieRecipeIntel(BaseModel):
157
+ name: str
158
+ description: str
159
+ ingredients: List[CookieRecipeIngredientIntel]
160
+ instructions: str
161
+
162
+
163
+ class CookieRecipeLlmBot(LlmBot):
164
+ # If you do not set a config, the "DEFAULT" config from your "dandy_settings.py" will be used.
165
+
166
+ config = llm_configs.OPENAI_GPT_3_5_TURBO
167
+
168
+ # You can also override settings per bot.
169
+
170
+ seed = 25
171
+ max_output_tokens = 1000
172
+
173
+ # This is the instructions used by the system message when the llm is prompted
174
+
175
+ instructions_prompt = (
176
+ Prompt()
177
+ .title('You are a cookie recipe bot.')
178
+ .text('Your job is to follow the instructions provided below.')
179
+ .unordered_random_list([
180
+ 'Create a cookie based on the users input',
181
+ 'Make sure the instructions are easy to follow',
182
+ 'Names of recipe should be as short as possible',
183
+ ])
184
+ )
185
+
186
+
187
+
188
+ cookie_recipe_intel = CookieRecipeLlmBot.process(
189
+ prompt=Prompt().text('I love broccoli and oatmeal!'),
190
+ model=CookieRecipeIntel,
191
+ )
192
+
193
+ print(cookie_recipe_intel.instructions)
194
+ ```
@@ -2,18 +2,31 @@ from abc import ABC
2
2
  from typing_extensions import Type, Union
3
3
 
4
4
  from dandy.bot.bot import Bot
5
+ from dandy.bot.exceptions import BotException
5
6
  from dandy.core.type_vars import ModelType
6
7
  from dandy.llm.config import BaseLlmConfig
8
+ from dandy.llm.config.options import LlmConfigOptions
7
9
  from dandy.llm.prompt import Prompt
10
+ from dandy.llm.conf import llm_configs
8
11
 
9
12
 
10
13
  class LlmBot(Bot, ABC):
11
14
  instructions_prompt: Prompt
12
- config: BaseLlmConfig
13
- temperature: Union[float, None] = None
14
- seed: Union[int, None] = None
15
+ config: BaseLlmConfig = llm_configs.DEFAULT
16
+
15
17
  max_input_tokens: Union[int, None] = None
16
18
  max_output_tokens: Union[int, None] = None
19
+ randomize_seed: Union[bool, None] = None
20
+ seed: Union[int, None] = None
21
+ temperature: Union[float, None] = None
22
+
23
+ def __new__(cls, *args, **kwargs):
24
+ if cls.config is None:
25
+ raise BotException(f'{cls.__name__} config is not set')
26
+ if cls.instructions_prompt is None:
27
+ raise BotException(f'{cls.__name__} instructions_prompt is not set')
28
+
29
+ return super().__new__(cls)
17
30
 
18
31
  @classmethod
19
32
  def process_prompt_to_model_object(
@@ -23,10 +36,13 @@ class LlmBot(Bot, ABC):
23
36
  ) -> ModelType:
24
37
 
25
38
  return cls.config.generate_service(
26
- seed=cls.seed,
27
- temperature=cls.temperature,
28
- max_input_tokens=cls.max_input_tokens,
29
- max_output_tokens=cls.max_output_tokens
39
+ llm_options=LlmConfigOptions(
40
+ seed=cls.seed,
41
+ randomize_seed=cls.randomize_seed,
42
+ temperature=cls.temperature,
43
+ max_input_tokens=cls.max_input_tokens,
44
+ max_output_tokens=cls.max_output_tokens
45
+ )
30
46
  ).process_prompt_to_model_object(
31
47
  prompt=prompt,
32
48
  model=model,
@@ -0,0 +1,24 @@
1
+ from dandy.llm.config import BaseLlmConfig
2
+
3
+
4
+ def assistant(
5
+ llm_config: BaseLlmConfig,
6
+ user_prompt: str,
7
+ ) -> None:
8
+
9
+ if user_prompt:
10
+ user_input = user_prompt
11
+ else:
12
+ user_input = input(f'Assistant Prompt: ')
13
+
14
+ print(f'Prompting Assistant ... depending on your llm configuration this may take up to a couple minutes')
15
+
16
+ response = llm_config.service.assistant_str_prompt_to_str(
17
+ user_prompt_str=user_input
18
+ )
19
+
20
+ if response:
21
+ print(response)
22
+
23
+ else:
24
+ print('Failed to get response from the assistant ... try again')
@@ -0,0 +1,70 @@
1
+ import importlib
2
+ import inspect
3
+ from enum import Enum
4
+
5
+ from pydantic import BaseModel
6
+ from typing_extensions import Union
7
+
8
+ from dandy.cli.llm.evaluate.intelligence.prompts.prompt_evaluation_prompts import evaluate_prompt_system_prompt, \
9
+ evaluate_prompt_user_prompt
10
+ from dandy.llm.config import BaseLlmConfig
11
+
12
+
13
+ class EvaluatedSourceIntel(BaseModel):
14
+ file_name: str
15
+ source: str
16
+ source_changed: bool
17
+ evaluator_comments: str
18
+
19
+
20
+ class EvaluateChoices(Enum):
21
+ PROMPT = 'prompt'
22
+
23
+
24
+ def evaluate(
25
+ llm_config: BaseLlmConfig,
26
+ choice: EvaluateChoices,
27
+ module_and_obj: Union[str, None] = None,
28
+ evaluate_description: Union[str, None] = None,
29
+ ) -> None:
30
+
31
+ if module_and_obj is None:
32
+ module_and_obj = input('Enter the module and object you want to evaluate: ')
33
+
34
+ if evaluate_description is None:
35
+ evaluate_description = input('Describe the prompt you want to evaluate: ')
36
+
37
+ print(f'Evaluating {choice.value} {module_and_obj} ... depending on your llm configuration this may take up to a couple minutes')
38
+
39
+ module_name = ".".join(module_and_obj.split(".")[0:-1])
40
+ obj_name = module_and_obj.split(".")[-1]
41
+
42
+ print(f'Module: {module_name}')
43
+ module = importlib.import_module(module_name)
44
+
45
+ print(f'Object: {obj_name}')
46
+ obj = getattr(module, obj_name)
47
+
48
+ source_code = inspect.getsource(obj)
49
+
50
+ if choice == EvaluateChoices.PROMPT:
51
+ evaluated_source_intel = llm_config.service.process_prompt_to_model_object(
52
+ prompt=evaluate_prompt_user_prompt(
53
+ prompt_name=obj_name,
54
+ prompt_source=source_code,
55
+ prompt_description=evaluate_description,
56
+ ),
57
+ model=EvaluatedSourceIntel,
58
+ prefix_system_prompt=evaluate_prompt_system_prompt(),
59
+ )
60
+
61
+ if evaluated_source_intel:
62
+ print(f'{evaluated_source_intel.source_changed=}')
63
+ print(evaluated_source_intel.source + '\n')
64
+ print(evaluated_source_intel.evaluator_comments + '\n')
65
+
66
+ else:
67
+ print('Failed to get response from the assistant ... try again')
68
+
69
+ else:
70
+ raise ValueError(f'Unknown evaluate type: {choice}')
@@ -0,0 +1,40 @@
1
+ from dandy.llm import Prompt
2
+
3
+
4
+ def evaluate_prompt_system_prompt() -> Prompt:
5
+ return (
6
+ Prompt()
7
+ .title(
8
+ 'Your a prompt evaluator that needs to review the users prompts and determine if there is improvements you can suggest.')
9
+ .divider()
10
+ .text(
11
+ 'Follow the rules below and the provided updated code.')
12
+ .list([
13
+ 'Use the provided module source code to understand the users prompt code.',
14
+ 'With the prompt description provided by the user update the code to improve its chance to work with an large language model.',
15
+ 'Add lines of code to the prompt if needed to improve its chance to work with an large language model.'
16
+ ])
17
+ .line_break()
18
+ .heading('This is the module source code used to create the prompt.')
19
+ .module_source('dandy.llm.prompt.prompt')
20
+ .line_break()
21
+ )
22
+
23
+
24
+ def evaluate_prompt_user_prompt(
25
+ prompt_name: str,
26
+ prompt_source: str,
27
+ prompt_description: str,
28
+ ) -> Prompt:
29
+ return (
30
+ Prompt()
31
+ .heading('Prompt Description')
32
+ .text(prompt_description)
33
+ .line_break()
34
+ .heading('Prompt Source Code')
35
+ .text(
36
+ prompt_source,
37
+ triple_quote=True,
38
+ triple_quote_label=prompt_name
39
+ )
40
+ )
@@ -0,0 +1,54 @@
1
+ from enum import Enum
2
+ from pathlib import Path
3
+ from typing import Union
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from dandy.cli.llm.generate.intelligence.prompts.generate_llm_bot_prompts import generate_llm_bot_system_prompt, \
8
+ generate_llm_bot_user_prompt
9
+ from dandy.llm.config import BaseLlmConfig
10
+
11
+
12
+ class LlmBotSourceIntel(BaseModel):
13
+ file_name: str
14
+ source: str
15
+
16
+
17
+ class GenerateChoices(Enum):
18
+ LLM_BOT = 'llm_bot'
19
+
20
+
21
+ def generate(
22
+ llm_config: BaseLlmConfig,
23
+ choice: GenerateChoices,
24
+ output_path: Union[Path, str],
25
+ generate_description: Union[str, None] = None,
26
+ output_to_file: bool = True
27
+ ) -> None:
28
+
29
+ if generate_description is None:
30
+ generate_description = input('Describe what you want to generate: ')
31
+
32
+ if choice == GenerateChoices.LLM_BOT:
33
+ print(f'Generating {choice} ... depending on your llm configuration this may take up to a couple minutes')
34
+
35
+ llm_bot_source_intel = llm_config.service.process_prompt_to_model_object(
36
+ prompt=generate_llm_bot_user_prompt(generate_description),
37
+ model=LlmBotSourceIntel,
38
+ prefix_system_prompt=generate_llm_bot_system_prompt(),
39
+ )
40
+
41
+ if llm_bot_source_intel:
42
+ if output_to_file:
43
+ Path(output_path).mkdir(parents=True, exist_ok=True)
44
+
45
+ with open(Path(output_path, llm_bot_source_intel.file_name), 'w') as f:
46
+ f.write(llm_bot_source_intel.source)
47
+
48
+ print(f'Done ... saved to "{Path(output_path, llm_bot_source_intel.file_name)}"')
49
+
50
+ else:
51
+ print(llm_bot_source_intel.source)
52
+
53
+ else:
54
+ print('Failed to generate ... try again')
@@ -4,7 +4,7 @@ from dandy.llm import Prompt
4
4
  def generate_llm_bot_system_prompt() -> Prompt:
5
5
  return (
6
6
  Prompt()
7
- .title("Your a coder that needs to write a large language model bot using the dandy framework.")
7
+ .title('Your a coder that needs to write a large language model bot using the dandy framework.')
8
8
  .divider()
9
9
  .text(
10
10
  'Follow the rules below and the provided code to create a llm bot based on the users input')
@@ -16,7 +16,10 @@ def generate_llm_bot_system_prompt() -> Prompt:
16
16
  'The new llm bot must use the process method for all its logic and can call the process_prompt_to_model_object for llm interactions.',
17
17
  'Return only python code in a string with no triple quotes or explanations as this code will be used directly in a python file to be run.',
18
18
  'Make sure to be explict with the keyword arguments in the process method.',
19
+ 'Include all required imports for all the required modules used.'
19
20
  'the file name for this bot should end in "_llm_bot" with the extension ".py"',
21
+ 'All the pydantic objects needed should be post-fixed with "Intel" ex: "SelectIntel"'
22
+ 'You do not need to add the model schema or instructions about it to the prompt its automatically handled by eh process_prompt_to_model_object method.'
20
23
  ])
21
24
  .line_break()
22
25
  .module_source('dandy.llm.prompt.prompt')
@@ -33,5 +36,6 @@ def generate_llm_bot_system_prompt() -> Prompt:
33
36
  def generate_llm_bot_user_prompt(user_input: str) -> Prompt:
34
37
  return (
35
38
  Prompt()
39
+ .heading('Llm Bot Description')
36
40
  .text(user_input)
37
41
  )
@@ -0,0 +1,95 @@
1
+ import argparse
2
+
3
+ from pathlib import Path
4
+ import sys
5
+
6
+
7
+ CWD_PATH = Path.cwd()
8
+
9
+ sys.path.append(str(CWD_PATH))
10
+
11
+ def main():
12
+ from dandy.cli.utils import check_or_create_settings, load_environment_variables
13
+
14
+ check_or_create_settings(CWD_PATH)
15
+ load_environment_variables(CWD_PATH)
16
+
17
+ from dandy.utils import enum_to_list
18
+ from dandy.llm.conf import llm_configs
19
+ from dandy.cli.llm.generate.generate import GenerateChoices, generate
20
+ from dandy.cli.llm.assistant.assistant import assistant
21
+ from dandy.conf import settings
22
+ from dandy.cli.llm.evaluate.evaluate import EvaluateChoices, evaluate
23
+ from dandy.const import CLI_OUTPUT_DIRECTORY
24
+
25
+ CLI_OUTPUT_PATH = Path(settings.BASE_PATH, CLI_OUTPUT_DIRECTORY)
26
+
27
+ parser = argparse.ArgumentParser(description='Dandy CLI Tool')
28
+
29
+ parser.add_argument(
30
+ '-a', '--assistant',
31
+ type=str,
32
+ help='Prompt an a generic assistant to quickly test a prompt.',
33
+ )
34
+
35
+ parser.add_argument(
36
+ '-e', '--evaluate',
37
+ type=str,
38
+ choices=enum_to_list(EvaluateChoices),
39
+ help='Test an llm_bot.',
40
+ )
41
+
42
+ parser.add_argument(
43
+ '-g', '--generate',
44
+ type=str,
45
+ choices=enum_to_list(GenerateChoices),
46
+ help='Generate your selected choice by description into a source file.',
47
+ )
48
+
49
+ parser.add_argument(
50
+ '-l', '--llm-config',
51
+ dest='llm_config',
52
+ type=str,
53
+ choices=llm_configs.choices,
54
+ default='DEFAULT',
55
+ help='Select the llm config to use. Defaults to "DEFAULT".',
56
+ )
57
+
58
+ parser.add_argument(
59
+ '-p', '--prompt',
60
+ type=str,
61
+ help='The string prompt to be used with the generate cli command.',
62
+ )
63
+
64
+ args = parser.parse_args()
65
+
66
+ llm_config = llm_configs[args.llm_config]
67
+
68
+ if args.assistant:
69
+ assistant(
70
+ llm_config=llm_config,
71
+ user_prompt=args.prompt if args.prompt else args.assistant,
72
+ )
73
+
74
+ elif args.evaluate:
75
+ evaluate(
76
+ llm_config=llm_config,
77
+ choice=EvaluateChoices(args.evaluate),
78
+ module_and_obj=None,
79
+ evaluate_description=args.prompt if args.prompt else None,
80
+ )
81
+
82
+ elif args.generate:
83
+ generate(
84
+ llm_config=llm_config,
85
+ choice=GenerateChoices(args.generate),
86
+ output_path=CLI_OUTPUT_PATH,
87
+ generate_description=args.prompt if args.prompt else None,
88
+ )
89
+
90
+ else:
91
+ parser.print_help()
92
+
93
+
94
+ if __name__ == '__main__':
95
+ exit(main())
@@ -0,0 +1,26 @@
1
+ from pathlib import Path
2
+
3
+ import dotenv
4
+
5
+ from dandy.const import USER_SETTINGS_FILE_NAME, CLI_DEFAULT_ENV_FILE_NAMES
6
+
7
+
8
+ def check_or_create_settings(cwd_path: Path) -> None:
9
+ if Path(cwd_path, USER_SETTINGS_FILE_NAME).exists():
10
+ return
11
+
12
+ print(f'Could not find "{USER_SETTINGS_FILE_NAME}" in your current directory. Creating one for you...')
13
+
14
+ with open(Path(Path(__file__).parent.parent.resolve(), 'default_settings.py'), 'r') as default_settings:
15
+ with open(Path(cwd_path, 'dandy_settings.py'), 'w') as user_settings:
16
+ user_settings.write(default_settings.read())
17
+
18
+ print(f'Created "{USER_SETTINGS_FILE_NAME}" in your current directory.')
19
+ print(f'You need to configure the "BASE_PATH" and "LLM_CONFIGS".')
20
+
21
+ def load_environment_variables(cwd_path: Path) -> None:
22
+ for env_file_name in CLI_DEFAULT_ENV_FILE_NAMES:
23
+ env_file_path = Path(cwd_path, env_file_name)
24
+ if env_file_path.exists():
25
+ print(f'Loading environment variables from "{env_file_path}"')
26
+ dotenv.load_dotenv(env_file_path)