mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +00:00
First front & backend integration
This commit is contained in:
parent
592c7e6915
commit
d1954ff326
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,12 +1,12 @@
|
|||||||
*.wav
|
*.wav
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
*.log
|
*.log
|
||||||
cookies.json
|
|
||||||
*.tmp
|
*.tmp
|
||||||
*.safetensors
|
*.safetensors
|
||||||
config.ini
|
|
||||||
test_agent.py
|
|
||||||
*.egg-info
|
*.egg-info
|
||||||
|
cookies.json
|
||||||
|
test_agent.py
|
||||||
|
config.ini
|
||||||
.voices/
|
.voices/
|
||||||
experimental/
|
experimental/
|
||||||
conversations/
|
conversations/
|
||||||
@ -15,6 +15,19 @@ agentic_env/*
|
|||||||
*/.env
|
*/.env
|
||||||
dsk/
|
dsk/
|
||||||
|
|
||||||
|
### react ###
|
||||||
|
.DS_*
|
||||||
|
*.log
|
||||||
|
logs
|
||||||
|
**/*.backup.*
|
||||||
|
**/*.back.*
|
||||||
|
node_modules
|
||||||
|
bower_components
|
||||||
|
*.sublime*
|
||||||
|
psd
|
||||||
|
thumb
|
||||||
|
sketch
|
||||||
|
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
186
app.py
Normal file
186
app.py
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import configparser
|
||||||
|
from typing import List
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
|
import uvicorn
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
|
from sources.llm_provider import Provider
|
||||||
|
from sources.interaction import Interaction
|
||||||
|
from sources.agents import CasualAgent, CoderAgent, FileAgent, PlannerAgent, BrowserAgent
|
||||||
|
from sources.browser import Browser, create_driver
|
||||||
|
from sources.utility import pretty_print
|
||||||
|
from sources.logger import Logger
|
||||||
|
from sources.schemas import QueryRequest, QueryResponse
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read('config.ini')
|
||||||
|
app = FastAPI(title="AgenticSeek API", version="0.1.0")
|
||||||
|
logger = Logger("backend.log")
|
||||||
|
|
||||||
|
app.mount("/screenshots", StaticFiles(directory=".screenshots"), name="screenshots")
|
||||||
|
|
||||||
|
# Add CORS middleware to allow frontend requests
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["http://localhost:3000"],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def initialize_system():
|
||||||
|
stealth_mode = config.getboolean('BROWSER', 'stealth_mode')
|
||||||
|
personality_folder = "jarvis" if config.getboolean('MAIN', 'jarvis_personality') else "base"
|
||||||
|
languages = config["MAIN"]["languages"].split(' ')
|
||||||
|
|
||||||
|
provider = Provider(
|
||||||
|
provider_name=config["MAIN"]["provider_name"],
|
||||||
|
model=config["MAIN"]["provider_model"],
|
||||||
|
server_address=config["MAIN"]["provider_server_address"],
|
||||||
|
is_local=config.getboolean('MAIN', 'is_local')
|
||||||
|
)
|
||||||
|
logger.info(f"Provider initialized: {provider.provider_name} ({provider.model})")
|
||||||
|
|
||||||
|
browser = Browser(
|
||||||
|
create_driver(headless=config.getboolean('BROWSER', 'headless_browser'), stealth_mode=stealth_mode),
|
||||||
|
anticaptcha_manual_install=stealth_mode
|
||||||
|
)
|
||||||
|
logger.info("Browser initialized")
|
||||||
|
|
||||||
|
agents = [
|
||||||
|
CasualAgent(
|
||||||
|
name=config["MAIN"]["agent_name"],
|
||||||
|
prompt_path=f"prompts/{personality_folder}/casual_agent.txt",
|
||||||
|
provider=provider, verbose=False
|
||||||
|
),
|
||||||
|
CoderAgent(
|
||||||
|
name="coder",
|
||||||
|
prompt_path=f"prompts/{personality_folder}/coder_agent.txt",
|
||||||
|
provider=provider, verbose=False
|
||||||
|
),
|
||||||
|
FileAgent(
|
||||||
|
name="File Agent",
|
||||||
|
prompt_path=f"prompts/{personality_folder}/file_agent.txt",
|
||||||
|
provider=provider, verbose=False
|
||||||
|
),
|
||||||
|
BrowserAgent(
|
||||||
|
name="Browser",
|
||||||
|
prompt_path=f"prompts/{personality_folder}/browser_agent.txt",
|
||||||
|
provider=provider, verbose=False, browser=browser
|
||||||
|
),
|
||||||
|
PlannerAgent(
|
||||||
|
name="Planner",
|
||||||
|
prompt_path=f"prompts/{personality_folder}/planner_agent.txt",
|
||||||
|
provider=provider, verbose=False, browser=browser
|
||||||
|
)
|
||||||
|
]
|
||||||
|
logger.info("Agents initialized")
|
||||||
|
|
||||||
|
interaction = Interaction(
|
||||||
|
agents,
|
||||||
|
tts_enabled=config.getboolean('MAIN', 'speak'),
|
||||||
|
stt_enabled=config.getboolean('MAIN', 'listen'),
|
||||||
|
recover_last_session=config.getboolean('MAIN', 'recover_last_session'),
|
||||||
|
langs=languages
|
||||||
|
)
|
||||||
|
logger.info("Interaction initialized")
|
||||||
|
return interaction
|
||||||
|
|
||||||
|
interaction = initialize_system()
|
||||||
|
is_generating = False
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
async def health_check():
|
||||||
|
logger.info("Health check endpoint called")
|
||||||
|
return {"status": "healthy", "version": "0.1.0"}
|
||||||
|
|
||||||
|
@app.get("/screenshot")
|
||||||
|
async def get_screenshot():
|
||||||
|
logger.info("Screenshot endpoint called")
|
||||||
|
if os.path.exists(".screenshots"):
|
||||||
|
screenshot = interaction.current_agent.browser.get_screenshot()
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=200,
|
||||||
|
content={"screenshot": screenshot}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.error("No browser agent available for screenshot")
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=400,
|
||||||
|
content={"error": "No browser agent available"}
|
||||||
|
)
|
||||||
|
|
||||||
|
@app.get("/is_active")
|
||||||
|
async def is_active():
|
||||||
|
logger.info("Is active endpoint called")
|
||||||
|
return {"is_active": interaction.is_active}
|
||||||
|
|
||||||
|
@app.post("/query", response_model=QueryResponse)
|
||||||
|
async def process_query(request: QueryRequest):
|
||||||
|
global is_generating
|
||||||
|
logger.info(f"Processing query: {request.query}")
|
||||||
|
query_resp = QueryResponse(
|
||||||
|
done="false",
|
||||||
|
answer="Waiting for agent...",
|
||||||
|
agent_name="Waiting for agent...",
|
||||||
|
success="false",
|
||||||
|
blocks={}
|
||||||
|
)
|
||||||
|
if is_generating:
|
||||||
|
logger.warning("Another query is being processed, please wait.")
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=429,
|
||||||
|
content=query_resp.jsonify()
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
interaction.tts_enabled = request.tts_enabled
|
||||||
|
interaction.stt_enabled = request.stt_enabled
|
||||||
|
interaction.last_query = request.query
|
||||||
|
logger.info("Agents request is being processed")
|
||||||
|
is_generating = True
|
||||||
|
success = interaction.think()
|
||||||
|
is_generating = False
|
||||||
|
if not success:
|
||||||
|
query_resp.answer = "Error: No answer from agent"
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=400,
|
||||||
|
content=query_resp.jsonify()
|
||||||
|
)
|
||||||
|
if interaction.current_agent:
|
||||||
|
blocks_json = {f'{i}': block.jsonify() for i, block in enumerate(interaction.current_agent.get_blocks_result())}
|
||||||
|
else:
|
||||||
|
logger.error("No current agent found")
|
||||||
|
blocks_json = {}
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=400,
|
||||||
|
content=query_resp.jsonify()
|
||||||
|
)
|
||||||
|
logger.info(f"Answer: {interaction.last_answer}")
|
||||||
|
logger.info(f"Blocks: {blocks_json}")
|
||||||
|
query_resp.done = "true"
|
||||||
|
query_resp.answer = interaction.last_answer
|
||||||
|
query_resp.agent_name = interaction.current_agent.agent_name
|
||||||
|
query_resp.success = str(success)
|
||||||
|
query_resp.blocks = blocks_json
|
||||||
|
logger.info("Query processed successfully")
|
||||||
|
return JSONResponse(
|
||||||
|
status_code=200,
|
||||||
|
content=query_resp.jsonify()
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"An error occurred: {str(e)}")
|
||||||
|
if config.getboolean('MAIN', 'save_session'):
|
||||||
|
interaction.save_session()
|
||||||
|
raise e
|
||||||
|
finally:
|
||||||
|
logger.info("Processing finished")
|
||||||
|
if config.getboolean('MAIN', 'save_session'):
|
||||||
|
interaction.save_session()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|
23
frontend/agentic-seek/.gitignore
vendored
Normal file
23
frontend/agentic-seek/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
70
frontend/agentic-seek/README.md
Normal file
70
frontend/agentic-seek/README.md
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# Getting Started with Create React App
|
||||||
|
|
||||||
|
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||||
|
|
||||||
|
## Available Scripts
|
||||||
|
|
||||||
|
In the project directory, you can run:
|
||||||
|
|
||||||
|
### `npm start`
|
||||||
|
|
||||||
|
Runs the app in the development mode.\
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
||||||
|
|
||||||
|
The page will reload when you make changes.\
|
||||||
|
You may also see any lint errors in the console.
|
||||||
|
|
||||||
|
### `npm test`
|
||||||
|
|
||||||
|
Launches the test runner in the interactive watch mode.\
|
||||||
|
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||||
|
|
||||||
|
### `npm run build`
|
||||||
|
|
||||||
|
Builds the app for production to the `build` folder.\
|
||||||
|
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||||
|
|
||||||
|
The build is minified and the filenames include the hashes.\
|
||||||
|
Your app is ready to be deployed!
|
||||||
|
|
||||||
|
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||||
|
|
||||||
|
### `npm run eject`
|
||||||
|
|
||||||
|
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
||||||
|
|
||||||
|
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||||
|
|
||||||
|
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
||||||
|
|
||||||
|
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||||
|
|
||||||
|
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||||
|
|
||||||
|
### Code Splitting
|
||||||
|
|
||||||
|
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
||||||
|
|
||||||
|
### Analyzing the Bundle Size
|
||||||
|
|
||||||
|
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
||||||
|
|
||||||
|
### Making a Progressive Web App
|
||||||
|
|
||||||
|
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
||||||
|
|
||||||
|
### Advanced Configuration
|
||||||
|
|
||||||
|
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
|
||||||
|
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
||||||
|
|
||||||
|
### `npm run build` fails to minify
|
||||||
|
|
||||||
|
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
17575
frontend/agentic-seek/package-lock.json
generated
Normal file
17575
frontend/agentic-seek/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
40
frontend/agentic-seek/package.json
Normal file
40
frontend/agentic-seek/package.json
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "agentic-seek",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@testing-library/dom": "^10.4.0",
|
||||||
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
|
"@testing-library/react": "^16.3.0",
|
||||||
|
"@testing-library/user-event": "^13.5.0",
|
||||||
|
"axios": "^1.8.4",
|
||||||
|
"react": "^19.1.0",
|
||||||
|
"react-dom": "^19.1.0",
|
||||||
|
"react-scripts": "5.0.1",
|
||||||
|
"web-vitals": "^2.1.4"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "react-scripts start",
|
||||||
|
"build": "react-scripts build",
|
||||||
|
"test": "react-scripts test",
|
||||||
|
"eject": "react-scripts eject"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": [
|
||||||
|
"react-app",
|
||||||
|
"react-app/jest"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
BIN
frontend/agentic-seek/public/favicon.ico
Normal file
BIN
frontend/agentic-seek/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
15
frontend/agentic-seek/public/index.html
Normal file
15
frontend/agentic-seek/public/index.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>AgenticSeek</title>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
frontend/agentic-seek/public/logo192.png
Normal file
BIN
frontend/agentic-seek/public/logo192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
frontend/agentic-seek/public/logo512.png
Normal file
BIN
frontend/agentic-seek/public/logo512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
25
frontend/agentic-seek/public/manifest.json
Normal file
25
frontend/agentic-seek/public/manifest.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"short_name": "React App",
|
||||||
|
"name": "Create React App Sample",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "favicon.ico",
|
||||||
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
|
"type": "image/x-icon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "logo192.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "192x192"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "logo512.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "512x512"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": ".",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#ffffff"
|
||||||
|
}
|
3
frontend/agentic-seek/public/robots.txt
Normal file
3
frontend/agentic-seek/public/robots.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# https://www.robotstxt.org/robotstxt.html
|
||||||
|
User-agent: *
|
||||||
|
Disallow:
|
250
frontend/agentic-seek/src/App.css
Normal file
250
frontend/agentic-seek/src/App.css
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Orbitron', sans-serif;
|
||||||
|
background-color: #0a0a0a;
|
||||||
|
color: #ffffff;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #1a1a1a;
|
||||||
|
border-bottom: 2px solid #00ffcc;
|
||||||
|
box-shadow: 0 0 10px #00ffcc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
flex: 1;
|
||||||
|
padding: 40px;
|
||||||
|
max-width: 1400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 40px;
|
||||||
|
height: calc(100vh - 200px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel,
|
||||||
|
.right-panel {
|
||||||
|
background-color: #1a1a1a;
|
||||||
|
border: 1px solid #00ffcc;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.messages {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 10px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-messages {
|
||||||
|
text-align: center;
|
||||||
|
color: #666;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
max-width: 80%;
|
||||||
|
padding: 10px 15px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-message {
|
||||||
|
background-color: #00ffcc;
|
||||||
|
color: #000;
|
||||||
|
align-self: flex-end;
|
||||||
|
border: 1px solid #00ccaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent-message {
|
||||||
|
background-color: #333;
|
||||||
|
color: #fff;
|
||||||
|
align-self: flex-start;
|
||||||
|
border: 1px solid #00ffcc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
background-color: #ff4444;
|
||||||
|
color: #fff;
|
||||||
|
align-self: flex-start;
|
||||||
|
border: 1px solid #cc3333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent-name {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #00ffcc;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form input {
|
||||||
|
flex: 1;
|
||||||
|
padding: 12px;
|
||||||
|
font-size: 1rem;
|
||||||
|
background-color: #222;
|
||||||
|
border: 1px solid #00ffcc;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
outline: none;
|
||||||
|
transition: box-shadow 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form input:focus {
|
||||||
|
box-shadow: 0 0 8px #00ffcc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form button {
|
||||||
|
padding: 12px 24px;
|
||||||
|
font-size: 1rem;
|
||||||
|
background-color: #00ffcc;
|
||||||
|
color: #000;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
text-transform: uppercase;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form button:hover {
|
||||||
|
background-color: #00ccaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form button:disabled {
|
||||||
|
background-color: #555;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-selector {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-selector button {
|
||||||
|
padding: 10px 20px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background-color: #222;
|
||||||
|
color: #fff;
|
||||||
|
border: 1px solid #00ffcc;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
text-transform: uppercase;
|
||||||
|
transition: background-color 0.3s, color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-selector button.active,
|
||||||
|
.view-selector button:hover {
|
||||||
|
background-color: #00ffcc;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-selector button:disabled {
|
||||||
|
background-color: #555;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blocks {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block {
|
||||||
|
background-color: #222;
|
||||||
|
padding: 15px;
|
||||||
|
border: 1px solid #00ffcc;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-tool,
|
||||||
|
.block-feedback,
|
||||||
|
.block-success {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block pre {
|
||||||
|
background-color: #111;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.screenshot {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.screenshot img {
|
||||||
|
max-width: 100%;
|
||||||
|
border: 1px solid #00ffcc;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: #ff4444;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.chat-container {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel,
|
||||||
|
.right-panel {
|
||||||
|
height: 50vh;
|
||||||
|
}
|
||||||
|
}
|
165
frontend/agentic-seek/src/App.js
Normal file
165
frontend/agentic-seek/src/App.js
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
|
import './App.css';
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
const [query, setQuery] = useState('');
|
||||||
|
const [messages, setMessages] = useState([]);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [error, setError] = useState(null);
|
||||||
|
const [currentView, setCurrentView] = useState('blocks');
|
||||||
|
const [responseData, setResponseData] = useState(null);
|
||||||
|
const messagesEndRef = useRef(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
scrollToBottom();
|
||||||
|
}, [messages]);
|
||||||
|
|
||||||
|
const scrollToBottom = () => {
|
||||||
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!query.trim()) return;
|
||||||
|
setMessages((prev) => [...prev, { type: 'user', content: query }]);
|
||||||
|
setIsLoading(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await axios.post('http://localhost:8000/query', {
|
||||||
|
query,
|
||||||
|
lang: 'en',
|
||||||
|
tts_enabled: false,
|
||||||
|
stt_enabled: false,
|
||||||
|
});
|
||||||
|
const data = res.data;
|
||||||
|
setResponseData(data);
|
||||||
|
setMessages((prev) => [
|
||||||
|
...prev,
|
||||||
|
{ type: 'agent', content: data.answer, agentName: data.agent_name },
|
||||||
|
]);
|
||||||
|
setCurrentView('blocks');
|
||||||
|
} catch (err) {
|
||||||
|
setError('Failed to process query.');
|
||||||
|
setMessages((prev) => [
|
||||||
|
...prev,
|
||||||
|
{ type: 'error', content: 'Error: Unable to get a response.' },
|
||||||
|
]);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
setQuery('');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleGetScreenshot = async () => {
|
||||||
|
try {
|
||||||
|
const res = await axios.get('http://localhost:8000/screenshots/updated_screen.png');
|
||||||
|
setResponseData((prev) => ({ ...prev, screenshot: res.data.screenshot }));
|
||||||
|
setCurrentView('screenshot');
|
||||||
|
} catch (err) {
|
||||||
|
setError('Failed to fetch screenshot.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="app">
|
||||||
|
<header className="header">
|
||||||
|
<h1>AgenticSeek</h1>
|
||||||
|
</header>
|
||||||
|
<main className="main">
|
||||||
|
<div className="chat-container">
|
||||||
|
<div className="left-panel">
|
||||||
|
<h2>Chat</h2>
|
||||||
|
<div className="messages">
|
||||||
|
{messages.length === 0 ? (
|
||||||
|
<p className="placeholder">No messages yet. Type below to start!</p>
|
||||||
|
) : (
|
||||||
|
messages.map((msg, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className={`message ${
|
||||||
|
msg.type === 'user'
|
||||||
|
? 'user-message'
|
||||||
|
: msg.type === 'agent'
|
||||||
|
? 'agent-message'
|
||||||
|
: 'error-message'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{msg.type === 'agent' && (
|
||||||
|
<span className="agent-name">{msg.agentName}</span>
|
||||||
|
)}
|
||||||
|
<p>{msg.content}</p>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
<div ref={messagesEndRef} />
|
||||||
|
</div>
|
||||||
|
{isLoading && <div className="loading-animation">Loading...</div>}
|
||||||
|
<form onSubmit={handleSubmit} className="input-form">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={query}
|
||||||
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
|
placeholder="Type your query..."
|
||||||
|
disabled={isLoading}
|
||||||
|
/>
|
||||||
|
<button type="submit" disabled={isLoading}>
|
||||||
|
Send
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div className="right-panel">
|
||||||
|
<h2>Details</h2>
|
||||||
|
<div className="view-selector">
|
||||||
|
<button
|
||||||
|
className={currentView === 'blocks' ? 'active' : ''}
|
||||||
|
onClick={() => setCurrentView('blocks')}
|
||||||
|
>
|
||||||
|
Editor View
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={currentView === 'screenshot' ? 'active' : ''}
|
||||||
|
onClick={responseData?.screenshot ? () => setCurrentView('screenshot') : handleGetScreenshot}
|
||||||
|
disabled={responseData?.agent_name !== 'Browser'}
|
||||||
|
>
|
||||||
|
Browser View
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="content">
|
||||||
|
{error && <p className="error">{error}</p>}
|
||||||
|
{responseData ? (
|
||||||
|
currentView === 'blocks' ? (
|
||||||
|
<div className="blocks">
|
||||||
|
{Object.values(responseData.blocks).length > 0 ? (
|
||||||
|
Object.values(responseData.blocks).map((block, index) => (
|
||||||
|
<div key={index} className="block">
|
||||||
|
<p className="block-tool">Tool: {block.tool_type}</p>
|
||||||
|
<pre>{block.block}</pre>
|
||||||
|
<p className="block-feedback">Feedback: {block.feedback}</p>
|
||||||
|
<p className="block-success">
|
||||||
|
Success: {block.success ? 'Yes' : 'No'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<p className="placeholder">No blocks available.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="screenshot">
|
||||||
|
<img src="http://localhost:8000/screenshots/updated_screen.png" alt="Screenshot" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<p className="placeholder">Nothing to display.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
8
frontend/agentic-seek/src/App.test.js
Normal file
8
frontend/agentic-seek/src/App.test.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
test('renders learn react link', () => {
|
||||||
|
render(<App />);
|
||||||
|
const linkElement = screen.getByText(/learn react/i);
|
||||||
|
expect(linkElement).toBeInTheDocument();
|
||||||
|
});
|
13
frontend/agentic-seek/src/index.css
Normal file
13
frontend/agentic-seek/src/index.css
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||||
|
sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||||
|
monospace;
|
||||||
|
}
|
10
frontend/agentic-seek/src/index.js
Normal file
10
frontend/agentic-seek/src/index.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||||
|
root.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>
|
||||||
|
);
|
1
frontend/agentic-seek/src/logo.svg
Normal file
1
frontend/agentic-seek/src/logo.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
After Width: | Height: | Size: 2.6 KiB |
13
frontend/agentic-seek/src/reportWebVitals.js
Normal file
13
frontend/agentic-seek/src/reportWebVitals.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const reportWebVitals = onPerfEntry => {
|
||||||
|
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||||
|
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||||
|
getCLS(onPerfEntry);
|
||||||
|
getFID(onPerfEntry);
|
||||||
|
getFCP(onPerfEntry);
|
||||||
|
getLCP(onPerfEntry);
|
||||||
|
getTTFB(onPerfEntry);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reportWebVitals;
|
5
frontend/agentic-seek/src/setupTests.js
Normal file
5
frontend/agentic-seek/src/setupTests.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||||
|
// allows you to do things like:
|
||||||
|
// expect(element).toHaveTextContent(/react/i)
|
||||||
|
// learn more: https://github.com/testing-library/jest-dom
|
||||||
|
import '@testing-library/jest-dom';
|
@ -128,10 +128,11 @@ class Browser:
|
|||||||
self.wait = WebDriverWait(self.driver, 10)
|
self.wait = WebDriverWait(self.driver, 10)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"Failed to initialize browser: {str(e)}")
|
raise Exception(f"Failed to initialize browser: {str(e)}")
|
||||||
|
self.screenshot_folder = os.path.join(os.getcwd(), ".screenshots")
|
||||||
|
self.screenshot()
|
||||||
self.driver.get("https://www.google.com")
|
self.driver.get("https://www.google.com")
|
||||||
if anticaptcha_manual_install:
|
if anticaptcha_manual_install:
|
||||||
self.load_anticatpcha_manually()
|
self.load_anticatpcha_manually()
|
||||||
self.screenshot_folder = os.path.join(os.getcwd(), ".screenshots")
|
|
||||||
|
|
||||||
def load_anticatpcha_manually(self):
|
def load_anticatpcha_manually(self):
|
||||||
pretty_print("You might want to install the AntiCaptcha extension for captchas.", color="warning")
|
pretty_print("You might want to install the AntiCaptcha extension for captchas.", color="warning")
|
||||||
@ -542,6 +543,9 @@ class Browser:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f"Error scrolling: {str(e)}")
|
self.logger.error(f"Error scrolling: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_screenshot(self) -> str:
|
||||||
|
return self.screenshot_folder + "/updated_screen.png"
|
||||||
|
|
||||||
def screenshot(self, filename:str = 'updated_screen.png') -> bool:
|
def screenshot(self, filename:str = 'updated_screen.png') -> bool:
|
||||||
"""Take a screenshot of the current page."""
|
"""Take a screenshot of the current page."""
|
||||||
|
@ -87,6 +87,8 @@ class Provider:
|
|||||||
raise ConnectionError(f"{str(e)}\nConnection to {self.server_ip} failed.")
|
raise ConnectionError(f"{str(e)}\nConnection to {self.server_ip} failed.")
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
raise NotImplementedError(f"{str(e)}\nIs {self.provider_name} implemented ?")
|
raise NotImplementedError(f"{str(e)}\nIs {self.provider_name} implemented ?")
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
|
raise ModuleNotFoundError(f"{str(e)}\nA import related to provider {self.provider_name} was not found. Is it installed ?")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if "refused" in str(e):
|
if "refused" in str(e):
|
||||||
return f"Server {self.server_ip} seem offline. Unable to answer."
|
return f"Server {self.server_ip} seem offline. Unable to answer."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user