Skip to content

Commit

Permalink
Skeleton for Dialectic API
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Mar 8, 2024
1 parent 0e6b56a commit c074f08
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 1 deletion.
126 changes: 125 additions & 1 deletion api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ opentelemetry-instrumentation-sqlalchemy = "^0.44b0"
opentelemetry-instrumentation-logging = "^0.44b0"
psycopg = "^3.1.18"
greenlet = "^3.0.3"
realtime = "^1.0.2"

[tool.ruff.lint]
# from https://docs.astral.sh/ruff/linter/#rule-selection example
Expand Down
10 changes: 10 additions & 0 deletions api/src/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
async def chat():
pass


async def hydrate():
pass


async def insight():
pass
23 changes: 23 additions & 0 deletions api/src/harvester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os

from dotenv import load_dotenv
from realtime.connection import Socket

load_dotenv()

SUPABASE_ID = os.getenv("SUPABASE_ID")
API_KEY = os.getenv("SUPABASE_API_KEY")


def derive_facts(payload):
print("Derive Facts: ", payload)


if __name__ == "__main__":
URL = f"wss://{SUPABASE_ID}.supabase.co/realtime/v1/websocket?apikey={API_KEY}&vsn=1.0.0"
s = Socket(URL)
s.connect()

channel = s.set_channel("realtime:public:messages")
channel.join().on("INSERT", derive_facts)
s.listen()
36 changes: 36 additions & 0 deletions api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,4 +1141,40 @@ async def delete_document(
)


router = APIRouter(prefix="/apps/{app_id}/users/{user_id}")


@router.get("/sessions/{session_id}/chat", response_model=Sequence[schemas.Message])
async def get_chat(
request: Request,
app_id: uuid.UUID,
user_id: uuid.UUID,
session_id: uuid.UUID,
db: AsyncSession = Depends(get_db),
):
pass


@router.get("/sessions/{session_id}/hydrate")
async def hydrate(
request: Request,
app_id: uuid.UUID,
user_id: uuid.UUID,
session_id: uuid.UUID,
db: AsyncSession = Depends(get_db),
):
pass


@router.get("/sessions/{session_id}/insight")
async def get_insight(
request: Request,
app_id: uuid.UUID,
user_id: uuid.UUID,
session_id: uuid.UUID,
db: AsyncSession = Depends(get_db),
):
pass


app.include_router(router)

0 comments on commit c074f08

Please sign in to comment.