Skip to content

Commit f80028f

Browse files
committed
feat: allow selecting model when sending message to AI
1 parent 6c5440b commit f80028f

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ function RemoteFunctions(config) {
15501550
// AI prompt box, it is displayed when user clicks on the AI button in the more options box
15511551
function AIPromptBox(element) {
15521552
this.element = element;
1553+
this.selectedModel = 'fast';
15531554
this.remove = this.remove.bind(this);
15541555
this.create();
15551556
}
@@ -1645,9 +1646,6 @@ function RemoteFunctions(config) {
16451646
}
16461647
16471648
.phoenix-ai-prompt-send-button {
1648-
position: absolute;
1649-
right: 12px;
1650-
bottom: 8px;
16511649
width: 28px;
16521650
height: 28px;
16531651
border: none;
@@ -1672,6 +1670,30 @@ function RemoteFunctions(config) {
16721670
color: #9aa0a6;
16731671
cursor: not-allowed;
16741672
}
1673+
1674+
.phoenix-ai-bottom-controls {
1675+
border-top: 1px solid #e0e0e0;
1676+
padding: 8px 16px;
1677+
background: #f9f9f9;
1678+
border-radius: 0 0 8px 8px;
1679+
display: flex;
1680+
align-items: center;
1681+
justify-content: space-between;
1682+
}
1683+
1684+
.phoenix-ai-model-select {
1685+
padding: 4px 8px;
1686+
border: 1px solid #ddd;
1687+
border-radius: 4px;
1688+
font-size: 12px;
1689+
background: white;
1690+
outline: none;
1691+
cursor: pointer;
1692+
}
1693+
1694+
.phoenix-ai-model-select:focus {
1695+
border-color: #4285F4;
1696+
}
16751697
`;
16761698

16771699
const content = `
@@ -1681,6 +1703,13 @@ function RemoteFunctions(config) {
16811703
class="phoenix-ai-prompt-textarea"
16821704
placeholder="${config.strings.aiPromptPlaceholder}"
16831705
></textarea>
1706+
</div>
1707+
<div class="phoenix-ai-bottom-controls">
1708+
<select class="phoenix-ai-model-select">
1709+
<option value="fast">Fast AI</option>
1710+
<option value="moderate">Moderate AI</option>
1711+
<option value="slow">Slow AI</option>
1712+
</select>
16841713
<button class="phoenix-ai-prompt-send-button" disabled>
16851714
16861715
</button>
@@ -1723,6 +1752,7 @@ function RemoteFunctions(config) {
17231752
_attachEventHandlers: function() {
17241753
const textarea = this._shadow.querySelector('.phoenix-ai-prompt-textarea');
17251754
const sendButton = this._shadow.querySelector('.phoenix-ai-prompt-send-button');
1755+
const modelSelect = this._shadow.querySelector('.phoenix-ai-model-select');
17261756

17271757
// Handle textarea input to enable/disable send button
17281758
if (textarea && sendButton) {
@@ -1755,6 +1785,13 @@ function RemoteFunctions(config) {
17551785
}
17561786
});
17571787
}
1788+
1789+
// model selection change
1790+
if (modelSelect) {
1791+
modelSelect.addEventListener('change', (event) => {
1792+
this.selectedModel = event.target.value;
1793+
});
1794+
}
17581795
},
17591796

17601797
_handleSend: function(event, prompt) {
@@ -1770,6 +1807,7 @@ function RemoteFunctions(config) {
17701807
element: element,
17711808
prompt: prompt,
17721809
tagId: Number(tagId),
1810+
selectedModel: this.selectedModel,
17731811
AISend: true
17741812
});
17751813
this.remove();

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ define(function (require, exports, module) {
551551
tagId: message.tagId, // the data-brackets-id of the element which was selected for AI edit
552552
range: {startPos, endPos}, // the start and end position text in the source code for that element
553553
text: text, // the actual source code in between the start and the end pos
554-
prompt: message.prompt // the prompt that user typed
554+
prompt: message.prompt, // the prompt that user typed
555+
model: message.selectedModel // the selected model (fast, slow or moderate)
555556
};
556557

557558
return AIData;

0 commit comments

Comments
 (0)