Spaces:
Sleeping
Sleeping
Commit
·
05626fe
1
Parent(s):
c1165ce
Updated analytics
Browse files
.github/workflows/main.yaml
DELETED
|
@@ -1,62 +0,0 @@
|
|
| 1 |
-
name: FastAPI CI + Docker
|
| 2 |
-
|
| 3 |
-
on:
|
| 4 |
-
push:
|
| 5 |
-
branches: [main]
|
| 6 |
-
pull_request:
|
| 7 |
-
branches: [main]
|
| 8 |
-
|
| 9 |
-
jobs:
|
| 10 |
-
build-test-and-dockerize:
|
| 11 |
-
runs-on: ubuntu-latest
|
| 12 |
-
|
| 13 |
-
env:
|
| 14 |
-
HUGGINGFACEHUB_ACCESS_TOKEN: ${{ secrets.HUGGINGFACEHUB_ACCESS_TOKEN }}
|
| 15 |
-
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
|
| 16 |
-
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
|
| 17 |
-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
| 18 |
-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
| 19 |
-
|
| 20 |
-
steps:
|
| 21 |
-
- name: Checkout code
|
| 22 |
-
uses: actions/checkout@v3
|
| 23 |
-
|
| 24 |
-
- name: Set up Python
|
| 25 |
-
uses: actions/setup-python@v4
|
| 26 |
-
with:
|
| 27 |
-
python-version: '3.13'
|
| 28 |
-
|
| 29 |
-
- name: Install dependencies
|
| 30 |
-
run: |
|
| 31 |
-
python -m pip install --upgrade pip
|
| 32 |
-
pip install -r requirements.txt
|
| 33 |
-
pip install pytest
|
| 34 |
-
pip install langgraph==0.6.4
|
| 35 |
-
|
| 36 |
-
# - name: Run tests
|
| 37 |
-
# run: pytest
|
| 38 |
-
|
| 39 |
-
- name: Set up Docker Buildx
|
| 40 |
-
uses: docker/setup-buildx-action@v3
|
| 41 |
-
|
| 42 |
-
- name: Log in to Docker Hub
|
| 43 |
-
uses: docker/login-action@v3
|
| 44 |
-
with:
|
| 45 |
-
username: ${{ secrets.DOCKER_USERNAME }}
|
| 46 |
-
password: ${{ secrets.DOCKER_PASSWORD }}
|
| 47 |
-
|
| 48 |
-
- name: Build and Push Docker image
|
| 49 |
-
uses: docker/build-push-action@v5
|
| 50 |
-
with:
|
| 51 |
-
context: .
|
| 52 |
-
push: false
|
| 53 |
-
tags: subash024/rt-genai-app:latest
|
| 54 |
-
build-args: |
|
| 55 |
-
HUGGINGFACEHUB_ACCESS_TOKEN=${{ secrets.HUGGINGFACEHUB_ACCESS_TOKEN }}
|
| 56 |
-
GROQ_API_KEY=${{ secrets.GROQ_API_KEY }}
|
| 57 |
-
GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }}
|
| 58 |
-
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
|
| 59 |
-
ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }}
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
CHANGED
|
@@ -6,4 +6,4 @@ logs
|
|
| 6 |
delete_pycache.py
|
| 7 |
docker_file_for_actions.txt
|
| 8 |
vercel.json
|
| 9 |
-
.github/workflows/
|
|
|
|
| 6 |
delete_pycache.py
|
| 7 |
docker_file_for_actions.txt
|
| 8 |
vercel.json
|
| 9 |
+
.github/workflows/actions_cicd.txt
|
logs/access.log
CHANGED
|
@@ -1247,3 +1247,37 @@
|
|
| 1247 |
2025-10-09 15:08:33,444 | INFO | access_logger | api/main.py:19 | Request: POST http://127.0.0.1:8000/api/orchestration
|
| 1248 |
2025-10-09 16:48:18,312 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/show-analytics
|
| 1249 |
2025-10-09 16:48:20,028 | INFO | access_logger | app.py:21 | Response status: 200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1247 |
2025-10-09 15:08:33,444 | INFO | access_logger | api/main.py:19 | Request: POST http://127.0.0.1:8000/api/orchestration
|
| 1248 |
2025-10-09 16:48:18,312 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/show-analytics
|
| 1249 |
2025-10-09 16:48:20,028 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1250 |
+
2025-10-10 13:19:42,360 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/
|
| 1251 |
+
2025-10-10 13:19:42,361 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1252 |
+
2025-10-10 13:19:42,846 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/favicon.ico
|
| 1253 |
+
2025-10-10 13:19:42,848 | INFO | access_logger | app.py:21 | Response status: 404
|
| 1254 |
+
2025-10-10 13:19:45,626 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/docs
|
| 1255 |
+
2025-10-10 13:19:45,627 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1256 |
+
2025-10-10 13:19:45,750 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/openapi.json
|
| 1257 |
+
2025-10-10 13:19:45,758 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1258 |
+
2025-10-10 13:19:58,201 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1259 |
+
2025-10-10 13:20:10,214 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1260 |
+
2025-10-10 13:20:35,163 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1261 |
+
2025-10-10 13:20:40,837 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1262 |
+
2025-10-10 13:30:44,690 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1263 |
+
2025-10-10 13:30:56,753 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1264 |
+
2025-10-10 13:32:12,738 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1265 |
+
2025-10-10 13:32:30,841 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1266 |
+
2025-10-10 13:54:13,642 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1267 |
+
2025-10-10 13:54:23,393 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1268 |
+
2025-10-10 13:58:25,240 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1269 |
+
2025-10-10 13:58:48,010 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1270 |
+
2025-10-10 14:00:29,327 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=no%20i%20want%20monthly
|
| 1271 |
+
2025-10-10 14:00:32,974 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1272 |
+
2025-10-10 14:05:34,316 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1273 |
+
2025-10-10 14:06:32,897 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1274 |
+
2025-10-10 14:14:43,239 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1275 |
+
2025-10-10 14:14:57,116 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1276 |
+
2025-10-10 14:15:18,176 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=now%20i%20want%20monthly
|
| 1277 |
+
2025-10-10 14:17:14,812 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1278 |
+
2025-10-10 15:11:11,583 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=I%20want%20to%20compare%20the%20analytics%20of%20divya%20dhakal%20and%20muna%20chiya%20in%20weekly%20basis
|
| 1279 |
+
2025-10-10 15:12:47,152 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1280 |
+
2025-10-10 15:13:11,651 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=i%20want%20monthly
|
| 1281 |
+
2025-10-10 15:13:23,414 | INFO | access_logger | app.py:21 | Response status: 200
|
| 1282 |
+
2025-10-10 15:14:29,401 | INFO | access_logger | app.py:19 | Request: GET http://127.0.0.1:8000/api/analytics-chatbot?msg=i%20want%20monthly%20not%20weekly
|
| 1283 |
+
2025-10-10 15:15:31,389 | INFO | access_logger | app.py:21 | Response status: 200
|
src/genai/analytics_chatbot/utils/nodes.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import requests
|
| 2 |
from langchain_core.messages import SystemMessage , HumanMessage , FunctionMessage
|
| 3 |
from .state import State
|
| 4 |
-
from .schemas import ResponseFormatter ,
|
| 5 |
-
from .prompts import chatbot_prompt ,
|
| 6 |
from .utils import generate_api_knowledge
|
| 7 |
from src.genai.utils.models_loader import llm_gpt
|
| 8 |
|
|
@@ -15,6 +15,7 @@ class ChatbotNode:
|
|
| 15 |
# state['messages'][-1].content = process_query(state['messages'][-1].content)
|
| 16 |
template = chatbot_prompt()
|
| 17 |
knowledge_base = generate_api_knowledge('https://reveltrends.vercel.app')
|
|
|
|
| 18 |
messages = [SystemMessage(content=template),
|
| 19 |
FunctionMessage(name='analytics_chatbot',content=str(knowledge_base)),
|
| 20 |
] + state["messages"]
|
|
@@ -47,12 +48,15 @@ class FetchDataNode:
|
|
| 47 |
response = requests.get(url, params=state['parameters'],headers=self.headers)
|
| 48 |
elif state['endpoint'] == '/api/v1/compare/':
|
| 49 |
print('Condition satisfied')
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
payload = {
|
| 54 |
"usernames": response.names,
|
| 55 |
-
"freq":
|
| 56 |
}
|
| 57 |
|
| 58 |
print('The payload is:',payload)
|
|
|
|
| 1 |
import requests
|
| 2 |
from langchain_core.messages import SystemMessage , HumanMessage , FunctionMessage
|
| 3 |
from .state import State
|
| 4 |
+
from .schemas import ResponseFormatter , CompareBodyFormatter
|
| 5 |
+
from .prompts import chatbot_prompt , get_body_prompt
|
| 6 |
from .utils import generate_api_knowledge
|
| 7 |
from src.genai.utils.models_loader import llm_gpt
|
| 8 |
|
|
|
|
| 15 |
# state['messages'][-1].content = process_query(state['messages'][-1].content)
|
| 16 |
template = chatbot_prompt()
|
| 17 |
knowledge_base = generate_api_knowledge('https://reveltrends.vercel.app')
|
| 18 |
+
print('The knowledge base is:', knowledge_base)
|
| 19 |
messages = [SystemMessage(content=template),
|
| 20 |
FunctionMessage(name='analytics_chatbot',content=str(knowledge_base)),
|
| 21 |
] + state["messages"]
|
|
|
|
| 48 |
response = requests.get(url, params=state['parameters'],headers=self.headers)
|
| 49 |
elif state['endpoint'] == '/api/v1/compare/':
|
| 50 |
print('Condition satisfied')
|
| 51 |
+
human_messages = [msg.content for msg in state['messages'] if isinstance(msg, HumanMessage)]
|
| 52 |
+
print('Human messages:', human_messages)
|
| 53 |
+
messages = [SystemMessage(content=get_body_prompt()),
|
| 54 |
+
HumanMessage(content=str(state['messages']))]
|
| 55 |
+
response=llm_gpt.with_structured_output(CompareBodyFormatter , method='function_calling').invoke(messages)
|
| 56 |
+
print('INF names response:', response)
|
| 57 |
payload = {
|
| 58 |
"usernames": response.names,
|
| 59 |
+
"freq": response.frequency
|
| 60 |
}
|
| 61 |
|
| 62 |
print('The payload is:',payload)
|
src/genai/analytics_chatbot/utils/prompts.py
CHANGED
|
@@ -41,8 +41,27 @@ Expected output:
|
|
| 41 |
Your response must always follow this exact JSON format.
|
| 42 |
"""
|
| 43 |
|
| 44 |
-
def
|
| 45 |
-
return'''You are given
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
'''
|
|
|
|
|
|
| 41 |
Your response must always follow this exact JSON format.
|
| 42 |
"""
|
| 43 |
|
| 44 |
+
def get_body_prompt():
|
| 45 |
+
return '''You are given a user query for comparing influencers.
|
| 46 |
+
|
| 47 |
+
Your task:
|
| 48 |
+
1. Extract all influencer names in the form of list.
|
| 49 |
+
- The names should be returned exactly as they appear.
|
| 50 |
+
|
| 51 |
+
2. Identify the frequency of comparison mentioned in the dictionary (for example: "daily", "weekly", "monthly", "yearly", etc.).
|
| 52 |
+
Return the result strictly in this JSON format:
|
| 53 |
+
{
|
| 54 |
+
"names": ["<influencer_1>", "<influencer_2>", ...],
|
| 55 |
+
"frequency": "<frequency_value>"
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
Example:
|
| 59 |
+
If the query is :"I want to compare the analytics of divyadhakal_ and munachiya in weekly basis", then
|
| 60 |
+
|
| 61 |
+
Then the expected output is:
|
| 62 |
+
{
|
| 63 |
+
"names": ["divyadhakal_", "munachiya"],
|
| 64 |
+
"frequency": "weekly"
|
| 65 |
+
}
|
| 66 |
'''
|
| 67 |
+
|
src/genai/analytics_chatbot/utils/schemas.py
CHANGED
|
@@ -1,9 +1,14 @@
|
|
| 1 |
from pydantic import BaseModel, Field
|
|
|
|
| 2 |
|
| 3 |
class ResponseFormatter(BaseModel):
|
| 4 |
endpoint: str = Field(description='Return the exact endpoint from the knowledge base of endpoints.')
|
| 5 |
method: str = Field(description='Return the exact request type from the knowledge base of endpoints. GET or POST ')
|
| 6 |
-
parameters:
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
class
|
| 9 |
-
names: list
|
|
|
|
|
|
| 1 |
from pydantic import BaseModel, Field
|
| 2 |
+
from typing import Optional , Dict , Any
|
| 3 |
|
| 4 |
class ResponseFormatter(BaseModel):
|
| 5 |
endpoint: str = Field(description='Return the exact endpoint from the knowledge base of endpoints.')
|
| 6 |
method: str = Field(description='Return the exact request type from the knowledge base of endpoints. GET or POST ')
|
| 7 |
+
parameters: Optional[Dict[str, Optional[Any]]] = Field(
|
| 8 |
+
None,
|
| 9 |
+
description="Return the dictionary of parameters to pass to the endpoint. Each parameter value can be None if not specified."
|
| 10 |
+
)
|
| 11 |
|
| 12 |
+
class CompareBodyFormatter(BaseModel):
|
| 13 |
+
names: list
|
| 14 |
+
frequency: str
|