django-spire 0.20.0__py3-none-any.whl → 0.20.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.
- django_spire/ai/chat/intelligence/decoders/tools.py +7 -2
- django_spire/ai/chat/intelligence/workflows/chat_workflow.py +22 -22
- django_spire/consts.py +1 -1
- django_spire/settings.py +1 -0
- {django_spire-0.20.0.dist-info → django_spire-0.20.1.dist-info}/METADATA +2 -2
- {django_spire-0.20.0.dist-info → django_spire-0.20.1.dist-info}/RECORD +9 -9
- {django_spire-0.20.0.dist-info → django_spire-0.20.1.dist-info}/WHEEL +0 -0
- {django_spire-0.20.0.dist-info → django_spire-0.20.1.dist-info}/licenses/LICENSE.md +0 -0
- {django_spire-0.20.0.dist-info → django_spire-0.20.1.dist-info}/top_level.txt +0 -0
|
@@ -5,6 +5,8 @@ from typing import Callable, TYPE_CHECKING
|
|
|
5
5
|
from dandy import Decoder
|
|
6
6
|
|
|
7
7
|
from django_spire.auth.controller.controller import AppAuthController
|
|
8
|
+
from django_spire.conf import settings
|
|
9
|
+
from django_spire.core.utils import get_callable_from_module_string_and_validate_arguments
|
|
8
10
|
from django_spire.knowledge.intelligence.workflows.knowledge_workflow import knowledge_search_workflow
|
|
9
11
|
|
|
10
12
|
if TYPE_CHECKING:
|
|
@@ -20,8 +22,11 @@ def generate_intent_decoder(
|
|
|
20
22
|
if AppAuthController(app_name='knowledge', request=request).can_view():
|
|
21
23
|
intent_dict['The user is looking for information or knowledge on something.'] = knowledge_search_workflow
|
|
22
24
|
|
|
23
|
-
if
|
|
24
|
-
intent_dict['None of the above choices match the user\'s intent'] =
|
|
25
|
+
if settings.AI_CHAT_DEFAULT_CALLABLE is not None:
|
|
26
|
+
intent_dict['None of the above choices match the user\'s intent'] = get_callable_from_module_string_and_validate_arguments(
|
|
27
|
+
settings.AI_CHAT_DEFAULT_CALLABLE,
|
|
28
|
+
['request', 'user_input', 'message_history']
|
|
29
|
+
)
|
|
25
30
|
|
|
26
31
|
return Decoder(
|
|
27
32
|
mapping_keys_description='Intent of the User\'s Request',
|
|
@@ -8,25 +8,15 @@ from dandy.recorder import recorder_to_html_file
|
|
|
8
8
|
from django_spire.ai.chat.intelligence.decoders.tools import generate_intent_decoder
|
|
9
9
|
from django_spire.ai.chat.message_intel import BaseMessageIntel, DefaultMessageIntel
|
|
10
10
|
from django_spire.ai.decorators import log_ai_interaction_from_recorder
|
|
11
|
+
from django_spire.conf import settings
|
|
12
|
+
from django_spire.core.utils import get_callable_from_module_string_and_validate_arguments
|
|
11
13
|
|
|
12
14
|
if TYPE_CHECKING:
|
|
13
15
|
from dandy.llm.request.message import MessageHistory
|
|
14
16
|
from django.core.handlers.wsgi import WSGIRequest
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
def
|
|
18
|
-
request: WSGIRequest,
|
|
19
|
-
user_input: str,
|
|
20
|
-
message_history: MessageHistory | None = None
|
|
21
|
-
) -> BaseMessageIntel:
|
|
22
|
-
return chat_workflow(
|
|
23
|
-
request=request,
|
|
24
|
-
user_input=user_input,
|
|
25
|
-
message_history=message_history
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def default_chat_response(
|
|
19
|
+
def default_chat_callable(
|
|
30
20
|
request: WSGIRequest,
|
|
31
21
|
user_input: str,
|
|
32
22
|
message_history: MessageHistory | None = None
|
|
@@ -45,13 +35,6 @@ def chat_workflow(
|
|
|
45
35
|
user_input: str,
|
|
46
36
|
message_history: MessageHistory | None = None
|
|
47
37
|
) -> BaseMessageIntel:
|
|
48
|
-
intent_decoder = generate_intent_decoder(
|
|
49
|
-
request=request,
|
|
50
|
-
default_callable=default_chat_response,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
intent_process = intent_decoder.process(user_input, max_return_values=1)[0]
|
|
54
|
-
|
|
55
38
|
@log_ai_interaction_from_recorder(request.user)
|
|
56
39
|
def run_workflow_process(callable_: Callable) -> BaseMessageIntel | None:
|
|
57
40
|
return callable_(
|
|
@@ -60,11 +43,28 @@ def chat_workflow(
|
|
|
60
43
|
message_history=message_history,
|
|
61
44
|
)
|
|
62
45
|
|
|
63
|
-
|
|
46
|
+
if settings.AI_CHAT_CALLABLE is not None:
|
|
47
|
+
chat_callable = get_callable_from_module_string_and_validate_arguments(
|
|
48
|
+
settings.AI_CHAT_CALLABLE,
|
|
49
|
+
['request', 'user_input', 'message_history']
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
message_intel = run_workflow_process(chat_callable)
|
|
53
|
+
|
|
54
|
+
else:
|
|
55
|
+
|
|
56
|
+
intent_decoder = generate_intent_decoder(
|
|
57
|
+
request=request,
|
|
58
|
+
default_callable=default_chat_callable,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
intent_process = intent_decoder.process(user_input, max_return_values=1)[0]
|
|
62
|
+
|
|
63
|
+
message_intel = run_workflow_process(intent_process)
|
|
64
64
|
|
|
65
65
|
if not isinstance(message_intel, BaseMessageIntel):
|
|
66
66
|
if message_intel is None:
|
|
67
|
-
return
|
|
67
|
+
return default_chat_callable(
|
|
68
68
|
request=request,
|
|
69
69
|
user_input=user_input,
|
|
70
70
|
message_history=message_history
|
django_spire/consts.py
CHANGED
django_spire/settings.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-spire
|
|
3
|
-
Version: 0.20.
|
|
3
|
+
Version: 0.20.1
|
|
4
4
|
Summary: A project for Django Spire
|
|
5
5
|
Author-email: Brayden Carlson <braydenc@stratusadv.com>, Nathan Johnson <nathanj@stratusadv.com>
|
|
6
6
|
License: Copyright (c) 2024 Stratus Advanced Technologies and Contributors.
|
|
@@ -49,7 +49,7 @@ Requires-Dist: beautifulsoup4>=4.14.2
|
|
|
49
49
|
Requires-Dist: boto3>=1.34.0
|
|
50
50
|
Requires-Dist: botocore>=1.34.0
|
|
51
51
|
Requires-Dist: crispy-bootstrap5==2024.10
|
|
52
|
-
Requires-Dist: dandy>=1.3.
|
|
52
|
+
Requires-Dist: dandy>=1.3.3
|
|
53
53
|
Requires-Dist: django>=5.1.8
|
|
54
54
|
Requires-Dist: django-crispy-forms==2.3
|
|
55
55
|
Requires-Dist: django-glue>=0.8.1
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
django_spire/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
django_spire/conf.py,sha256=c5Hs-7lk9T15254tOasiQ2ZTFLQIVJof9_QJDfm1PAI,933
|
|
3
|
-
django_spire/consts.py,sha256=
|
|
3
|
+
django_spire/consts.py,sha256=0pi9-zQb-ooeNNpnBBaPK6lSS7BO1hC2KSZHRlgbhcE,171
|
|
4
4
|
django_spire/exceptions.py,sha256=L5ndRO5ftMmh0pHkO2z_NG3LSGZviJ-dDHNT73SzTNw,48
|
|
5
|
-
django_spire/settings.py,sha256=
|
|
5
|
+
django_spire/settings.py,sha256=5gzQCMKAHcBYFREPrYLkQcqFj5gSSgyduUU1H2ztWN8,685
|
|
6
6
|
django_spire/urls.py,sha256=mKeZszb5U4iIGqddMb5Tt5fRC72U2wABEOi6mvOfEBU,656
|
|
7
7
|
django_spire/utils.py,sha256=kW0HP1xWj8Oz0h1GWs4NflnD8Jq8_F4hABwKTiT-Iyk,1006
|
|
8
8
|
django_spire/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -25,9 +25,9 @@ django_spire/ai/chat/auth/controller.py,sha256=l4xHQxSlPgS_QPvofsARUOMcXzVo3cTMs
|
|
|
25
25
|
django_spire/ai/chat/intelligence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
django_spire/ai/chat/intelligence/prompts.py,sha256=jnFaN7EUUQM-wxloWJZ2UAGw1RDXIOKkX4JfvT6ukxw,686
|
|
27
27
|
django_spire/ai/chat/intelligence/decoders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
-
django_spire/ai/chat/intelligence/decoders/tools.py,sha256=
|
|
28
|
+
django_spire/ai/chat/intelligence/decoders/tools.py,sha256=pC3Rvg0a1bgi0ESAsDH2HDJQTsu9aCcTslXfp4R7HwQ,1233
|
|
29
29
|
django_spire/ai/chat/intelligence/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
django_spire/ai/chat/intelligence/workflows/chat_workflow.py,sha256=
|
|
30
|
+
django_spire/ai/chat/intelligence/workflows/chat_workflow.py,sha256=VaaIqN2U5C1opyQXyJevDs9fDtfwn7gVm5-EZDju1EI,2475
|
|
31
31
|
django_spire/ai/chat/migrations/0001_initial.py,sha256=1cbREhX3_fNsbfumJoKAZ8w91Kq5NeXUn_iI45B7oGE,2632
|
|
32
32
|
django_spire/ai/chat/migrations/0002_remove_chatmessage_content_chatmessage__content_and_more.py,sha256=KeNT7VRFmwA74odh9wxIE1Cr4KAO4Tmtqu0FuI2AmK0,752
|
|
33
33
|
django_spire/ai/chat/migrations/0003_rename__content_chatmessage__intel_data_and_more.py,sha256=wAcJ6Ia3fWrGbqnVrqD2C3-3ijAot0LK-B3KZavoY_A,754
|
|
@@ -1142,8 +1142,8 @@ django_spire/theme/urls/page_urls.py,sha256=S8nkKkgbhG3XHI3uMUL-piOjXIrRkuY2UlM_
|
|
|
1142
1142
|
django_spire/theme/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1143
1143
|
django_spire/theme/views/json_views.py,sha256=W1khC2K_EMbEzAFmMxC_P76_MFnkRH4-eVdodrRfAhw,1904
|
|
1144
1144
|
django_spire/theme/views/page_views.py,sha256=pHr8iekjtR99xs7w1taj35HEo133Svq1dvDD0y0VL1c,3933
|
|
1145
|
-
django_spire-0.20.
|
|
1146
|
-
django_spire-0.20.
|
|
1147
|
-
django_spire-0.20.
|
|
1148
|
-
django_spire-0.20.
|
|
1149
|
-
django_spire-0.20.
|
|
1145
|
+
django_spire-0.20.1.dist-info/licenses/LICENSE.md,sha256=tlTbOtgKoy-xAQpUk9gPeh9O4oRXCOzoWdW3jJz0wnA,1091
|
|
1146
|
+
django_spire-0.20.1.dist-info/METADATA,sha256=2DlaKuP0TZp6LeY4ytPWI7ckgoQS_4lF5GonhxR-E6A,4967
|
|
1147
|
+
django_spire-0.20.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
1148
|
+
django_spire-0.20.1.dist-info/top_level.txt,sha256=xf3QV1e--ONkVpgMDQE9iqjQ1Vg4--_6C8wmO-KxPHQ,13
|
|
1149
|
+
django_spire-0.20.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|