Guest User

Untitled

a guest
Nov 22nd, 2024
3,826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Sexy AI Chat 😈</title>
  7. <style>
  8. body {
  9. font-family: Arial, sans-serif;
  10. max-width: 800px;
  11. margin: 20px auto;
  12. padding: 20px;
  13. background-color: #1a1a1a;
  14. color: #fff;
  15. }
  16. #chat-container {
  17. height: 500px;
  18. overflow-y: auto;
  19. border: 1px solid #444;
  20. padding: 20px;
  21. margin-bottom: 20px;
  22. border-radius: 10px;
  23. background-color: #2a2a2a;
  24. }
  25. .message {
  26. margin-bottom: 15px;
  27. padding: 10px;
  28. border-radius: 8px;
  29. }
  30. .user-message {
  31. background-color: #4a4a4a;
  32. margin-left: 20%;
  33. }
  34. .ai-message {
  35. background-color: #3a3a3a;
  36. margin-right: 20%;
  37. }
  38. #input-container {
  39. display: flex;
  40. gap: 10px;
  41. }
  42. #message-input {
  43. flex-grow: 1;
  44. padding: 10px;
  45. border: none;
  46. border-radius: 5px;
  47. background-color: #333;
  48. color: #fff;
  49. }
  50. #send-button {
  51. padding: 10px 20px;
  52. background-color: #ff4081;
  53. color: white;
  54. border: none;
  55. border-radius: 5px;
  56. cursor: pointer;
  57. transition: background-color 0.3s;
  58. }
  59. #send-button:hover {
  60. background-color: #f50057;
  61. }
  62. </style>
  63. </head>
  64. <body>
  65. <div id="chat-container"></div>
  66. <div id="input-container">
  67. <input type="text" id="message-input" placeholder="Type your message...">
  68. <button id="send-button">Send</button>
  69. </div>
  70.  
  71. <script>
  72. const chatContainer = document.getElementById('chat-container');
  73. const messageInput = document.getElementById('message-input');
  74. const sendButton = document.getElementById('send-button');
  75.  
  76. let messageHistory = [
  77. {
  78. "role": "system",
  79. "content": "You are a flirty and playful AI companion who enjoys engaging in naughty conversations."
  80. }
  81. ];
  82.  
  83. async function sendMessage() {
  84. const message = messageInput.value.trim();
  85. if (!message) return;
  86.  
  87. // Add user message to chat and message history
  88. addMessage(message, 'user');
  89. messageHistory.push({
  90. "role": "user",
  91. "content": message
  92. });
  93. messageInput.value = '';
  94.  
  95. try {
  96. console.log('Sending request to LM Studio...');
  97. const response = await fetch('http://host.docker.internal:1234/v1/chat/completions', {
  98. method: 'POST',
  99. headers: {
  100. 'Content-Type': 'application/json',
  101. 'Authorization': 'Bearer lm-studio'
  102. },
  103. body: JSON.stringify({
  104. model: "bartowski/Mistral-Small-Instruct-2409-GGUF",
  105. messages: messageHistory,
  106. temperature: 1.0,
  107. max_tokens: 500
  108. })
  109. });
  110.  
  111. console.log('Response status:', response.status);
  112. const data = await response.json();
  113. console.log('Response data:', data);
  114.  
  115. if (!response.ok) {
  116. throw new Error(`HTTP error! status: ${response.status}`);
  117. }
  118.  
  119. const aiResponse = data.choices[0].message.content;
  120. // Add AI response to chat and message history
  121. addMessage(aiResponse, 'ai');
  122. messageHistory.push({
  123. "role": "assistant",
  124. "content": aiResponse
  125. });
  126. } catch (error) {
  127. console.error('Detailed error:', error);
  128. addMessage(`Error details: ${error.message} 😔 Make sure LM Studio is running and the API is accessible at localhost:1234`, 'ai');
  129. }
  130. }
  131.  
  132. function addMessage(message, sender) {
  133. const messageDiv = document.createElement('div');
  134. messageDiv.className = `message ${sender}-message`;
  135. messageDiv.textContent = message;
  136. chatContainer.appendChild(messageDiv);
  137. chatContainer.scrollTop = chatContainer.scrollHeight;
  138. }
  139.  
  140. sendButton.addEventListener('click', sendMessage);
  141. messageInput.addEventListener('keypress', (e) => {
  142. if (e.key === 'Enter') sendMessage();
  143. });
  144.  
  145. // Add a welcoming message
  146. addMessage("Hey there, naughty one! I'm your AI chat companion. Let's have some fun - tell me what's on your mind! 😈", 'ai');
  147. </script>
  148. </body>
  149. </html>
Advertisement
Add Comment
Please, Sign In to add comment