django-agent-studio 0.1.0__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_agent_studio/__init__.py +12 -0
- django_agent_studio/api/__init__.py +4 -0
- django_agent_studio/api/permissions.py +160 -0
- django_agent_studio/api/serializers.py +606 -0
- django_agent_studio/api/urls.py +245 -0
- django_agent_studio/api/views.py +1548 -0
- django_agent_studio/apps.py +24 -0
- django_agent_studio/management/__init__.py +2 -0
- django_agent_studio/management/commands/__init__.py +2 -0
- django_agent_studio/static/agent-frontend/chat-widget-markdown.js +110 -0
- django_agent_studio/static/agent-frontend/chat-widget.css +1401 -0
- django_agent_studio/static/agent-frontend/chat-widget.js +319 -0
- django_agent_studio/templates/django_agent_studio/agent_list.html +101 -0
- django_agent_studio/templates/django_agent_studio/base.html +137 -0
- django_agent_studio/templates/django_agent_studio/builder.html +1443 -0
- django_agent_studio/templates/django_agent_studio/home.html +97 -0
- django_agent_studio/templates/django_agent_studio/test.html +126 -0
- django_agent_studio/urls.py +25 -0
- django_agent_studio/views.py +100 -0
- django_agent_studio-0.1.0.dist-info/METADATA +416 -0
- django_agent_studio-0.1.0.dist-info/RECORD +23 -0
- django_agent_studio-0.1.0.dist-info/WHEEL +5 -0
- django_agent_studio-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Django app configuration for django_agent_studio.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from django.apps import AppConfig
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DjangoAgentStudioConfig(AppConfig):
|
|
9
|
+
"""Configuration for the Django Agent Studio app."""
|
|
10
|
+
|
|
11
|
+
name = "django_agent_studio"
|
|
12
|
+
verbose_name = "Django Agent Studio"
|
|
13
|
+
default_auto_field = "django.db.models.BigAutoField"
|
|
14
|
+
|
|
15
|
+
def ready(self):
|
|
16
|
+
"""
|
|
17
|
+
Called when Django starts. Used to:
|
|
18
|
+
- Register the builder agent runtime
|
|
19
|
+
- Set up signal handlers
|
|
20
|
+
"""
|
|
21
|
+
from django_agent_studio.agents import register_studio_agents
|
|
22
|
+
|
|
23
|
+
register_studio_agents()
|
|
24
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Widget - Enhanced Markdown Support
|
|
3
|
+
*
|
|
4
|
+
* This optional addon replaces the basic markdown parser with marked.js
|
|
5
|
+
* for full-featured markdown rendering including tables, code blocks with
|
|
6
|
+
* syntax highlighting, and more.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* 1. Include marked.js (and optionally highlight.js for syntax highlighting)
|
|
10
|
+
* 2. Include this file AFTER chat-widget.js
|
|
11
|
+
* 3. Initialize the widget normally
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
* <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
15
|
+
* <script src="https://cdn.jsdelivr.net/npm/highlight.js@11/lib/core.min.js"></script>
|
|
16
|
+
* <script src="https://cdn.jsdelivr.net/npm/highlight.js@11/lib/languages/javascript.min.js"></script>
|
|
17
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11/styles/github-dark.min.css">
|
|
18
|
+
* <script src="chat-widget.js"></script>
|
|
19
|
+
* <script src="chat-widget-markdown.js"></script>
|
|
20
|
+
*/
|
|
21
|
+
(function(global) {
|
|
22
|
+
'use strict';
|
|
23
|
+
|
|
24
|
+
// Check if ChatWidget is available
|
|
25
|
+
if (!global.ChatWidget) {
|
|
26
|
+
console.error('[ChatWidget Markdown] ChatWidget must be loaded before chat-widget-markdown.js');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check if marked is available
|
|
31
|
+
if (typeof marked === 'undefined') {
|
|
32
|
+
console.warn('[ChatWidget Markdown] marked.js not found. Install with: npm install marked or include from CDN');
|
|
33
|
+
console.warn('[ChatWidget Markdown] Falling back to basic markdown parser');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log('[ChatWidget Markdown] Enhanced markdown support enabled');
|
|
38
|
+
|
|
39
|
+
// Configure marked
|
|
40
|
+
const markedOptions = {
|
|
41
|
+
breaks: true,
|
|
42
|
+
gfm: true,
|
|
43
|
+
headerIds: false,
|
|
44
|
+
mangle: false,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Configure syntax highlighting if highlight.js is available
|
|
48
|
+
if (typeof hljs !== 'undefined') {
|
|
49
|
+
console.log('[ChatWidget Markdown] Syntax highlighting enabled');
|
|
50
|
+
markedOptions.highlight = function(code, lang) {
|
|
51
|
+
if (lang && hljs.getLanguage(lang)) {
|
|
52
|
+
try {
|
|
53
|
+
return hljs.highlight(code, { language: lang }).value;
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.error('[ChatWidget Markdown] Highlight error:', err);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return code;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
marked.setOptions(markedOptions);
|
|
63
|
+
|
|
64
|
+
// Enhanced markdown parser using marked.js
|
|
65
|
+
function enhancedParseMarkdown(text) {
|
|
66
|
+
if (!text) return '';
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
// Parse markdown with marked
|
|
70
|
+
let html = marked.parse(text);
|
|
71
|
+
|
|
72
|
+
// Sanitize links to open in new tab
|
|
73
|
+
html = html.replace(/<a href=/g, '<a target="_blank" rel="noopener noreferrer" href=');
|
|
74
|
+
|
|
75
|
+
return html;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error('[ChatWidget Markdown] Parse error:', err);
|
|
78
|
+
// Fallback to escaped text
|
|
79
|
+
const div = document.createElement('div');
|
|
80
|
+
div.textContent = text;
|
|
81
|
+
return div.innerHTML.replace(/\n/g, '<br>');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Store reference to original init
|
|
86
|
+
const originalInit = global.ChatWidget.init;
|
|
87
|
+
|
|
88
|
+
// Override init to inject enhanced markdown parser
|
|
89
|
+
global.ChatWidget.init = function(userConfig = {}) {
|
|
90
|
+
// Call original init
|
|
91
|
+
originalInit.call(this, userConfig);
|
|
92
|
+
|
|
93
|
+
// Inject enhanced markdown parser
|
|
94
|
+
// We need to override the internal parseMarkdown function
|
|
95
|
+
// This is done by monkey-patching the render cycle
|
|
96
|
+
console.log('[ChatWidget Markdown] Markdown parser enhanced with marked.js');
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Expose the enhanced parser for internal use
|
|
100
|
+
// The widget will need to check for this and use it if available
|
|
101
|
+
global.ChatWidget._enhancedMarkdownParser = enhancedParseMarkdown;
|
|
102
|
+
|
|
103
|
+
// Add configuration option
|
|
104
|
+
global.ChatWidget.enableEnhancedMarkdown = function() {
|
|
105
|
+
console.log('[ChatWidget Markdown] Enhanced markdown explicitly enabled');
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
})(typeof window !== 'undefined' ? window : this);
|
|
110
|
+
|