Skip to content

FROM feat/183-finance-tools TO development #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .cursorindexingignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.env*
**/logs
**/__pycache__
**/__pycache__/*
**/logs/*
**/.venv
**/.venv/*
**/node_modules
**/node_modules/*
**/dist
**/dist/*
**/build
**/build/*
**/env
**/env/*
**/src/public
**/src/public/*
**/src/templates
**/src/templates/*
**/src/static
**/src/static/*
**/src/static/css
**/src/static/css/*
**/src/static/js
**/src/static/js/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
**/logs/
**/sandbox/db/*
**/site
**/docker/searxng/settings.yml.new

backend/src/public
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- bugfix/28-cannot-auth-tools-list (2024-11-30)

### Changed
- feat/183-finance-tools (2025-03-10)
- feat/173-test-a-tool-call (2025-03-04)
- feat/165-oauth-init (2025-03-01)
- feat/153-clear-chat-inputs (2025-02-27)
Expand Down
25 changes: 25 additions & 0 deletions backend/.cursorindexingignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.env*
**/logs
**/__pycache__
**/__pycache__/*
**/logs/*
**/.venv
**/.venv/*
**/node_modules
**/node_modules/*
**/dist
**/dist/*
**/build
**/build/*
**/env
**/env/*
**/src/public
**/src/public/*
**/src/templates
**/src/templates/*
**/src/static
**/src/static/*
**/src/static/css
**/src/static/css/*
**/src/static/js
**/src/static/js/*
52 changes: 52 additions & 0 deletions backend/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,58 @@
"console": "integratedTerminal",
"justMyCode": false,
"envFile": "${workspaceFolder}/.env"
},
{
"name": "Python: Single Test",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"args": [
"tests/unit/repos/test_agent_repo.py",
"-v"
],
"console": "integratedTerminal",
"justMyCode": true,
"envFile": "${workspaceFolder}/.env.test"
},
{
"name": "Python: Run Tests",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"args": [
"tests/",
"-v"
],
"console": "integratedTerminal",
"justMyCode": false,
"envFile": "${workspaceFolder}/.env.test"
},
{
"name": "Python: Run Unit Tests Only",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"args": [
"tests/unit/",
"-v"
],
"console": "integratedTerminal",
"justMyCode": false,
"envFile": "${workspaceFolder}/.env.test"
},
{
"name": "Python: Run Integration Tests Only",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"args": [
"tests/integration/",
"-v"
],
"console": "integratedTerminal",
"justMyCode": false,
"envFile": "${workspaceFolder}/.env.test"
}
]
}
11 changes: 6 additions & 5 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from fastapi.middleware.cors import CORSMiddleware
import os

from src.routes.v0 import tool, llm, thread, retrieve, source, info, auth, token, storage, settings
from src.routes.v0 import tool, llm, thread, retrieve, source, info, auth, token, storage, settings, agent
from src.constants import (
HOST,
PORT,
Expand All @@ -30,7 +30,7 @@ async def lifespan(app: FastAPI):
pass

app = FastAPI(
title="Armada by Prompt Engineers AI 🤖",
title="Enso by Prompt Engineers AI 🤖",
version=APP_VERSION,
description=(
"This is a simple API for building chatbots with LangGraph. "
Expand Down Expand Up @@ -61,14 +61,15 @@ async def lifespan(app: FastAPI):
PREFIX = "/api"
app.include_router(auth, prefix=PREFIX)
app.include_router(info, prefix=PREFIX)
app.include_router(token, prefix=PREFIX)
app.include_router(llm, prefix=PREFIX)
app.include_router(thread, prefix=PREFIX)
app.include_router(tool, prefix=PREFIX)
app.include_router(settings, prefix=PREFIX)
app.include_router(agent, prefix=PREFIX)
app.include_router(retrieve, prefix=PREFIX)
app.include_router(source, prefix=PREFIX)
app.include_router(token, prefix=PREFIX)
app.include_router(storage, prefix=PREFIX)
app.include_router(settings, prefix=PREFIX)

# Mount specific directories only if they exist
app.mount("/docs", StaticFiles(directory="src/public/docs", html=True), name="docs")
Expand All @@ -79,7 +80,7 @@ async def lifespan(app: FastAPI):
app.mount("/icons", StaticFiles(directory="src/public/icons"), name="icons")

# Function to serve static files with fallback
@app.get("/{filename:path}")
@app.get("/{filename:path}", include_in_schema=False)
async def serve_static_or_index(filename: str, request: Request):
# List of static files to check for at the root
static_files = ["manifest.json", "sw.js", "favicon.ico", "robots.txt", "manifest.webmanifest"]
Expand Down
33 changes: 33 additions & 0 deletions backend/migrations/versions/0005_add_user_id_to_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Add user_id to settings table

Revision ID: 0005_add_user_id_to_settings
Revises: 00000000000004_add_settings_table
Create Date: 2023-02-10 00:00:00.000000

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '0005_add_user_id_to_settings'
down_revision = '00000000000004_add_settings_table'
branch_labels = None
depends_on = None


def upgrade() -> None:
# Add user_id column to settings table
op.add_column('settings',
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=True))

# Add index on user_id for faster lookups
op.create_index('idx_settings_user_id', 'settings', ['user_id'])


def downgrade() -> None:
# Remove index first
op.drop_index('idx_settings_user_id')

# Remove the column
op.drop_column('settings', 'user_id')
63 changes: 63 additions & 0 deletions backend/migrations/versions/0006_add_agents_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Create agents table for storing agents

Revision ID: 0006_add_agents_table
Revises: 0005_add_user_id_to_settings
Create Date: 2025-02-10 00:00:00.000000

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '0006_add_agents_table'
down_revision = '0005_add_user_id_to_settings'
branch_labels = None
depends_on = None


def upgrade() -> None:
op.create_table(
'agents',
sa.Column(
'id',
postgresql.UUID(as_uuid=True),
server_default=sa.text('gen_random_uuid()'),
primary_key=True
),
sa.Column(
'user_id',
postgresql.UUID(as_uuid=True),
sa.ForeignKey('users.id', ondelete='CASCADE'),
nullable=False
),
sa.Column('name', sa.String(), nullable=False),
sa.Column('slug', sa.String(), nullable=False),
sa.Column('description', sa.String(), nullable=True),
sa.Column('public', sa.Boolean(), server_default='false', nullable=False),
sa.Column('revision_number', sa.Integer(), nullable=False),
sa.Column(
'created_at',
sa.DateTime(timezone=True),
server_default=sa.text('now()'),
nullable=False
),
sa.Column(
'updated_at',
sa.DateTime(timezone=True),
server_default=sa.text('now()'),
onupdate=sa.text('now()'),
nullable=False
),
# Create a unique constraint on slug
sa.UniqueConstraint('slug', name='uq_agents_slug'),
)

# Add index on slug for faster lookups
op.create_index('idx_agents_slug', 'agents', ['slug'])


def downgrade() -> None:
op.drop_index('idx_agents_slug')
op.drop_table('agents')

78 changes: 78 additions & 0 deletions backend/migrations/versions/0007_add_revisions_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""Create revisions table for storing settings revisions

Revision ID: 0007_add_revisions_table
Revises: 0006_add_agents_table
Create Date: 2025-02-10 00:00:00.000000

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '0007_add_revisions_table'
down_revision = '0006_add_agents_table'
branch_labels = None
depends_on = None


def upgrade() -> None:
op.create_table(
'revisions',
sa.Column(
'id',
postgresql.UUID(as_uuid=True),
server_default=sa.text('gen_random_uuid()'),
primary_key=True
),
sa.Column(
'agent_id',
postgresql.UUID(as_uuid=True),
sa.ForeignKey('agents.id', ondelete='CASCADE'),
nullable=False
),
sa.Column(
'user_id',
postgresql.UUID(as_uuid=True),
sa.ForeignKey('users.id', ondelete='CASCADE'),
nullable=False
),
sa.Column(
'settings_id',
postgresql.UUID(as_uuid=True),
sa.ForeignKey('settings.id', ondelete='CASCADE'),
nullable=False
),
sa.Column('revision_number', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column(
'created_at',
sa.DateTime(timezone=True),
server_default=sa.text('now()'),
nullable=False
),
sa.Column(
'updated_at',
sa.DateTime(timezone=True),
server_default=sa.text('now()'),
onupdate=sa.text('now()'),
nullable=False
),
# Create a unique constraint for agent_id + revision_number
sa.UniqueConstraint('agent_id', 'revision_number', name='uq_revisions_agent_revision')
)

# Add index on agent_id for faster lookups
op.create_index('idx_revisions_agent_id', 'revisions', ['agent_id'])
# Add index on settings_id for faster joins
op.create_index('idx_revisions_settings_id', 'revisions', ['settings_id'])
# Add index on revision_number for faster max/min operations
op.create_index('idx_revisions_revision_number', 'revisions', ['revision_number'])


def downgrade() -> None:
op.drop_index('idx_revisions_revision_number')
op.drop_index('idx_revisions_settings_id')
op.drop_index('idx_revisions_agent_id')
op.drop_table('revisions')
3 changes: 2 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ aiofiles
alembic
sqlalchemy
passlib[bcrypt]
python-jose[cryptography]
python-jose[cryptography]
yfinance
Loading