Skip to content

Commit

Permalink
fix: circular db import
Browse files Browse the repository at this point in the history
  • Loading branch information
Draichi committed Oct 31, 2024
1 parent c1e4b9e commit b8fe862
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from gradio import ChatMessage
import textwrap
from tools import *
from db.connection import db
load_dotenv()
os.environ['LANGCHAIN_PROJECT'] = 'gradio-test'

Expand Down
3 changes: 3 additions & 0 deletions db/connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from langchain_community.utilities import SQLDatabase

db = SQLDatabase.from_uri("sqlite:///db/Bahrain_2023_Q.db")
3 changes: 0 additions & 3 deletions tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from langchain_community.utilities import SQLDatabase
from rich.console import Console
from .driver_performance import GetDriverPerformance
from .event_performance import GetEventPerformance
Expand All @@ -8,8 +7,6 @@

console = Console(style="chartreuse1 on grey7")

db = SQLDatabase.from_uri("sqlite:///db/Bahrain_2023_Q.db")

__all__ = [
"GetDriverPerformance",
"GetEventPerformance",
Expand Down
3 changes: 2 additions & 1 deletion tools/driver_performance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pydantic import BaseModel, Field
from langchain_core.tools import BaseTool
from . import db, console
from db.connection import db
from . import console


class GetDriverPerformanceOutput(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion tools/event_performance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pydantic import BaseModel, Field
from typing import Type
from langchain_core.tools import BaseTool
from . import db, console
from db.connection import db
from . import console


class GetEventPerformanceOutput(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion tools/telemetry_analysis.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pydantic import BaseModel, Field
from typing import Type
from langchain_core.tools import BaseTool
from . import db, console
from db.connection import db
from . import console


class GetTelemetryAndWeatherInput(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion tools/tyre_performance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pydantic import BaseModel, Field
from typing import Type
from langchain_core.tools import BaseTool
from . import db, console
from db.connection import db
from . import console


class GetTyrePerformanceInput(BaseModel):
Expand Down
6 changes: 2 additions & 4 deletions tools/weather_impact.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from pydantic import BaseModel, Field
from typing import Type
from langchain_core.tools import BaseTool
from rich.console import Console
from . import db

console = Console(style="chartreuse1 on grey7")
from db.connection import db
from . import console


class GetWeatherImpactInput(BaseModel):
Expand Down

0 comments on commit b8fe862

Please sign in to comment.