Skip to content

Commit

Permalink
Fix first initialisation issues (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
StreetLamb authored May 3, 2024
1 parent 1c2eab8 commit 0d52350
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 78 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ GOOGLE_API_KEY=
LANGCHAIN_TRACING_V2=
LANGCHAIN_API_KEY=

# tools/skills api keys
SERP_API_KEY=
SERPAPI_API_KEY=

# Emails
SMTP_HOST=
SMTP_USER=
Expand Down
83 changes: 83 additions & 0 deletions backend/app/alembic/versions/634ddcf1c767_initialise_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""initialise models
Revision ID: 634ddcf1c767
Revises:
Create Date: 2024-05-03 14:27:45.799194
"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = '634ddcf1c767'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('skill',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('description', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.Column('is_superuser', sa.Boolean(), nullable=False),
sa.Column('full_name', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('hashed_password', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
op.create_table('team',
sa.Column('description', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('owner_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('member',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('backstory', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('role', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('owner_of', sa.Integer(), nullable=True),
sa.Column('position_x', sa.Float(), nullable=False),
sa.Column('position_y', sa.Float(), nullable=False),
sa.Column('source', sa.Integer(), nullable=True),
sa.Column('provider', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('model', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('temperature', sa.Float(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('belongs_to', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['belongs_to'], ['team.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name', 'belongs_to', name='unique_team_and_name')
)
op.create_table('memberskillslink',
sa.Column('member_id', sa.Integer(), nullable=False),
sa.Column('skill_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['member_id'], ['member.id'], ),
sa.ForeignKeyConstraint(['skill_id'], ['skill.id'], ),
sa.PrimaryKeyConstraint('member_id', 'skill_id')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('memberskillslink')
op.drop_table('member')
op.drop_table('team')
op.drop_index(op.f('ix_user_email'), table_name='user')
op.drop_table('user')
op.drop_table('skill')
# ### end Alembic commands ###
54 changes: 0 additions & 54 deletions backend/app/alembic/versions/e2412789c190_initialize_models.py

This file was deleted.

1 change: 1 addition & 0 deletions backend/app/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def init_db(session: Session) -> None:
)
user = crud.create_user(session=session, user_create=user_in)

# TODO: Find a way to deal with deleting skills
existing_skills = session.exec(select(Skill)).all()
existing_skills_dict = {skill.name: skill for skill in existing_skills}

Expand Down
53 changes: 29 additions & 24 deletions backend/app/core/graph/skills.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Some tools are commented out as they require your SERP_API_KEY and SERPAPI_API_KEY to be added in .env file.
# See https://python.langchain.com/docs/integrations/tools/ for a list of other available tools.
# You can also add your own custom tools.

from typing import Any

from langchain_community.tools import DuckDuckGoSearchRun, WikipediaQueryRun
from langchain_community.tools.google_finance import GoogleFinanceQueryRun
from langchain_community.tools.google_jobs import GoogleJobsQueryRun
from langchain_community.tools.google_scholar import GoogleScholarQueryRun
from langchain_community.tools.google_trends import GoogleTrendsQueryRun

# from langchain_community.tools.google_finance import GoogleFinanceQueryRun
# from langchain_community.tools.google_jobs import GoogleJobsQueryRun
# from langchain_community.tools.google_scholar import GoogleScholarQueryRun
# from langchain_community.tools.google_trends import GoogleTrendsQueryRun
from langchain_community.tools.yahoo_finance_news import YahooFinanceNewsTool
from langchain_community.utilities import (
GoogleFinanceAPIWrapper,
GoogleJobsAPIWrapper,
GoogleScholarAPIWrapper,
GoogleTrendsAPIWrapper,
# GoogleFinanceAPIWrapper,
# GoogleJobsAPIWrapper,
# GoogleScholarAPIWrapper,
# GoogleTrendsAPIWrapper,
WikipediaAPIWrapper,
)
from pydantic import BaseModel
Expand All @@ -29,22 +34,22 @@ class SkillInfo(BaseModel):
description="Searches Wikipedia",
tool=WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper()), # type: ignore[call-arg]
),
"google-finance": SkillInfo(
description="Get information from Google Finance Page via SerpApi.",
tool=GoogleFinanceQueryRun(api_wrapper=GoogleFinanceAPIWrapper()), # type: ignore[call-arg]
),
"google-jobs": SkillInfo(
description="Fetch current job postings from Google Jobs via SerpApi.",
tool=GoogleJobsQueryRun(api_wrapper=GoogleJobsAPIWrapper()), # type: ignore[call-arg]
),
"google-scholar": SkillInfo(
description="Fetch papers from Google Scholar via SerpApi.",
tool=GoogleScholarQueryRun(api_wrapper=GoogleScholarAPIWrapper()),
),
"google-trends": SkillInfo(
description="Get information from Google Trends Page via SerpApi.",
tool=GoogleTrendsQueryRun(api_wrapper=GoogleTrendsAPIWrapper()), # type: ignore[call-arg]
),
# "google-finance": SkillInfo(
# description="Get information from Google Finance Page via SerpApi.",
# tool=GoogleFinanceQueryRun(api_wrapper=GoogleFinanceAPIWrapper()), # type: ignore[call-arg]
# ),
# "google-jobs": SkillInfo(
# description="Fetch current job postings from Google Jobs via SerpApi.",
# tool=GoogleJobsQueryRun(api_wrapper=GoogleJobsAPIWrapper()), # type: ignore[call-arg]
# ),
# "google-scholar": SkillInfo(
# description="Fetch papers from Google Scholar via SerpApi.",
# tool=GoogleScholarQueryRun(api_wrapper=GoogleScholarAPIWrapper()),
# ),
# "google-trends": SkillInfo(
# description="Get information from Google Trends Page via SerpApi.",
# tool=GoogleTrendsQueryRun(api_wrapper=GoogleTrendsAPIWrapper()), # type: ignore[call-arg]
# ),
"yahoo-finance": SkillInfo(
description="Get information from Yahoo Finance News.",
tool=YahooFinanceNewsTool(),
Expand Down

0 comments on commit 0d52350

Please sign in to comment.