subashpoudel commited on
Commit
1493eb1
Β·
1 Parent(s): 4797a99

Next commit

Browse files
Files changed (5) hide show
  1. Dockerfile +1 -1
  2. app.py +39 -0
  3. logs/access.log +2 -0
  4. logs/app.log +1 -0
  5. streamlit_app.py +0 -50
Dockerfile CHANGED
@@ -34,4 +34,4 @@ ENV OPENAI_API_KEY=$OPENAI_API_KEY
34
  ENV ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY
35
 
36
  # Set the command to run the app (adjust as needed)
37
- CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
 
34
  ENV ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY
35
 
36
  # Set the command to run the app (adjust as needed)
37
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request
2
+ from logger_config import setup_loggers
3
+ import logging
4
+ from api.routers import orchestration, context_analysis, ideation , human_idea_refining , brainstorm , generate_final_story , generate_image, show_analytics, analytics_chatbot
5
+
6
+ setup_loggers()
7
+ app = FastAPI()
8
+
9
+
10
+ # Get loggers
11
+ app_logger = logging.getLogger("app_logger")
12
+ error_logger = logging.getLogger("error_logger")
13
+ access_logger = logging.getLogger("access_logger")
14
+ warning_logger = logging.getLogger("warning_logger")
15
+
16
+
17
+ @app.middleware("http")
18
+ async def log_requests(request: Request, call_next):
19
+ access_logger.info(f"Request: {request.method} {request.url}")
20
+ response = await call_next(request)
21
+ access_logger.info(f"Response status: {response.status_code}")
22
+ return response
23
+
24
+
25
+ @app.get("/")
26
+ async def root():
27
+ return {'response':'Hello'}
28
+
29
+ app.include_router(orchestration.router, prefix="/api")
30
+ app.include_router(show_analytics.router, prefix="/api")
31
+ app.include_router(context_analysis.router, prefix="/api")
32
+ app.include_router(ideation.router, prefix="/api")
33
+ # app.include_router(human_idea_refining.router, prefix="/api")
34
+ app.include_router(brainstorm.router, prefix="/api")
35
+ app.include_router(generate_final_story.router, prefix="/api")
36
+ app.include_router(generate_image.router, prefix="/api")
37
+ app.include_router(analytics_chatbot.router, prefix="/api")
38
+
39
+
logs/access.log CHANGED
@@ -1245,3 +1245,5 @@
1245
  2025-10-09 15:06:25,706 | INFO | access_logger | api/main.py:19 | Request: GET http://127.0.0.1:8000/api/show-analytics
1246
  2025-10-09 15:07:54,561 | INFO | access_logger | api/main.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
 
 
 
1245
  2025-10-09 15:06:25,706 | INFO | access_logger | api/main.py:19 | Request: GET http://127.0.0.1:8000/api/show-analytics
1246
  2025-10-09 15:07:54,561 | INFO | access_logger | api/main.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
logs/app.log CHANGED
@@ -125,3 +125,4 @@
125
  2025-09-21 10:33:52,133 | INFO | app_logger | api/routers/orchestration.py:28 | Orchestrator executed
126
  2025-09-21 10:35:07,705 | INFO | app_logger | api/routers/orchestration.py:28 | Orchestrator executed
127
  2025-10-09 15:07:54,561 | INFO | app_logger | api/routers/show_analytics.py:14 | Influencer Analytics returned by orchestrator.
 
 
125
  2025-09-21 10:33:52,133 | INFO | app_logger | api/routers/orchestration.py:28 | Orchestrator executed
126
  2025-09-21 10:35:07,705 | INFO | app_logger | api/routers/orchestration.py:28 | Orchestrator executed
127
  2025-10-09 15:07:54,561 | INFO | app_logger | api/routers/show_analytics.py:14 | Influencer Analytics returned by orchestrator.
128
+ 2025-10-09 16:48:20,026 | INFO | app_logger | api/routers/show_analytics.py:14 | Influencer Analytics returned by orchestrator.
streamlit_app.py DELETED
@@ -1,50 +0,0 @@
1
- import streamlit as st
2
- import requests
3
-
4
- # Your FastAPI endpoint
5
- API_URL = "http://localhost:8000/api/analytics-chatbot" # change if deployed
6
-
7
- st.set_page_config(page_title="Analytics Chatbot", page_icon="πŸ€–", layout="centered")
8
-
9
- st.title("πŸ“Š Analytics Chatbot")
10
-
11
- # Initialize chat history
12
- if "messages" not in st.session_state:
13
- st.session_state["messages"] = []
14
-
15
- # Display previous messages
16
- for chat in st.session_state["messages"]:
17
- role = "πŸ§‘ You" if chat["role"] == "user" else "πŸ€– Bot"
18
- with st.chat_message(chat["role"]):
19
- st.markdown(f"**{role}:** {chat['content']}")
20
-
21
- # User input box
22
- if prompt := st.chat_input("Ask something about analytics..."):
23
- # Store user message
24
- st.session_state["messages"].append({"role": "user", "content": prompt})
25
-
26
- # Show user message
27
- with st.chat_message("user"):
28
- st.markdown(f"**πŸ§‘ You:** {prompt}")
29
-
30
- try:
31
- # Call FastAPI backend
32
- response = requests.post(API_URL, json={"message": prompt})
33
-
34
- if response.status_code == 200:
35
- bot_reply = response.json()
36
- # bot_reply = f"**Endpoint:** {data['endpoint']}\n\n" \
37
- # f"**Parameters:** `{data['parameters']}`\n\n" \
38
- # f"**Response:** {data['response']}"
39
- else:
40
- bot_reply = f"⚠️ Error {response.status_code}: {response.text}"
41
-
42
- except Exception as e:
43
- bot_reply = f"❌ Failed to connect to API: {e}"
44
-
45
- # Store bot message
46
- st.session_state["messages"].append({"role": "assistant", "content": bot_reply['response']})
47
-
48
- # Show bot reply
49
- with st.chat_message("assistant"):
50
- st.json(bot_reply['response'])