GilbertClaus commited on
Commit
31d903b
·
1 Parent(s): 0f65d37
Files changed (1) hide show
  1. index.html +77 -14
index.html CHANGED
@@ -1,19 +1,82 @@
1
- <!doctype html>
2
- <html>
3
  <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </head>
9
  <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
 
 
 
 
17
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  </body>
19
- </html>
 
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>WSP ChatBot</title>
7
+ <link
8
+ rel="stylesheet"
9
+ href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" />
10
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
11
+ <style>
12
+ #response {
13
+ margin-top: 20px;
14
+ padding: 10px;
15
+ min-height: 50px;
16
+ }
17
+ #response h3 {
18
+ color: #333;
19
+ font-size: 1.2em;
20
+ }
21
+ #response strong {
22
+ color: #d9534f;
23
+ }
24
+ #response ul {
25
+ padding-left: 20px;
26
+ }
27
+ #response li {
28
+ margin-bottom: 5px;
29
+ }
30
+ </style>
31
  </head>
32
  <body>
33
+ <div class="container">
34
+ <h2>Free ChatBot</h2>
35
+ <div class="form-group">
36
+ <input
37
+ type="text"
38
+ class="form-control"
39
+ id="userInput"
40
+ placeholder="Enter your question" />
41
+ </div>
42
+ <button class="btn btn-success" onclick="sendMessage()">Ask!</button>
43
+ <div id="response"></div>
44
  </div>
45
+ <script>
46
+ async function sendMessage() {
47
+ const input = document.getElementById('userInput').value;
48
+ const responseDiv = document.getElementById('response');
49
+ if (!input) {
50
+ responseDiv.innerHTML = 'Please enter a message.';
51
+ return;
52
+ }
53
+ responseDiv.innerHTML = 'Loading...';
54
+ try {
55
+ const response = await fetch(
56
+ 'https://openrouter.ai/api/v1/chat/completions',
57
+ {
58
+ method: 'POST',
59
+ headers: {
60
+ Authorization: 'Bearer <API Key from Open Router>',
61
+ 'HTTP-Referer': 'https://www.sitename.com',
62
+ 'X-Title': 'SiteName',
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ body: JSON.stringify({
66
+ model: 'deepseek/deepseek-r1:free',
67
+ messages: [{ role: 'user', content: input }],
68
+ }),
69
+ },
70
+ );
71
+ const data = await response.json();
72
+ console.log(data);
73
+ const markdownText =
74
+ data.choices?.[0]?.message?.content || 'No response received.';
75
+ responseDiv.innerHTML = marked.parse(markdownText);
76
+ } catch (error) {
77
+ responseDiv.innerHTML = 'Error: ' + error.message;
78
+ }
79
+ }
80
+ </script>
81
  </body>
82
+ </html>