File size: 1,353 Bytes
b6d77d3
 
 
 
 
 
2fd2129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b6d77d3
 
 
 
 
 
2fd2129
b6d77d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <title>HubRAG</title>
  <style>
    body {
      font-family: sans-serif;
      max-width: 800px;
      margin: 40px auto;
    }
    textarea {
      width: 100%;
      padding: 10px;
    }
    button {
      margin-top: 10px;
      padding: 8px 16px;
    }
    pre {
      background: #f5f5f5;
      padding: 10px;
      white-space: pre-wrap;
    }
  </style>
</head>
<body>

<h2>📄 HubRAG (HF Space)</h2>

<textarea id="q" rows="4" placeholder="Ask a question about the documents..."></textarea>
<br/>
<button onclick="ask()">Ask</button>

<h3>Status</h3>
<ul id="status"></ul>

<h3>Answer</h3>
<pre id="answer"></pre>

<script>
async function ask() {
  const q = document.getElementById("q").value;
  document.getElementById("answer").textContent = "Thinking...";
  document.getElementById("status").innerHTML = "";

  const res = await fetch("/chat", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ question: q })
  });

  const data = await res.json();

  document.getElementById("answer").textContent =
    data.answer || "No answer";

  (data.status || []).forEach(s => {
    const li = document.createElement("li");
    li.textContent = s;
    document.getElementById("status").appendChild(li);
  });
}
</script>

</body>
</html>