Sibi Krishnamoorthy commited on
Commit ·
6fa1bad
1
Parent(s): 5ce04dd
fix internal network
Browse files- Dockerfile +1 -0
- frontend/src/App.js +4 -2
- frontend/src/components/StorageManager.js +6 -2
Dockerfile
CHANGED
|
@@ -4,6 +4,7 @@ WORKDIR /app/frontend
|
|
| 4 |
COPY frontend/package.json frontend/package-lock.json* ./
|
| 5 |
RUN npm install
|
| 6 |
COPY frontend/ ./
|
|
|
|
| 7 |
RUN npm run build
|
| 8 |
|
| 9 |
# Stage 2: Setup Backend
|
|
|
|
| 4 |
COPY frontend/package.json frontend/package-lock.json* ./
|
| 5 |
RUN npm install
|
| 6 |
COPY frontend/ ./
|
| 7 |
+
ENV REACT_APP_BACKEND_URL=http://0.0.0.0:7860
|
| 8 |
RUN npm run build
|
| 9 |
|
| 10 |
# Stage 2: Setup Backend
|
frontend/src/App.js
CHANGED
|
@@ -25,6 +25,8 @@ import './App.css';
|
|
| 25 |
import StorageManager from './components/StorageManager'; // Import StorageManager
|
| 26 |
|
| 27 |
function App() {
|
|
|
|
|
|
|
| 28 |
const [sessions, setSessions] = useState(() => {
|
| 29 |
const saved = localStorage.getItem('chat_sessions');
|
| 30 |
return saved ? JSON.parse(saved) : [];
|
|
@@ -124,7 +126,7 @@ function App() {
|
|
| 124 |
|
| 125 |
try {
|
| 126 |
setIsLoading(true);
|
| 127 |
-
const response = await axios.post(
|
| 128 |
headers: { 'Content-Type': 'multipart/form-data' }
|
| 129 |
});
|
| 130 |
|
|
@@ -174,7 +176,7 @@ function App() {
|
|
| 174 |
setIsLoading(true);
|
| 175 |
|
| 176 |
try {
|
| 177 |
-
const response = await axios.post(
|
| 178 |
query: userMessage,
|
| 179 |
file_path: uploadedFile?.path || null
|
| 180 |
});
|
|
|
|
| 25 |
import StorageManager from './components/StorageManager'; // Import StorageManager
|
| 26 |
|
| 27 |
function App() {
|
| 28 |
+
// Use environment variable for backend URL, default to http://localhost:7860
|
| 29 |
+
const BACKEND_URL = process.env.REACT_APP_BACKEND_URL || 'http://localhost:7860';
|
| 30 |
const [sessions, setSessions] = useState(() => {
|
| 31 |
const saved = localStorage.getItem('chat_sessions');
|
| 32 |
return saved ? JSON.parse(saved) : [];
|
|
|
|
| 126 |
|
| 127 |
try {
|
| 128 |
setIsLoading(true);
|
| 129 |
+
const response = await axios.post(`${BACKEND_URL}/upload`, formData, {
|
| 130 |
headers: { 'Content-Type': 'multipart/form-data' }
|
| 131 |
});
|
| 132 |
|
|
|
|
| 176 |
setIsLoading(true);
|
| 177 |
|
| 178 |
try {
|
| 179 |
+
const response = await axios.post(`${BACKEND_URL}/chat`, {
|
| 180 |
query: userMessage,
|
| 181 |
file_path: uploadedFile?.path || null
|
| 182 |
});
|
frontend/src/components/StorageManager.js
CHANGED
|
@@ -7,10 +7,14 @@ const StorageManager = () => {
|
|
| 7 |
const [cleanupAge, setCleanupAge] = useState(24);
|
| 8 |
const [message, setMessage] = useState('');
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
const fetchStorageInfo = async () => {
|
| 11 |
setLoading(true);
|
| 12 |
try {
|
| 13 |
-
const response = await axios.get(
|
| 14 |
setStorageInfo(response.data);
|
| 15 |
setMessage('');
|
| 16 |
} catch (error) {
|
|
@@ -24,7 +28,7 @@ const StorageManager = () => {
|
|
| 24 |
const handleCleanup = async () => {
|
| 25 |
setLoading(true);
|
| 26 |
try {
|
| 27 |
-
const response = await axios.post(
|
| 28 |
setMessage(response.data.message);
|
| 29 |
fetchStorageInfo(); // Refresh info after cleanup
|
| 30 |
} catch (error) {
|
|
|
|
| 7 |
const [cleanupAge, setCleanupAge] = useState(24);
|
| 8 |
const [message, setMessage] = useState('');
|
| 9 |
|
| 10 |
+
|
| 11 |
+
// Use environment variable for backend URL, default to http://localhost:7860
|
| 12 |
+
const BACKEND_URL = process.env.REACT_APP_BACKEND_URL || 'http://localhost:7860';
|
| 13 |
+
|
| 14 |
const fetchStorageInfo = async () => {
|
| 15 |
setLoading(true);
|
| 16 |
try {
|
| 17 |
+
const response = await axios.get(`${BACKEND_URL}/storage/info`);
|
| 18 |
setStorageInfo(response.data);
|
| 19 |
setMessage('');
|
| 20 |
} catch (error) {
|
|
|
|
| 28 |
const handleCleanup = async () => {
|
| 29 |
setLoading(true);
|
| 30 |
try {
|
| 31 |
+
const response = await axios.post(`${BACKEND_URL}/storage/cleanup?max_age_hours=${cleanupAge}`);
|
| 32 |
setMessage(response.data.message);
|
| 33 |
fetchStorageInfo(); // Refresh info after cleanup
|
| 34 |
} catch (error) {
|