Spaces:
Running
Running
A-Mahla
commited on
Commit
·
51747e6
1
Parent(s):
a104b34
Amir/patch 2 (#9)
Browse files* FIX import
* FIX Route front -> back
cua2-core/src/cua2_core/app.py
CHANGED
|
@@ -55,12 +55,7 @@ app = FastAPI(
|
|
| 55 |
app.add_middleware(
|
| 56 |
CORSMiddleware,
|
| 57 |
allow_origins=[
|
| 58 |
-
"
|
| 59 |
-
"http://localhost:5173", # Vite dev server
|
| 60 |
-
"http://localhost:8080", # Alternative frontend port
|
| 61 |
-
"http://127.0.0.1:3000",
|
| 62 |
-
"http://127.0.0.1:5173",
|
| 63 |
-
"http://127.0.0.1:8080",
|
| 64 |
],
|
| 65 |
allow_credentials=True,
|
| 66 |
allow_methods=["*"],
|
|
|
|
| 55 |
app.add_middleware(
|
| 56 |
CORSMiddleware,
|
| 57 |
allow_origins=[
|
| 58 |
+
"*",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
],
|
| 60 |
allow_credentials=True,
|
| 61 |
allow_methods=["*"],
|
cua2-core/src/cua2_core/main.py
CHANGED
|
@@ -6,7 +6,7 @@ from cua2_core.routes.routes import router
|
|
| 6 |
from cua2_core.routes.websocket import router as websocket_router
|
| 7 |
|
| 8 |
# Include routes
|
| 9 |
-
app.include_router(router, prefix="/api
|
| 10 |
app.include_router(websocket_router)
|
| 11 |
|
| 12 |
|
|
|
|
| 6 |
from cua2_core.routes.websocket import router as websocket_router
|
| 7 |
|
| 8 |
# Include routes
|
| 9 |
+
app.include_router(router, prefix="/api")
|
| 10 |
app.include_router(websocket_router)
|
| 11 |
|
| 12 |
|
cua2-front/src/App.tsx
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
|
|
| 1 |
import { useMemo } from 'react';
|
| 2 |
-
import { BrowserRouter,
|
| 3 |
-
import {
|
| 4 |
-
import getTheme from './theme';
|
| 5 |
-
import Welcome from "./pages/Welcome";
|
| 6 |
-
import Task from "./pages/Task";
|
| 7 |
-
import { useAgentStore, selectIsDarkMode } from './stores/agentStore';
|
| 8 |
import { useAgentWebSocket } from './hooks/useAgentWebSocket';
|
| 9 |
-
import
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
const App = () => {
|
| 12 |
const isDarkMode = useAgentStore(selectIsDarkMode);
|
| 13 |
const theme = useMemo(() => getTheme(isDarkMode ? 'dark' : 'light'), [isDarkMode]);
|
| 14 |
|
| 15 |
// Initialize WebSocket connection at app level so it persists across route changes
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
return (
|
| 19 |
<ThemeProvider theme={theme}>
|
|
|
|
| 1 |
+
import { CssBaseline, ThemeProvider } from '@mui/material';
|
| 2 |
import { useMemo } from 'react';
|
| 3 |
+
import { BrowserRouter, Route, Routes } from "react-router-dom";
|
| 4 |
+
import { getWebSocketUrl } from './config/api';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import { useAgentWebSocket } from './hooks/useAgentWebSocket';
|
| 6 |
+
import Task from "./pages/Task";
|
| 7 |
+
import Welcome from "./pages/Welcome";
|
| 8 |
+
import { selectIsDarkMode, useAgentStore } from './stores/agentStore';
|
| 9 |
+
import getTheme from './theme';
|
| 10 |
|
| 11 |
const App = () => {
|
| 12 |
const isDarkMode = useAgentStore(selectIsDarkMode);
|
| 13 |
const theme = useMemo(() => getTheme(isDarkMode ? 'dark' : 'light'), [isDarkMode]);
|
| 14 |
|
| 15 |
// Initialize WebSocket connection at app level so it persists across route changes
|
| 16 |
+
|
| 17 |
+
useAgentWebSocket({ url: getWebSocketUrl() });
|
| 18 |
|
| 19 |
return (
|
| 20 |
<ThemeProvider theme={theme}>
|
cua2-front/src/services/api.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
import {
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Fetch available models from the backend
|
| 5 |
*/
|
| 6 |
export async function fetchAvailableModels(): Promise<string[]> {
|
| 7 |
-
const response = await fetch(`${
|
| 8 |
if (!response.ok) {
|
| 9 |
throw new Error('Failed to fetch models');
|
| 10 |
}
|
|
@@ -16,7 +16,7 @@ export async function fetchAvailableModels(): Promise<string[]> {
|
|
| 16 |
* Generate a random instruction from the backend
|
| 17 |
*/
|
| 18 |
export async function generateRandomQuestion(modelId: string): Promise<string> {
|
| 19 |
-
const response = await fetch(`${
|
| 20 |
method: 'POST',
|
| 21 |
headers: {
|
| 22 |
'Content-Type': 'application/json',
|
|
@@ -40,7 +40,7 @@ export async function updateStepEvaluation(
|
|
| 40 |
stepId: string,
|
| 41 |
evaluation: 'like' | 'dislike' | 'neutral'
|
| 42 |
): Promise<void> {
|
| 43 |
-
const response = await fetch(`${
|
| 44 |
method: 'PATCH',
|
| 45 |
headers: {
|
| 46 |
'Content-Type': 'application/json',
|
|
|
|
| 1 |
+
import { getApiBaseUrl } from '@/config/api';
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Fetch available models from the backend
|
| 5 |
*/
|
| 6 |
export async function fetchAvailableModels(): Promise<string[]> {
|
| 7 |
+
const response = await fetch(`${getApiBaseUrl()}/models`);
|
| 8 |
if (!response.ok) {
|
| 9 |
throw new Error('Failed to fetch models');
|
| 10 |
}
|
|
|
|
| 16 |
* Generate a random instruction from the backend
|
| 17 |
*/
|
| 18 |
export async function generateRandomQuestion(modelId: string): Promise<string> {
|
| 19 |
+
const response = await fetch(`${getApiBaseUrl()}/generate-instruction`, {
|
| 20 |
method: 'POST',
|
| 21 |
headers: {
|
| 22 |
'Content-Type': 'application/json',
|
|
|
|
| 40 |
stepId: string,
|
| 41 |
evaluation: 'like' | 'dislike' | 'neutral'
|
| 42 |
): Promise<void> {
|
| 43 |
+
const response = await fetch(`${getApiBaseUrl()}/traces/${traceId}/steps/${stepId}`, {
|
| 44 |
method: 'PATCH',
|
| 45 |
headers: {
|
| 46 |
'Content-Type': 'application/json',
|