DINGOLANI commited on
Commit
4291c82
·
verified ·
1 Parent(s): ea7acd3

Create frontend/src/App.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/App.jsx +59 -0
frontend/src/App.jsx ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from "react";
2
+ import "./styles.css";
3
+
4
+ const App = () => {
5
+ const [query, setQuery] = useState("");
6
+ const [output, setOutput] = useState(null);
7
+ const [loading, setLoading] = useState(false);
8
+
9
+ const fetchPrediction = async () => {
10
+ setLoading(true);
11
+ setOutput(null);
12
+
13
+ const response = await fetch("https://your-space-url.hf.space/predict/", {
14
+ method: "POST",
15
+ headers: { "Content-Type": "application/json" },
16
+ body: JSON.stringify({ query }),
17
+ });
18
+
19
+ const data = await response.json();
20
+ setOutput(data.output);
21
+ setLoading(false);
22
+ };
23
+
24
+ return (
25
+ <div className="container">
26
+ <h1 className="title">Luxury NER Extractor</h1>
27
+ <p className="subtitle">Enter a sentence and extract structured data</p>
28
+
29
+ <div className="input-section">
30
+ <input
31
+ type="text"
32
+ placeholder="e.g. Luxury bags for women above $2000"
33
+ value={query}
34
+ onChange={(e) => setQuery(e.target.value)}
35
+ className="input-box"
36
+ />
37
+ <button onClick={fetchPrediction} className="analyze-button">
38
+ {loading ? "Analyzing..." : "Analyze"}
39
+ </button>
40
+ </div>
41
+
42
+ {output && (
43
+ <div className="output-section">
44
+ <h2>Extracted Information</h2>
45
+ <div className="result-box">
46
+ {Object.entries(output).map(([key, value]) => (
47
+ <div key={key} className="entity">
48
+ <span className="entity-type">{key}</span>:{" "}
49
+ <span className="entity-value">{value.join(", ")}</span>
50
+ </div>
51
+ ))}
52
+ </div>
53
+ </div>
54
+ )}
55
+ </div>
56
+ );
57
+ };
58
+
59
+ export default App;