Skip to content

Commit

Permalink
added g_analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
luv-singh-ai committed Nov 15, 2024
1 parent 662843e commit 68e9ccf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
9 changes: 9 additions & 0 deletions sukoon-frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
<html lang="en">

<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-E7644C856B"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-E7644C856B');
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sukoon Chat</title>
Expand Down
1 change: 0 additions & 1 deletion sukoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from langchain_core.runnables import RunnableConfig
from langgraph.store.base import BaseStore


import os
import yaml, uuid
import json
Expand Down
39 changes: 38 additions & 1 deletion sukoon_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
from typing import TypedDict, Annotated
import uvicorn

# from fastapi import Request
# from fastapi.responses import HTMLResponse
# from fastapi.templating import Jinja2Templates
# import json
# from datetime import datetime

from sukoon import chat

from fastapi.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -39,4 +45,35 @@ async def root():
# return RedirectResponse("/docs")

if __name__ == "__main__":
uvicorn.run(app, host = "127.0.0.1", port = 8001)
uvicorn.run(app, host = "127.0.0.1", port = 8001)


# for google analytics
# templates = Jinja2Templates(directory="templates")

# # Track conversation events
# async def track_conversation_event(conversation_id: str, event_type: str, data: dict):
# # Send to Google Analytics
# event = {
# 'conversation_id': conversation_id,
# 'event_type': event_type,
# 'timestamp': datetime.utcnow().isoformat(),
# 'data': data
# }
# # Log for analysis
# print(json.dumps(event))

# @app.post("/chat")
# async def chat_endpoint(request: Request):
# # Your existing chat logic
# conversation_id = "unique_id" # Generate unique ID

# # Track conversation start
# await track_conversation_event(
# conversation_id=conversation_id,
# event_type="conversation_start",
# data={
# 'user_id': request.client.host,
# 'timestamp': datetime.utcnow().isoformat()
# }
# )

0 comments on commit 68e9ccf

Please sign in to comment.