OK NOW MAK IT A WORKING 100 PERCENT WITH LM STIDIOS
Browse files- chat.html +78 -43
- index.html +6 -6
chat.html
CHANGED
|
@@ -140,57 +140,92 @@ waypoint.SetType(EWaypointType.MOVE);</pre>
|
|
| 140 |
</div>
|
| 141 |
</div>
|
| 142 |
</div>
|
| 143 |
-
|
| 144 |
<script>
|
| 145 |
// Initialize feather icons
|
| 146 |
feather.replace();
|
| 147 |
|
| 148 |
-
//
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
e.preventDefault();
|
| 151 |
-
const
|
| 152 |
-
const message = input.value.trim();
|
| 153 |
|
| 154 |
if (message) {
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
const userMsg = document.createElement('div');
|
| 158 |
-
userMsg.className = 'flex justify-end';
|
| 159 |
-
userMsg.innerHTML = `
|
| 160 |
-
<div class="user-bubble max-w-3xl p-4">
|
| 161 |
-
<p>${message}</p>
|
| 162 |
-
</div>
|
| 163 |
-
`;
|
| 164 |
-
chatContainer.appendChild(userMsg);
|
| 165 |
-
|
| 166 |
-
// Clear input
|
| 167 |
-
input.value = '';
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
// Add AI response
|
| 181 |
-
const aiMsg = document.createElement('div');
|
| 182 |
-
aiMsg.className = 'flex';
|
| 183 |
-
aiMsg.innerHTML = `
|
| 184 |
-
<div class="ai-bubble max-w-3xl p-4">
|
| 185 |
-
<p>Thanks for your question about Arma Reforger modding. I'm currently a demo interface, but in a real implementation, I would provide detailed guidance on "${message}".</p>
|
| 186 |
-
<p class="mt-2">For real help, this would connect to an AI backend trained on Arma Reforger documentation and modding resources.</p>
|
| 187 |
-
</div>
|
| 188 |
-
`;
|
| 189 |
-
chatContainer.appendChild(aiMsg);
|
| 190 |
-
|
| 191 |
-
// Scroll to bottom
|
| 192 |
-
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 193 |
-
}, 2000);
|
| 194 |
}
|
| 195 |
});
|
| 196 |
</script>
|
|
|
|
| 140 |
</div>
|
| 141 |
</div>
|
| 142 |
</div>
|
|
|
|
| 143 |
<script>
|
| 144 |
// Initialize feather icons
|
| 145 |
feather.replace();
|
| 146 |
|
| 147 |
+
// Connect to LM Studio API
|
| 148 |
+
const API_URL = 'http://localhost:1234/v1/chat/completions';
|
| 149 |
+
const chatContainer = document.querySelector('.chat-container');
|
| 150 |
+
const chatForm = document.getElementById('chatForm');
|
| 151 |
+
const userInput = document.getElementById('userInput');
|
| 152 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
| 153 |
+
|
| 154 |
+
// Add message to chat
|
| 155 |
+
function addMessage(role, content) {
|
| 156 |
+
const msgDiv = document.createElement('div');
|
| 157 |
+
msgDiv.className = role === 'user' ? 'flex justify-end' : 'flex';
|
| 158 |
+
|
| 159 |
+
const bubbleClass = role === 'user' ? 'user-bubble' : 'ai-bubble';
|
| 160 |
+
msgDiv.innerHTML = `
|
| 161 |
+
<div class="${bubbleClass} max-w-3xl p-4">
|
| 162 |
+
<p>${content}</p>
|
| 163 |
+
</div>
|
| 164 |
+
`;
|
| 165 |
+
|
| 166 |
+
chatContainer.appendChild(msgDiv);
|
| 167 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
// Get AI response
|
| 171 |
+
async function getAIResponse(prompt) {
|
| 172 |
+
typingIndicator.classList.remove('hidden');
|
| 173 |
+
|
| 174 |
+
try {
|
| 175 |
+
const response = await fetch(API_URL, {
|
| 176 |
+
method: 'POST',
|
| 177 |
+
headers: {
|
| 178 |
+
'Content-Type': 'application/json'
|
| 179 |
+
},
|
| 180 |
+
body: JSON.stringify({
|
| 181 |
+
model: 'local-model', // Should match your LM Studio model
|
| 182 |
+
messages: [
|
| 183 |
+
{
|
| 184 |
+
role: 'system',
|
| 185 |
+
content: 'You are ArmaForge Assistant, an expert in Arma Reforger modding and scripting. Provide detailed, technical answers with code examples when possible. Format code blocks properly.'
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
role: 'user',
|
| 189 |
+
content: prompt
|
| 190 |
+
}
|
| 191 |
+
],
|
| 192 |
+
temperature: 0.7,
|
| 193 |
+
max_tokens: 2000,
|
| 194 |
+
stream: false
|
| 195 |
+
})
|
| 196 |
+
});
|
| 197 |
+
|
| 198 |
+
if (!response.ok) throw new Error('Network response was not ok');
|
| 199 |
+
|
| 200 |
+
const data = await response.json();
|
| 201 |
+
return data.choices[0].message.content;
|
| 202 |
+
} catch (error) {
|
| 203 |
+
console.error('Error:', error);
|
| 204 |
+
return "Sorry, I encountered an error. Please ensure LM Studio is running and the API is accessible at http://localhost:1234";
|
| 205 |
+
} finally {
|
| 206 |
+
typingIndicator.classList.add('hidden');
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
// Handle form submission
|
| 211 |
+
chatForm.addEventListener('submit', async function(e) {
|
| 212 |
e.preventDefault();
|
| 213 |
+
const message = userInput.value.trim();
|
|
|
|
| 214 |
|
| 215 |
if (message) {
|
| 216 |
+
addMessage('user', message);
|
| 217 |
+
userInput.value = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
+
const aiResponse = await getAIResponse(message);
|
| 220 |
+
addMessage('assistant', aiResponse);
|
| 221 |
+
}
|
| 222 |
+
});
|
| 223 |
+
|
| 224 |
+
// Allow Shift+Enter for new lines, Enter to submit
|
| 225 |
+
userInput.addEventListener('keydown', function(e) {
|
| 226 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
| 227 |
+
e.preventDefault();
|
| 228 |
+
chatForm.dispatchEvent(new Event('submit'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
}
|
| 230 |
});
|
| 231 |
</script>
|
index.html
CHANGED
|
@@ -46,10 +46,10 @@
|
|
| 46 |
<a href="#" class="text-teal-300 hover:text-white font-medium flex items-center">
|
| 47 |
<i data-feather="book" class="mr-2"></i> Docs
|
| 48 |
</a>
|
| 49 |
-
<a href="
|
| 50 |
-
<i data-feather="message-square" class="mr-2"></i>
|
| 51 |
</a>
|
| 52 |
-
|
| 53 |
</header>
|
| 54 |
|
| 55 |
<!-- Hero Section -->
|
|
@@ -59,10 +59,10 @@
|
|
| 59 |
Get instant help with script debugging, mod creation, and troubleshooting for Arma Reforger.
|
| 60 |
</p>
|
| 61 |
<div class="flex justify-center space-x-4">
|
| 62 |
-
<
|
| 63 |
<i data-feather="terminal" class="mr-2"></i> Start Modding Chat
|
| 64 |
-
</
|
| 65 |
-
|
| 66 |
<i data-feather="download" class="mr-2"></i> Get Templates
|
| 67 |
</button>
|
| 68 |
</div>
|
|
|
|
| 46 |
<a href="#" class="text-teal-300 hover:text-white font-medium flex items-center">
|
| 47 |
<i data-feather="book" class="mr-2"></i> Docs
|
| 48 |
</a>
|
| 49 |
+
<a href="chat.html" class="text-teal-300 hover:text-white font-medium flex items-center">
|
| 50 |
+
<i data-feather="message-square" class="mr-2"></i> Chat
|
| 51 |
</a>
|
| 52 |
+
</nav>
|
| 53 |
</header>
|
| 54 |
|
| 55 |
<!-- Hero Section -->
|
|
|
|
| 59 |
Get instant help with script debugging, mod creation, and troubleshooting for Arma Reforger.
|
| 60 |
</p>
|
| 61 |
<div class="flex justify-center space-x-4">
|
| 62 |
+
<a href="chat.html" class="bg-teal-600 hover:bg-teal-500 text-white px-6 py-3 rounded-lg font-medium flex items-center transition">
|
| 63 |
<i data-feather="terminal" class="mr-2"></i> Start Modding Chat
|
| 64 |
+
</a>
|
| 65 |
+
<button class="border border-teal-400 text-teal-400 hover:bg-teal-900/50 px-6 py-3 rounded-lg font-medium flex items-center transition">
|
| 66 |
<i data-feather="download" class="mr-2"></i> Get Templates
|
| 67 |
</button>
|
| 68 |
</div>
|