Spaces:
Sleeping
Sleeping
Commit
·
5c271a3
1
Parent(s):
ef9fa4b
Implemented logging and try catch
Browse files- __pycache__/logger_config.cpython-312.pyc +0 -0
- api/__pycache__/main.cpython-312.pyc +0 -0
- api/main.py +1 -0
- api/routers/__pycache__/brainstorm.cpython-312.pyc +0 -0
- api/routers/__pycache__/context_analysis.cpython-312.pyc +0 -0
- api/routers/__pycache__/generate_final_story.cpython-312.pyc +0 -0
- api/routers/__pycache__/generate_image.cpython-312.pyc +0 -0
- api/routers/__pycache__/human_idea_refining.cpython-312.pyc +0 -0
- api/routers/__pycache__/ideation.cpython-312.pyc +0 -0
- api/routers/__pycache__/orchestration.cpython-312.pyc +0 -0
- api/routers/__pycache__/show_analytics.cpython-312.pyc +0 -0
- api/routers/brainstorm.py +32 -23
- api/routers/context_analysis.py +48 -35
- api/routers/generate_final_story.py +14 -5
- api/routers/generate_image.py +16 -7
- api/routers/human_idea_refining.py +21 -11
- api/routers/ideation.py +14 -4
- api/routers/orchestration.py +20 -18
- api/routers/show_analytics.py +11 -2
- api/schemas/__pycache__/__init__.cpython-312.pyc +0 -0
- api/schemas/__pycache__/orchestration.cpython-312.pyc +0 -0
- api/schemas/orchestration.py +6 -0
- logger_config.py +19 -1
- logs/access.log +50 -0
- logs/app.log +30 -1
- logs/warnings.log +0 -0
- src/genai/brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc +0 -0
- src/genai/brainstroming_agent/utils/tools.py +1 -1
- src/genai/context_analysis_agent/__pycache__/agent.cpython-312.pyc +0 -0
- src/genai/context_analysis_agent/agent.py +6 -4
- src/genai/context_analysis_agent/utils/__pycache__/nodes.cpython-312.pyc +0 -0
- src/genai/context_analysis_agent/utils/__pycache__/utils.cpython-312.pyc +0 -0
- src/genai/context_analysis_agent/utils/nodes.py +1 -1
- src/genai/context_analysis_agent/utils/utils.py +5 -4
- src/genai/ideation_agent/utils/__pycache__/tools.cpython-312.pyc +0 -0
- src/genai/ideation_agent/utils/tools.py +1 -1
- src/genai/orchestration_agent/utils/__pycache__/tools.cpython-312.pyc +0 -0
- src/genai/orchestration_agent/utils/__pycache__/utils.cpython-312.pyc +0 -0
- src/genai/orchestration_agent/utils/tools.py +1 -1
- src/genai/orchestration_agent/utils/utils.py +3 -10
- src/genai/utils/__pycache__/data_loader.cpython-312.pyc +0 -0
- src/genai/utils/__pycache__/models_loader.cpython-312.pyc +0 -0
- src/genai/utils/data_loader.py +43 -7
- src/genai/utils/load_embeddings.py +0 -33
- src/genai/utils/models_loader.py +16 -40
__pycache__/logger_config.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/logger_config.cpython-312.pyc and b/__pycache__/logger_config.cpython-312.pyc differ
|
|
|
api/__pycache__/main.cpython-312.pyc
CHANGED
|
Binary files a/api/__pycache__/main.cpython-312.pyc and b/api/__pycache__/main.cpython-312.pyc differ
|
|
|
api/main.py
CHANGED
|
@@ -11,6 +11,7 @@ app = FastAPI()
|
|
| 11 |
app_logger = logging.getLogger("app_logger")
|
| 12 |
error_logger = logging.getLogger("error_logger")
|
| 13 |
access_logger = logging.getLogger("access_logger")
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
@app.middleware("http")
|
|
|
|
| 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")
|
api/routers/__pycache__/brainstorm.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/brainstorm.cpython-312.pyc and b/api/routers/__pycache__/brainstorm.cpython-312.pyc differ
|
|
|
api/routers/__pycache__/context_analysis.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/context_analysis.cpython-312.pyc and b/api/routers/__pycache__/context_analysis.cpython-312.pyc differ
|
|
|
api/routers/__pycache__/generate_final_story.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/generate_final_story.cpython-312.pyc and b/api/routers/__pycache__/generate_final_story.cpython-312.pyc differ
|
|
|
api/routers/__pycache__/generate_image.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/generate_image.cpython-312.pyc and b/api/routers/__pycache__/generate_image.cpython-312.pyc differ
|
|
|
api/routers/__pycache__/human_idea_refining.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/human_idea_refining.cpython-312.pyc and b/api/routers/__pycache__/human_idea_refining.cpython-312.pyc differ
|
|
|
api/routers/__pycache__/ideation.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/ideation.cpython-312.pyc and b/api/routers/__pycache__/ideation.cpython-312.pyc differ
|
|
|
api/routers/__pycache__/orchestration.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/orchestration.cpython-312.pyc and b/api/routers/__pycache__/orchestration.cpython-312.pyc differ
|
|
|
api/routers/__pycache__/show_analytics.cpython-312.pyc
CHANGED
|
Binary files a/api/routers/__pycache__/show_analytics.cpython-312.pyc and b/api/routers/__pycache__/show_analytics.cpython-312.pyc differ
|
|
|
api/routers/brainstorm.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
|
|
|
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from fastapi.responses import StreamingResponse
|
| 4 |
from api.stored_data import stored_data
|
|
@@ -9,30 +10,38 @@ from api.backup_prompts import brainstorm_backup_prompt
|
|
| 9 |
router=APIRouter()
|
| 10 |
agent = BrainstormingAgent()
|
| 11 |
brainstorm_graph = agent.brainstorming_graph()
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
@router.post("/brainstorm")
|
| 14 |
def brainstorming_endpoint(request: BrainstormRequest):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def event_stream():
|
| 24 |
-
for stream_mode, chunk in brainstorm_graph.stream(
|
| 25 |
-
{
|
| 26 |
-
"idea": idea,
|
| 27 |
-
"images": request.image_base64_list,
|
| 28 |
-
"latest_preferred_topics": request.preferred_topics,
|
| 29 |
-
"business_details": stored_data["business_details"],
|
| 30 |
-
},
|
| 31 |
-
config={"configurable": {"thread_id": request.thread_id}},
|
| 32 |
-
stream_mode=['messages','values']
|
| 33 |
-
):
|
| 34 |
-
stored_data['brainstorming_response'] = chunk if isinstance(chunk, dict) else stored_data.get('brainstorming_response')
|
| 35 |
-
# if isinstance(chunk, tuple): yield f"data: {json.dumps(chunk[0].content)}"
|
| 36 |
-
if isinstance(chunk, tuple): yield chunk[0].content
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
import logging
|
| 3 |
from fastapi import APIRouter
|
| 4 |
from fastapi.responses import StreamingResponse
|
| 5 |
from api.stored_data import stored_data
|
|
|
|
| 10 |
router=APIRouter()
|
| 11 |
agent = BrainstormingAgent()
|
| 12 |
brainstorm_graph = agent.brainstorming_graph()
|
| 13 |
+
app_logger = logging.getLogger("app_logger")
|
| 14 |
+
error_logger = logging.getLogger("error_logger")
|
| 15 |
+
|
| 16 |
|
| 17 |
@router.post("/brainstorm")
|
| 18 |
def brainstorming_endpoint(request: BrainstormRequest):
|
| 19 |
+
try:
|
| 20 |
+
idea = (
|
| 21 |
+
[stored_data['refined_ideation']]
|
| 22 |
+
if stored_data.get('refined_ideation')
|
| 23 |
+
else [str(stored_data['final_ideation'])]
|
| 24 |
+
if stored_data.get('final_ideation')
|
| 25 |
+
else [brainstorm_backup_prompt]
|
| 26 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
def event_stream():
|
| 29 |
+
for stream_mode, chunk in brainstorm_graph.stream(
|
| 30 |
+
{
|
| 31 |
+
"idea": idea,
|
| 32 |
+
"images": request.image_base64_list,
|
| 33 |
+
"latest_preferred_topics": request.preferred_topics,
|
| 34 |
+
"business_details": stored_data["business_details"],
|
| 35 |
+
},
|
| 36 |
+
config={"configurable": {"thread_id": request.thread_id}},
|
| 37 |
+
stream_mode=['messages','values']
|
| 38 |
+
):
|
| 39 |
+
stored_data['brainstorming_response'] = chunk if isinstance(chunk, dict) else stored_data.get('brainstorming_response')
|
| 40 |
+
# if isinstance(chunk, tuple): yield f"data: {json.dumps(chunk[0].content)}"
|
| 41 |
+
if isinstance(chunk, tuple): yield chunk[0].content
|
| 42 |
+
app_logger.info('Executed brainstorming agent.')
|
| 43 |
+
return StreamingResponse(event_stream(), media_type="text/event-stream")
|
| 44 |
+
|
| 45 |
+
except Exception as e:
|
| 46 |
+
error_logger.error('Unable to execute brainstorm agent.')
|
| 47 |
+
raise
|
api/routers/context_analysis.py
CHANGED
|
@@ -1,51 +1,64 @@
|
|
| 1 |
import ast
|
| 2 |
import json
|
|
|
|
| 3 |
from fastapi import APIRouter
|
| 4 |
from fastapi.responses import StreamingResponse
|
| 5 |
from api.stored_data import stored_data
|
| 6 |
from src.genai.context_analysis_agent.agent import IntroductionChatbot
|
| 7 |
from api.schemas.context_analysis import UserMessage
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
router = APIRouter()
|
| 10 |
context_analysis_graph = IntroductionChatbot()
|
| 11 |
|
| 12 |
@router.post("/context-analysis")
|
| 13 |
def context_analysis(msg: UserMessage):
|
| 14 |
def event_generator():
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
return StreamingResponse(event_generator(), media_type="text/event-stream")
|
|
|
|
| 1 |
import ast
|
| 2 |
import json
|
| 3 |
+
import logging
|
| 4 |
from fastapi import APIRouter
|
| 5 |
from fastapi.responses import StreamingResponse
|
| 6 |
from api.stored_data import stored_data
|
| 7 |
from src.genai.context_analysis_agent.agent import IntroductionChatbot
|
| 8 |
from api.schemas.context_analysis import UserMessage
|
| 9 |
|
| 10 |
+
app_logger = logging.getLogger("app_logger")
|
| 11 |
+
error_logger = logging.getLogger("error_logger")
|
| 12 |
+
|
| 13 |
router = APIRouter()
|
| 14 |
context_analysis_graph = IntroductionChatbot()
|
| 15 |
|
| 16 |
@router.post("/context-analysis")
|
| 17 |
def context_analysis(msg: UserMessage):
|
| 18 |
def event_generator():
|
| 19 |
+
try:
|
| 20 |
+
accumulated_response = ""
|
| 21 |
+
for chunk in context_analysis_graph.chat(msg.message):
|
| 22 |
+
accumulated_response += chunk
|
| 23 |
+
payload = {
|
| 24 |
+
"streamed_response": chunk,
|
| 25 |
+
}
|
| 26 |
+
yield json.dumps(payload) + "\n"
|
| 27 |
+
app_logger.info('Executed context analysis agent')
|
| 28 |
+
|
| 29 |
+
last_response = context_analysis_graph.messages[-1]["content"]
|
| 30 |
+
|
| 31 |
+
if context_analysis_graph.is_complete(last_response):
|
| 32 |
+
app_logger.info('Context analysis completed.')
|
| 33 |
+
try:
|
| 34 |
+
details = context_analysis_graph.extract_details()
|
| 35 |
+
app_logger.info('Details extracted after context analysis.')
|
| 36 |
+
except Exception as e:
|
| 37 |
+
error_logger.error(f'Unable to extract details: {e}')
|
| 38 |
+
|
| 39 |
+
if type(details) != dict:details = details.model_dump()
|
| 40 |
+
if isinstance(details, str):details = ast.literal_eval(details)
|
| 41 |
+
|
| 42 |
+
stored_data["business_details"] = details
|
| 43 |
+
try:
|
| 44 |
+
context_analysis_graph.reset()
|
| 45 |
+
app_logger.info('Context analysis memory reset after details extraction.')
|
| 46 |
+
except Exception as e:
|
| 47 |
+
error_logger.error('Unable to reset memory:', e)
|
| 48 |
+
|
| 49 |
+
final_payload = {
|
| 50 |
+
"response": accumulated_response,
|
| 51 |
+
"complete": True,
|
| 52 |
+
"business_details": details
|
| 53 |
+
}
|
| 54 |
+
else:
|
| 55 |
+
final_payload = {
|
| 56 |
+
"response": accumulated_response,
|
| 57 |
+
"complete": False
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
yield json.dumps(final_payload) + "\n"
|
| 61 |
+
except Exception as e:
|
| 62 |
+
error_logger.error('Unable to run context analysis agent:', e)
|
| 63 |
|
| 64 |
return StreamingResponse(event_generator(), media_type="text/event-stream")
|
api/routers/generate_final_story.py
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
from fastapi.responses import StreamingResponse
|
| 3 |
from api.stored_data import stored_data
|
| 4 |
from src.genai.brainstroming_agent.utils.utils import FinalStoryGenenrator
|
| 5 |
|
| 6 |
router= APIRouter()
|
|
|
|
|
|
|
| 7 |
|
| 8 |
@router.post("/generate-final-story")
|
| 9 |
def generate_final_story_endpoint():
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from fastapi.responses import StreamingResponse
|
| 4 |
from api.stored_data import stored_data
|
| 5 |
from src.genai.brainstroming_agent.utils.utils import FinalStoryGenenrator
|
| 6 |
|
| 7 |
router= APIRouter()
|
| 8 |
+
app_logger = logging.getLogger("app_logger")
|
| 9 |
+
error_logger = logging.getLogger("error_logger")
|
| 10 |
|
| 11 |
@router.post("/generate-final-story")
|
| 12 |
def generate_final_story_endpoint():
|
| 13 |
+
try:
|
| 14 |
+
def event_stream():
|
| 15 |
+
for chunk in FinalStoryGenenrator().generate_final_story(stored_data.get('brainstorming_response') or stored_data.get('business_details')):
|
| 16 |
+
yield chunk
|
| 17 |
+
app_logger.info('Executed final story generation.')
|
| 18 |
+
return StreamingResponse(event_stream(), media_type="text/event-stream")
|
| 19 |
+
|
| 20 |
+
except Exception as e:
|
| 21 |
+
error_logger.error('Unable to generate final story.')
|
| 22 |
+
raise
|
| 23 |
+
|
api/routers/generate_image.py
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
from api.stored_data import stored_data
|
| 3 |
from src.genai.brainstroming_agent.utils.utils import ImageGenerator
|
| 4 |
from api.backup_prompts import image_gen_backup_prompt
|
|
|
|
| 5 |
router = APIRouter()
|
|
|
|
|
|
|
| 6 |
|
| 7 |
@router.post("/generate-image")
|
| 8 |
def generate_image_endpoint():
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
'
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from api.stored_data import stored_data
|
| 4 |
from src.genai.brainstroming_agent.utils.utils import ImageGenerator
|
| 5 |
from api.backup_prompts import image_gen_backup_prompt
|
| 6 |
+
|
| 7 |
router = APIRouter()
|
| 8 |
+
app_logger = logging.getLogger("app_logger")
|
| 9 |
+
error_logger = logging.getLogger("error_logger")
|
| 10 |
|
| 11 |
@router.post("/generate-image")
|
| 12 |
def generate_image_endpoint():
|
| 13 |
+
try:
|
| 14 |
+
image = ImageGenerator().generate_image(str(stored_data.get('final_story',image_gen_backup_prompt))
|
| 15 |
+
,str(stored_data.get('business_details'))
|
| 16 |
+
,str(stored_data.get('refined_ideation',image_gen_backup_prompt)))
|
| 17 |
+
stored_data['generated_image']=image
|
| 18 |
+
app_logger.info('The image is Generated')
|
| 19 |
+
return {
|
| 20 |
+
'response':image
|
| 21 |
+
}
|
| 22 |
+
except Exception as e:
|
| 23 |
+
error_logger.error('Unable to generate image')
|
| 24 |
+
raise
|
api/routers/human_idea_refining.py
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
from api.stored_data import stored_data
|
| 3 |
from src.genai.human_refined_ideation.agent import human_refined_idea
|
| 4 |
from api.schemas.human_idea_refining import RefineIdeationRequest
|
|
|
|
| 5 |
router= APIRouter()
|
| 6 |
human_refine_graph = human_refined_idea()
|
|
|
|
|
|
|
| 7 |
|
| 8 |
@router.post("/human-idea-refining")
|
| 9 |
def human_idea_refine_endpoint(request:RefineIdeationRequest):
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from api.stored_data import stored_data
|
| 4 |
from src.genai.human_refined_ideation.agent import human_refined_idea
|
| 5 |
from api.schemas.human_idea_refining import RefineIdeationRequest
|
| 6 |
+
|
| 7 |
router= APIRouter()
|
| 8 |
human_refine_graph = human_refined_idea()
|
| 9 |
+
app_logger = logging.getLogger("app_logger")
|
| 10 |
+
error_logger = logging.getLogger("error_logger")
|
| 11 |
|
| 12 |
@router.post("/human-idea-refining")
|
| 13 |
def human_idea_refine_endpoint(request:RefineIdeationRequest):
|
| 14 |
+
try:
|
| 15 |
+
stored_data['human_ideation_interactions'].append({"role": "user", "content": request.query})
|
| 16 |
+
response = human_refine_graph.invoke(
|
| 17 |
+
{
|
| 18 |
+
'query': stored_data['human_ideation_interactions'],
|
| 19 |
+
'business_details': stored_data["business_details"],
|
| 20 |
+
'final_ideation': stored_data.get('final_ideation',["","","",""]),
|
| 21 |
+
},config={"configurable": {"thread_id": request.thread_id}}
|
| 22 |
+
)
|
| 23 |
+
stored_data['human_ideation_interactions'].append({"role": "assistant", "content": response['result']})
|
| 24 |
+
stored_data['refined_ideation'] = stored_data['human_ideation_interactions'][-1]['content']
|
| 25 |
+
app_logger.info('Executed human ideation refining.')
|
| 26 |
+
return {'response' : stored_data['human_ideation_interactions'][-1]['content'] }
|
| 27 |
+
|
| 28 |
+
except Exception as e:
|
| 29 |
+
error_logger.error('Unable to execute human idea refining agent:', e)
|
| 30 |
+
raise
|
api/routers/ideation.py
CHANGED
|
@@ -1,9 +1,13 @@
|
|
| 1 |
import ast
|
|
|
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from api.stored_data import stored_data
|
| 4 |
from src.genai.ideation_agent.agent import IdeationAgent
|
| 5 |
from langgraph.errors import GraphRecursionError
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
router = APIRouter()
|
| 8 |
agent = IdeationAgent()
|
| 9 |
idea_graph = agent.ideation_graph()
|
|
@@ -16,15 +20,21 @@ def ideation_endpoint():
|
|
| 16 |
{
|
| 17 |
'business_details': [stored_data['business_details']],
|
| 18 |
'image_caption': [stored_data['image_caption'] if 'image_caption' in stored_data else ""]
|
| 19 |
-
|
| 20 |
},
|
| 21 |
-
config=config
|
| 22 |
-
|
| 23 |
stored_data['final_ideation'] = result['formatted_response'][-1]
|
| 24 |
stored_data['final_ideation']=ast.literal_eval(stored_data['final_ideation'])
|
| 25 |
-
|
|
|
|
| 26 |
return {'response':ast.literal_eval(result['formatted_response'][-1])}
|
|
|
|
| 27 |
except GraphRecursionError:
|
|
|
|
| 28 |
result = idea_graph.get_state({"configurable": {"thread_id": "ideation_thread123"}})
|
| 29 |
return {'response': result[0]}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
| 1 |
import ast
|
| 2 |
+
import logging
|
| 3 |
from fastapi import APIRouter
|
| 4 |
from api.stored_data import stored_data
|
| 5 |
from src.genai.ideation_agent.agent import IdeationAgent
|
| 6 |
from langgraph.errors import GraphRecursionError
|
| 7 |
|
| 8 |
+
app_logger = logging.getLogger("app_logger")
|
| 9 |
+
error_logger = logging.getLogger("error_logger")
|
| 10 |
+
|
| 11 |
router = APIRouter()
|
| 12 |
agent = IdeationAgent()
|
| 13 |
idea_graph = agent.ideation_graph()
|
|
|
|
| 20 |
{
|
| 21 |
'business_details': [stored_data['business_details']],
|
| 22 |
'image_caption': [stored_data['image_caption'] if 'image_caption' in stored_data else ""]
|
|
|
|
| 23 |
},
|
| 24 |
+
config=config)
|
| 25 |
+
|
| 26 |
stored_data['final_ideation'] = result['formatted_response'][-1]
|
| 27 |
stored_data['final_ideation']=ast.literal_eval(stored_data['final_ideation'])
|
| 28 |
+
app_logger.info('Executed the ideation pipeline.')
|
| 29 |
+
|
| 30 |
return {'response':ast.literal_eval(result['formatted_response'][-1])}
|
| 31 |
+
|
| 32 |
except GraphRecursionError:
|
| 33 |
+
error_logger.error('Ideation loop ran more than specified.')
|
| 34 |
result = idea_graph.get_state({"configurable": {"thread_id": "ideation_thread123"}})
|
| 35 |
return {'response': result[0]}
|
| 36 |
+
|
| 37 |
+
except Exception as e:
|
| 38 |
+
error_logger.error('Unable to execute the ideation', e)
|
| 39 |
+
raise
|
| 40 |
|
api/routers/orchestration.py
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
-
from pydantic import BaseModel
|
| 3 |
from api.stored_data import stored_data
|
| 4 |
from src.genai.orchestration_agent.agent import OrchestrationAgent
|
| 5 |
-
from
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
image_base64 : Optional[list] = []
|
| 10 |
|
| 11 |
router= APIRouter()
|
| 12 |
agent = OrchestrationAgent()
|
|
|
|
| 13 |
@router.post("/orchestration")
|
| 14 |
def orchestration_endpoint(request:OrchestrationRequest):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
return {'tool_response': result.tool ,
|
| 25 |
-
'message_response': result.query_response,
|
| 26 |
-
'image_caption':result.image_caption,
|
| 27 |
-
'video_idea': result.video_idea,
|
| 28 |
-
'video_story': result.video_story}
|
| 29 |
|
| 30 |
|
|
|
|
| 1 |
+
import logging
|
| 2 |
from fastapi import APIRouter
|
|
|
|
| 3 |
from api.stored_data import stored_data
|
| 4 |
from src.genai.orchestration_agent.agent import OrchestrationAgent
|
| 5 |
+
from api.schemas.orchestration import OrchestrationRequest
|
| 6 |
|
| 7 |
+
app_logger = logging.getLogger("app_logger")
|
| 8 |
+
error_logger = logging.getLogger("error_logger")
|
|
|
|
| 9 |
|
| 10 |
router= APIRouter()
|
| 11 |
agent = OrchestrationAgent()
|
| 12 |
+
|
| 13 |
@router.post("/orchestration")
|
| 14 |
def orchestration_endpoint(request:OrchestrationRequest):
|
| 15 |
+
try:
|
| 16 |
+
result = agent.chat(request.message , request.image_base64)
|
| 17 |
+
if result.image_caption != '': stored_data['image_caption']=result.image_caption
|
| 18 |
+
if result.video_idea !='' or result.video_idea != 'null': stored_data['refined_ideation']= result.video_idea
|
| 19 |
+
if result.video_story!='' or result.video_story!='null': stored_data['final_story']= result.video_story
|
| 20 |
+
app_logger.info('Orchestrator executed')
|
| 21 |
+
|
| 22 |
+
return {'tool_response': result.tool ,
|
| 23 |
+
'message_response': result.query_response,
|
| 24 |
+
'image_caption':result.image_caption,
|
| 25 |
+
'video_idea': result.video_idea,
|
| 26 |
+
'video_story': result.video_story}
|
| 27 |
+
except Exception as e:
|
| 28 |
+
error_logger.error('Unable to run orchestration:', e)
|
| 29 |
+
raise
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
|
api/routers/show_analytics.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
from api.stored_data import stored_data
|
| 3 |
from src.genai.orchestration_agent.utils.utils import AnalyticsViewer
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
router=APIRouter()
|
| 6 |
@router.post("/show-analytics")
|
| 7 |
def show_analytics_endpoint():
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from api.stored_data import stored_data
|
| 4 |
from src.genai.orchestration_agent.utils.utils import AnalyticsViewer
|
| 5 |
|
| 6 |
+
app_logger = logging.getLogger("app_logger")
|
| 7 |
+
error_logger = logging.getLogger("error_logger")
|
| 8 |
+
|
| 9 |
router=APIRouter()
|
| 10 |
@router.post("/show-analytics")
|
| 11 |
def show_analytics_endpoint():
|
| 12 |
+
try:
|
| 13 |
+
response = AnalyticsViewer(stored_data['business_details']).show_analytics()
|
| 14 |
+
app_logger.info('Influencer Analytics returned by orchestrator.')
|
| 15 |
+
return {'response': response}
|
| 16 |
+
except Exception as e:
|
| 17 |
+
error_logger.error('Unable to extract influencer analytics:', e)
|
| 18 |
+
raise
|
api/schemas/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (178 Bytes). View file
|
|
|
api/schemas/__pycache__/orchestration.cpython-312.pyc
ADDED
|
Binary file (566 Bytes). View file
|
|
|
api/schemas/orchestration.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pydantic import BaseModel
|
| 2 |
+
from typing import Optional
|
| 3 |
+
|
| 4 |
+
class OrchestrationRequest(BaseModel):
|
| 5 |
+
message: str
|
| 6 |
+
image_base64 : Optional[list] = []
|
logger_config.py
CHANGED
|
@@ -2,11 +2,17 @@
|
|
| 2 |
import logging
|
| 3 |
import os
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
def setup_loggers():
|
| 6 |
os.makedirs("logs", exist_ok=True)
|
| 7 |
|
| 8 |
# === Format ===
|
| 9 |
-
formatter = logging.Formatter("%(asctime)s | %(levelname)s | %(name)s | %(message)s")
|
|
|
|
| 10 |
|
| 11 |
# === App Logger ===
|
| 12 |
app_logger = logging.getLogger("app_logger")
|
|
@@ -32,9 +38,21 @@ def setup_loggers():
|
|
| 32 |
access_logger.setLevel(logging.INFO)
|
| 33 |
access_logger.addHandler(access_handler)
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
# Optional: also log to console
|
| 36 |
console_handler = logging.StreamHandler()
|
| 37 |
console_handler.setFormatter(formatter)
|
| 38 |
app_logger.addHandler(console_handler)
|
| 39 |
error_logger.addHandler(console_handler)
|
| 40 |
access_logger.addHandler(console_handler)
|
|
|
|
|
|
|
|
|
| 2 |
import logging
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
class RelativePathFormatter(logging.Formatter):
|
| 6 |
+
def format(self, record):
|
| 7 |
+
record.relpath = os.path.relpath(record.pathname, os.getcwd())
|
| 8 |
+
return super().format(record)
|
| 9 |
+
|
| 10 |
def setup_loggers():
|
| 11 |
os.makedirs("logs", exist_ok=True)
|
| 12 |
|
| 13 |
# === Format ===
|
| 14 |
+
# formatter = logging.Formatter("%(asctime)s | %(levelname)s | %(name)s | %(message)s")
|
| 15 |
+
formatter = RelativePathFormatter("%(asctime)s | %(levelname)s | %(name)s | %(relpath)s:%(lineno)d | %(message)s")
|
| 16 |
|
| 17 |
# === App Logger ===
|
| 18 |
app_logger = logging.getLogger("app_logger")
|
|
|
|
| 38 |
access_logger.setLevel(logging.INFO)
|
| 39 |
access_logger.addHandler(access_handler)
|
| 40 |
|
| 41 |
+
|
| 42 |
+
# === Warning Logger ===
|
| 43 |
+
warning_logger = logging.getLogger("warning_logger")
|
| 44 |
+
warning_handler = logging.FileHandler("logs/warnings.log")
|
| 45 |
+
warning_handler.setLevel(logging.WARNING) # WARNING, ERROR, CRITICAL
|
| 46 |
+
warning_handler.setFormatter(formatter)
|
| 47 |
+
warning_logger.setLevel(logging.WARNING)
|
| 48 |
+
warning_logger.addHandler(warning_handler)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
# Optional: also log to console
|
| 52 |
console_handler = logging.StreamHandler()
|
| 53 |
console_handler.setFormatter(formatter)
|
| 54 |
app_logger.addHandler(console_handler)
|
| 55 |
error_logger.addHandler(console_handler)
|
| 56 |
access_logger.addHandler(console_handler)
|
| 57 |
+
warning_logger.addHandler(console_handler)
|
| 58 |
+
|
logs/access.log
CHANGED
|
@@ -331,3 +331,53 @@
|
|
| 331 |
2025-08-15 15:12:47,265 | INFO | access_logger | Response status: 200
|
| 332 |
2025-08-15 15:16:31,623 | INFO | access_logger | Request: POST http://127.0.0.1:8000/api/context-analysis
|
| 333 |
2025-08-15 15:16:31,646 | INFO | access_logger | Response status: 200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
2025-08-15 15:12:47,265 | INFO | access_logger | Response status: 200
|
| 332 |
2025-08-15 15:16:31,623 | INFO | access_logger | Request: POST http://127.0.0.1:8000/api/context-analysis
|
| 333 |
2025-08-15 15:16:31,646 | INFO | access_logger | Response status: 200
|
| 334 |
+
2025-08-17 14:00:44,955 | INFO | access_logger | api\main.py:19 | Request: GET http://127.0.0.1:8000/docs
|
| 335 |
+
2025-08-17 14:00:44,955 | INFO | access_logger | api\main.py:19 | Request: GET http://127.0.0.1:8000/docs
|
| 336 |
+
2025-08-17 14:00:44,988 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 337 |
+
2025-08-17 14:00:44,988 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 338 |
+
2025-08-17 14:00:45,317 | INFO | access_logger | api\main.py:19 | Request: GET http://127.0.0.1:8000/openapi.json
|
| 339 |
+
2025-08-17 14:00:45,317 | INFO | access_logger | api\main.py:19 | Request: GET http://127.0.0.1:8000/openapi.json
|
| 340 |
+
2025-08-17 14:00:45,332 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 341 |
+
2025-08-17 14:00:45,332 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 342 |
+
2025-08-17 14:01:37,707 | INFO | access_logger | api\main.py:19 | Request: GET http://127.0.0.1:8000/
|
| 343 |
+
2025-08-17 14:01:37,707 | INFO | access_logger | api\main.py:19 | Request: GET http://127.0.0.1:8000/
|
| 344 |
+
2025-08-17 14:01:37,708 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 345 |
+
2025-08-17 14:01:37,708 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 346 |
+
2025-08-17 14:01:52,138 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/orchestration
|
| 347 |
+
2025-08-17 14:01:52,138 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/orchestration
|
| 348 |
+
2025-08-17 14:02:00,653 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 349 |
+
2025-08-17 14:02:00,653 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 350 |
+
2025-08-17 14:02:51,400 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/show-analytics
|
| 351 |
+
2025-08-17 14:02:51,400 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/show-analytics
|
| 352 |
+
2025-08-17 14:02:52,614 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 353 |
+
2025-08-17 14:02:52,614 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 354 |
+
2025-08-17 14:03:31,051 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/context-analysis
|
| 355 |
+
2025-08-17 14:03:31,051 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/context-analysis
|
| 356 |
+
2025-08-17 14:03:31,055 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 357 |
+
2025-08-17 14:03:31,055 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 358 |
+
2025-08-17 14:03:54,120 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/ideation
|
| 359 |
+
2025-08-17 14:03:54,120 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/ideation
|
| 360 |
+
2025-08-17 14:04:55,699 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 361 |
+
2025-08-17 14:04:55,699 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 362 |
+
2025-08-17 14:06:10,799 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/human-idea-refining
|
| 363 |
+
2025-08-17 14:06:10,799 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/human-idea-refining
|
| 364 |
+
2025-08-17 14:06:14,163 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 365 |
+
2025-08-17 14:06:14,163 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 366 |
+
2025-08-17 14:06:31,241 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/brainstorm
|
| 367 |
+
2025-08-17 14:06:31,241 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/brainstorm
|
| 368 |
+
2025-08-17 14:06:31,245 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 369 |
+
2025-08-17 14:06:31,245 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 370 |
+
2025-08-17 14:07:16,274 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/generate-final-story
|
| 371 |
+
2025-08-17 14:07:16,274 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/generate-final-story
|
| 372 |
+
2025-08-17 14:07:16,283 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 373 |
+
2025-08-17 14:07:16,283 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 374 |
+
2025-08-17 14:07:28,222 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/generate-image
|
| 375 |
+
2025-08-17 14:07:28,222 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/generate-image
|
| 376 |
+
2025-08-17 14:07:40,034 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 377 |
+
2025-08-17 14:07:40,034 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 378 |
+
2025-08-17 14:13:44,422 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/show-analytics
|
| 379 |
+
2025-08-17 14:13:45,525 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 380 |
+
2025-08-17 15:22:50,869 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/show-analytics
|
| 381 |
+
2025-08-17 15:22:52,619 | INFO | access_logger | api\main.py:21 | Response status: 200
|
| 382 |
+
2025-08-17 15:23:25,844 | INFO | access_logger | api\main.py:19 | Request: POST http://127.0.0.1:8000/api/ideation
|
| 383 |
+
2025-08-17 15:24:08,120 | INFO | access_logger | api\main.py:21 | Response status: 200
|
logs/app.log
CHANGED
|
@@ -1,6 +1,35 @@
|
|
| 1 |
2025-07-30 16:53:23,605 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 2 |
2025-08-12 17:03:25,262 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 3 |
-
2025-08-13 11:48:54,941 | ERROR | app_logger | Error while showing analytics: retrieve_data_for_analytics() missing 1 required positional argument: 'business_details'
|
| 4 |
2025-08-13 13:53:24,416 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 5 |
2025-08-13 17:24:22,398 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 6 |
2025-08-15 14:33:03,159 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
2025-07-30 16:53:23,605 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 2 |
2025-08-12 17:03:25,262 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
|
|
|
| 3 |
2025-08-13 13:53:24,416 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 4 |
2025-08-13 17:24:22,398 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 5 |
2025-08-15 14:33:03,159 | INFO | app_logger | Showing Analytics of the influencers after context analysis.
|
| 6 |
+
2025-08-17 12:01:31,453 | INFO | app_logger | Checking the logging
|
| 7 |
+
2025-08-17 12:01:35,639 | INFO | app_logger | Checking the logging
|
| 8 |
+
2025-08-17 12:02:44,510 | INFO | app_logger | logger_config.py:65 | Checking the logging
|
| 9 |
+
2025-08-17 12:06:40,293 | INFO | app_logger | Context Analysis agent initialized.
|
| 10 |
+
2025-08-17 12:06:40,294 | INFO | app_logger | Details are extracted.
|
| 11 |
+
2025-08-17 12:06:42,154 | INFO | app_logger | Context Analysis agent initialized.
|
| 12 |
+
2025-08-17 12:06:48,500 | INFO | app_logger | logger_config.py:65 | Checking the logging
|
| 13 |
+
2025-08-17 12:07:11,398 | INFO | app_logger | src\genai\context_analysis_agent\agent.py:21 | Context Analysis agent initialized.
|
| 14 |
+
2025-08-17 12:07:11,398 | INFO | app_logger | src\genai\context_analysis_agent\agent.py:46 | Details are extracted.
|
| 15 |
+
2025-08-17 12:07:12,641 | INFO | app_logger | src\genai\context_analysis_agent\agent.py:21 | Context Analysis agent initialized.
|
| 16 |
+
2025-08-17 13:59:22,347 | INFO | app_logger | logger_config.py:65 | Checking the logging
|
| 17 |
+
2025-08-17 14:02:00,651 | INFO | app_logger | api\routers\orchestration.py:20 | Orchestrator executed
|
| 18 |
+
2025-08-17 14:02:00,651 | INFO | app_logger | api\routers\orchestration.py:20 | Orchestrator executed
|
| 19 |
+
2025-08-17 14:02:52,612 | INFO | app_logger | api\routers\show_analytics.py:14 | Influencer Analytics returned by orchestrator.
|
| 20 |
+
2025-08-17 14:02:52,612 | INFO | app_logger | api\routers\show_analytics.py:14 | Influencer Analytics returned by orchestrator.
|
| 21 |
+
2025-08-17 14:03:33,201 | INFO | app_logger | api\routers\context_analysis.py:27 | Executed context analysis agent
|
| 22 |
+
2025-08-17 14:03:33,201 | INFO | app_logger | api\routers\context_analysis.py:27 | Executed context analysis agent
|
| 23 |
+
2025-08-17 14:04:55,698 | INFO | app_logger | api\routers\ideation.py:28 | Executed the ideation pipeline.
|
| 24 |
+
2025-08-17 14:04:55,698 | INFO | app_logger | api\routers\ideation.py:28 | Executed the ideation pipeline.
|
| 25 |
+
2025-08-17 14:06:14,161 | INFO | app_logger | api\routers\human_idea_refining.py:25 | Executed human ideation refining.
|
| 26 |
+
2025-08-17 14:06:14,161 | INFO | app_logger | api\routers\human_idea_refining.py:25 | Executed human ideation refining.
|
| 27 |
+
2025-08-17 14:06:31,243 | INFO | app_logger | api\routers\brainstorm.py:42 | Executed brainstorming agent.
|
| 28 |
+
2025-08-17 14:06:31,243 | INFO | app_logger | api\routers\brainstorm.py:42 | Executed brainstorming agent.
|
| 29 |
+
2025-08-17 14:07:16,281 | INFO | app_logger | api\routers\generate_final_story.py:17 | Executed final story generation.
|
| 30 |
+
2025-08-17 14:07:16,281 | INFO | app_logger | api\routers\generate_final_story.py:17 | Executed final story generation.
|
| 31 |
+
2025-08-17 14:07:40,022 | INFO | app_logger | api\routers\generate_image.py:18 | The image is Generated
|
| 32 |
+
2025-08-17 14:07:40,022 | INFO | app_logger | api\routers\generate_image.py:18 | The image is Generated
|
| 33 |
+
2025-08-17 14:13:45,517 | INFO | app_logger | api\routers\show_analytics.py:14 | Influencer Analytics returned by orchestrator.
|
| 34 |
+
2025-08-17 15:22:52,597 | INFO | app_logger | api\routers\show_analytics.py:14 | Influencer Analytics returned by orchestrator.
|
| 35 |
+
2025-08-17 15:24:08,119 | INFO | app_logger | api\routers\ideation.py:28 | Executed the ideation pipeline.
|
logs/warnings.log
ADDED
|
File without changes
|
src/genai/brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc and b/src/genai/brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc differ
|
|
|
src/genai/brainstroming_agent/utils/tools.py
CHANGED
|
@@ -5,7 +5,7 @@ from src.genai.utils.models_loader import embedding_model , llm
|
|
| 5 |
import numpy as np
|
| 6 |
import faiss
|
| 7 |
import tiktoken
|
| 8 |
-
from src.genai.utils.
|
| 9 |
from src.genai.utils.utils import clean_text
|
| 10 |
|
| 11 |
class Retrieval:
|
|
|
|
| 5 |
import numpy as np
|
| 6 |
import faiss
|
| 7 |
import tiktoken
|
| 8 |
+
from src.genai.utils.data_loader import caption_index , caption_df
|
| 9 |
from src.genai.utils.utils import clean_text
|
| 10 |
|
| 11 |
class Retrieval:
|
src/genai/context_analysis_agent/__pycache__/agent.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/context_analysis_agent/__pycache__/agent.cpython-312.pyc and b/src/genai/context_analysis_agent/__pycache__/agent.cpython-312.pyc differ
|
|
|
src/genai/context_analysis_agent/agent.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
from langgraph.graph import StateGraph, MessagesState, START, END
|
| 3 |
from langgraph.checkpoint.memory import MemorySaver
|
| 4 |
from .utils.state import State
|
|
@@ -6,6 +6,7 @@ from .utils.nodes import IntroductionNode
|
|
| 6 |
from .utils.utils import DetailsExtractor
|
| 7 |
from src.genai.utils.models_loader import llm_gpt
|
| 8 |
|
|
|
|
| 9 |
business_state = State()
|
| 10 |
|
| 11 |
class IntroductionChatbot:
|
|
@@ -16,6 +17,7 @@ class IntroductionChatbot:
|
|
| 16 |
self.interact_agent = self.workflow.compile(checkpointer=self.memory)
|
| 17 |
self.messages = []
|
| 18 |
|
|
|
|
| 19 |
def _initialize_workflow(self):
|
| 20 |
workflow = StateGraph(MessagesState)
|
| 21 |
workflow.add_node("chatbot", lambda state: IntroductionNode().run(state, self.llm))
|
|
@@ -38,11 +40,11 @@ class IntroductionChatbot:
|
|
| 38 |
return "Thanks for providing all your required business details" in latest_response
|
| 39 |
|
| 40 |
def extract_details(self):
|
| 41 |
-
response = DetailsExtractor().run(
|
| 42 |
-
print('Extracted details:', response)
|
| 43 |
return response
|
| 44 |
|
| 45 |
def reset(self):
|
| 46 |
self.memory= MemorySaver()
|
| 47 |
self.interact_agent = self.workflow.compile(checkpointer=self.memory)
|
| 48 |
-
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
from langgraph.graph import StateGraph, MessagesState, START, END
|
| 3 |
from langgraph.checkpoint.memory import MemorySaver
|
| 4 |
from .utils.state import State
|
|
|
|
| 6 |
from .utils.utils import DetailsExtractor
|
| 7 |
from src.genai.utils.models_loader import llm_gpt
|
| 8 |
|
| 9 |
+
|
| 10 |
business_state = State()
|
| 11 |
|
| 12 |
class IntroductionChatbot:
|
|
|
|
| 17 |
self.interact_agent = self.workflow.compile(checkpointer=self.memory)
|
| 18 |
self.messages = []
|
| 19 |
|
| 20 |
+
|
| 21 |
def _initialize_workflow(self):
|
| 22 |
workflow = StateGraph(MessagesState)
|
| 23 |
workflow.add_node("chatbot", lambda state: IntroductionNode().run(state, self.llm))
|
|
|
|
| 40 |
return "Thanks for providing all your required business details" in latest_response
|
| 41 |
|
| 42 |
def extract_details(self):
|
| 43 |
+
response = DetailsExtractor(business_state.interactions).run()
|
|
|
|
| 44 |
return response
|
| 45 |
|
| 46 |
def reset(self):
|
| 47 |
self.memory= MemorySaver()
|
| 48 |
self.interact_agent = self.workflow.compile(checkpointer=self.memory)
|
| 49 |
+
|
| 50 |
+
|
src/genai/context_analysis_agent/utils/__pycache__/nodes.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/context_analysis_agent/utils/__pycache__/nodes.cpython-312.pyc and b/src/genai/context_analysis_agent/utils/__pycache__/nodes.cpython-312.pyc differ
|
|
|
src/genai/context_analysis_agent/utils/__pycache__/utils.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/context_analysis_agent/utils/__pycache__/utils.cpython-312.pyc and b/src/genai/context_analysis_agent/utils/__pycache__/utils.cpython-312.pyc differ
|
|
|
src/genai/context_analysis_agent/utils/nodes.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
from .state import DetailsFormatter
|
| 2 |
from langchain_core.messages import SystemMessage
|
| 3 |
from src.genai.utils.models_loader import llm_gpt
|
| 4 |
from .prompts import introduction_prompt
|
| 5 |
|
|
|
|
| 6 |
class IntroductionNode:
|
| 7 |
def __init__(self):
|
| 8 |
self.llm = llm_gpt
|
|
|
|
|
|
|
| 1 |
from langchain_core.messages import SystemMessage
|
| 2 |
from src.genai.utils.models_loader import llm_gpt
|
| 3 |
from .prompts import introduction_prompt
|
| 4 |
|
| 5 |
+
|
| 6 |
class IntroductionNode:
|
| 7 |
def __init__(self):
|
| 8 |
self.llm = llm_gpt
|
src/genai/context_analysis_agent/utils/utils.py
CHANGED
|
@@ -1,16 +1,17 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
-
from src.genai.utils.
|
| 3 |
from src.genai.utils.models_loader import llm_gpt
|
| 4 |
from .prompts import details_extract_prompt
|
| 5 |
from langchain_core.messages import SystemMessage
|
| 6 |
from .state import DetailsFormatter
|
| 7 |
|
| 8 |
class DetailsExtractor:
|
| 9 |
-
def __init__(self):
|
| 10 |
self.llm = llm_gpt
|
|
|
|
| 11 |
|
| 12 |
-
def run(
|
| 13 |
-
template = details_extract_prompt(interactions)
|
| 14 |
messages = [SystemMessage(content=template)]
|
| 15 |
response=llm_gpt.with_structured_output(DetailsFormatter).invoke(messages)
|
| 16 |
return response
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
from src.genai.utils.data_loader import caption_df
|
| 3 |
from src.genai.utils.models_loader import llm_gpt
|
| 4 |
from .prompts import details_extract_prompt
|
| 5 |
from langchain_core.messages import SystemMessage
|
| 6 |
from .state import DetailsFormatter
|
| 7 |
|
| 8 |
class DetailsExtractor:
|
| 9 |
+
def __init__(self, interactions):
|
| 10 |
self.llm = llm_gpt
|
| 11 |
+
self.interactions = interactions
|
| 12 |
|
| 13 |
+
def run(self):
|
| 14 |
+
template = details_extract_prompt(self.interactions)
|
| 15 |
messages = [SystemMessage(content=template)]
|
| 16 |
response=llm_gpt.with_structured_output(DetailsFormatter).invoke(messages)
|
| 17 |
return response
|
src/genai/ideation_agent/utils/__pycache__/tools.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/ideation_agent/utils/__pycache__/tools.cpython-312.pyc and b/src/genai/ideation_agent/utils/__pycache__/tools.cpython-312.pyc differ
|
|
|
src/genai/ideation_agent/utils/tools.py
CHANGED
|
@@ -7,7 +7,7 @@ import ast
|
|
| 7 |
import faiss
|
| 8 |
import tiktoken
|
| 9 |
from src.genai.utils.models_loader import embedding_model
|
| 10 |
-
from src.genai.utils.
|
| 11 |
from src.genai.utils.utils import clean_text
|
| 12 |
|
| 13 |
|
|
|
|
| 7 |
import faiss
|
| 8 |
import tiktoken
|
| 9 |
from src.genai.utils.models_loader import embedding_model
|
| 10 |
+
from src.genai.utils.data_loader import caption_index , caption_df, ideas_index , ideas_df
|
| 11 |
from src.genai.utils.utils import clean_text
|
| 12 |
|
| 13 |
|
src/genai/orchestration_agent/utils/__pycache__/tools.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/orchestration_agent/utils/__pycache__/tools.cpython-312.pyc and b/src/genai/orchestration_agent/utils/__pycache__/tools.cpython-312.pyc differ
|
|
|
src/genai/orchestration_agent/utils/__pycache__/utils.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/orchestration_agent/utils/__pycache__/utils.cpython-312.pyc and b/src/genai/orchestration_agent/utils/__pycache__/utils.cpython-312.pyc differ
|
|
|
src/genai/orchestration_agent/utils/tools.py
CHANGED
|
@@ -2,7 +2,7 @@ import faiss
|
|
| 2 |
import ast
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
-
from src.genai.utils.
|
| 6 |
from src.genai.utils.models_loader import embedding_model
|
| 7 |
from src.genai.utils.utils import clean_text
|
| 8 |
import tiktoken
|
|
|
|
| 2 |
import ast
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
+
from src.genai.utils.data_loader import caption_df, caption_embeddings , caption_index
|
| 6 |
from src.genai.utils.models_loader import embedding_model
|
| 7 |
from src.genai.utils.utils import clean_text
|
| 8 |
import tiktoken
|
src/genai/orchestration_agent/utils/utils.py
CHANGED
|
@@ -8,9 +8,6 @@ from src.genai.utils.models_loader import llm
|
|
| 8 |
from langchain_core.messages import FunctionMessage , AIMessage
|
| 9 |
from .tools import InfluencerRetrievalTool
|
| 10 |
import re
|
| 11 |
-
import logging
|
| 12 |
-
app_logger = logging.getLogger("app_logger")
|
| 13 |
-
error_logger = logging.getLogger("error_logger")
|
| 14 |
|
| 15 |
class ImageCaptioner:
|
| 16 |
def __init__(self, api_key=os.environ.get('GROQ_API_KEY')):
|
|
@@ -48,13 +45,9 @@ class AnalyticsViewer:
|
|
| 48 |
self.business_details = business_details
|
| 49 |
|
| 50 |
def show_analytics(self):
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
return tool_response
|
| 55 |
-
except Exception as e:
|
| 56 |
-
error_logger.error(f'Error while showing analytics: {e}')
|
| 57 |
-
return e
|
| 58 |
|
| 59 |
class ResponseBlockExtractor:
|
| 60 |
def __init__(self, response):
|
|
|
|
| 8 |
from langchain_core.messages import FunctionMessage , AIMessage
|
| 9 |
from .tools import InfluencerRetrievalTool
|
| 10 |
import re
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
class ImageCaptioner:
|
| 13 |
def __init__(self, api_key=os.environ.get('GROQ_API_KEY')):
|
|
|
|
| 45 |
self.business_details = business_details
|
| 46 |
|
| 47 |
def show_analytics(self):
|
| 48 |
+
tool_response = InfluencerRetrievalTool().retrieve_for_analytics(str(self.business_details))
|
| 49 |
+
return tool_response
|
| 50 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
class ResponseBlockExtractor:
|
| 53 |
def __init__(self, response):
|
src/genai/utils/__pycache__/data_loader.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/utils/__pycache__/data_loader.cpython-312.pyc and b/src/genai/utils/__pycache__/data_loader.cpython-312.pyc differ
|
|
|
src/genai/utils/__pycache__/models_loader.cpython-312.pyc
CHANGED
|
Binary files a/src/genai/utils/__pycache__/models_loader.cpython-312.pyc and b/src/genai/utils/__pycache__/models_loader.cpython-312.pyc differ
|
|
|
src/genai/utils/data_loader.py
CHANGED
|
@@ -1,11 +1,47 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
| 3 |
from datasets import load_dataset
|
| 4 |
-
# dataset = load_dataset("subashdvorak/tiktok-formatted-story-v2", revision="embedded")
|
| 5 |
-
# data = dataset['train'].add_faiss_index('embeddings')
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
|
|
|
| 1 |
+
import ast
|
| 2 |
+
import faiss
|
| 3 |
+
import logging
|
| 4 |
+
import numpy as np
|
| 5 |
+
import pandas as pd
|
| 6 |
from datasets import load_dataset
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
app_logger = logging.getLogger("app_logger")
|
| 9 |
+
error_logger = logging.getLogger("error_logger")
|
| 10 |
+
|
| 11 |
+
class DataLoader:
|
| 12 |
+
def __init__(self):
|
| 13 |
+
self.caption_dataset = load_dataset("DvorakInnovationAI/rt-genai-dataset-v1", revision="openai-embeddings")
|
| 14 |
+
self.ideas_dataset = load_dataset("DvorakInnovationAI/rt-genai-imdb-ideas-v1", revision='openai-embeddings')
|
| 15 |
+
|
| 16 |
+
def _load_vector_index(self , dataset):
|
| 17 |
+
df = dataset["train"].to_pandas()
|
| 18 |
+
df['embeddings'] = df['embeddings'].apply(lambda x: ast.literal_eval(x) if isinstance(x, str) else x)
|
| 19 |
+
embeddings = np.vstack(df['embeddings'].values).astype('float32')
|
| 20 |
+
faiss.normalize_L2(embeddings)
|
| 21 |
+
index = faiss.IndexFlatIP(embeddings.shape[1])
|
| 22 |
+
index.add(embeddings)
|
| 23 |
+
return df, embeddings, index
|
| 24 |
+
|
| 25 |
+
def load_caption(self):
|
| 26 |
+
return self._load_vector_index(self.caption_dataset)
|
| 27 |
+
|
| 28 |
+
def load_imdb_ideas(self):
|
| 29 |
+
return self._load_vector_index(self.ideas_dataset)
|
| 30 |
+
|
| 31 |
+
try:
|
| 32 |
+
data_loader = DataLoader()
|
| 33 |
+
app_logger.info('Dataset loaded from Hugging Face.')
|
| 34 |
+
|
| 35 |
+
except Exception as e:
|
| 36 |
+
error_logger.error('Unable to load dataset:', e)
|
| 37 |
+
raise
|
| 38 |
+
|
| 39 |
+
try:
|
| 40 |
+
caption_df, caption_embeddings, caption_index = data_loader.load_caption()
|
| 41 |
+
ideas_df , ideas_embeddings , ideas_index = data_loader.load_imdb_ideas()
|
| 42 |
+
app_logger.info('Loaded the embeddings.')
|
| 43 |
+
|
| 44 |
+
except Exception as e:
|
| 45 |
+
error_logger.error('Unable to load the embeddings:', e)
|
| 46 |
|
| 47 |
|
src/genai/utils/load_embeddings.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
-
import ast
|
| 3 |
-
import faiss
|
| 4 |
-
import pandas as pd
|
| 5 |
-
from datasets import load_dataset
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def load_caption_index():
|
| 9 |
-
dataset = load_dataset("DvorakInnovationAI/rt-genai-dataset-v1", revision="openai-embeddings")
|
| 10 |
-
df = dataset["train"]
|
| 11 |
-
df= df.to_pandas()
|
| 12 |
-
df['embeddings'] = df['embeddings'].apply(lambda x: ast.literal_eval(x) if isinstance(x, str) else x)
|
| 13 |
-
embeddings = np.vstack(df['embeddings'].values).astype('float32')
|
| 14 |
-
faiss.normalize_L2(embeddings)
|
| 15 |
-
index = faiss.IndexFlatIP(embeddings.shape[1])
|
| 16 |
-
index.add(embeddings)
|
| 17 |
-
return df, embeddings, index
|
| 18 |
-
|
| 19 |
-
def load_imdb_ideas_index():
|
| 20 |
-
dataset = load_dataset("DvorakInnovationAI/rt-genai-imdb-ideas-v1", revision='openai-embeddings')
|
| 21 |
-
df = dataset['train']
|
| 22 |
-
df= df.to_pandas()
|
| 23 |
-
df['embeddings'] = df['embeddings'].apply(lambda x: ast.literal_eval(x) if isinstance(x,str) else x)
|
| 24 |
-
embeddings = np.vstack(df['embeddings'].values).astype('float32')
|
| 25 |
-
faiss.normalize_L2(embeddings)
|
| 26 |
-
index = faiss.IndexFlatIP(embeddings.shape[1])
|
| 27 |
-
index.add(embeddings)
|
| 28 |
-
return df , embeddings , index
|
| 29 |
-
|
| 30 |
-
print('Loading Embeddings...........')
|
| 31 |
-
caption_df, caption_embeddings, caption_index = load_caption_index()
|
| 32 |
-
ideas_df , ideas_embeddings , ideas_index = load_imdb_ideas_index()
|
| 33 |
-
print('Embeddings Loaded.................')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/genai/utils/models_loader.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
import requests
|
| 3 |
import numpy as np
|
| 4 |
from langchain_groq import ChatGroq
|
| 5 |
from langchain_openai import ChatOpenAI
|
|
@@ -8,57 +7,34 @@ from langchain_anthropic import ChatAnthropic
|
|
| 8 |
from langchain_openai import OpenAIEmbeddings
|
| 9 |
from huggingface_hub import login
|
| 10 |
from dotenv import load_dotenv
|
|
|
|
| 11 |
load_dotenv()
|
| 12 |
os.environ['HUGGINGFACEHUB_ACCESS_TOKEN']=os.getenv('HUGGINGFACEHUB_ACCESS_TOKEN')
|
| 13 |
login(os.environ['HUGGINGFACEHUB_ACCESS_TOKEN'])
|
| 14 |
-
|
| 15 |
|
| 16 |
embedding_model = OpenAIEmbeddings(model="text-embedding-3-small", dimensions=1536)
|
| 17 |
llm_anthropic = ChatAnthropic(model='claude-3-5-sonnet-20241022', temperature=0.7, max_tokens=500)
|
| 18 |
llm_gemini = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
temperature=0.7,
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
llm_gpt = ChatOpenAI(
|
| 26 |
-
model="gpt-4o-mini",
|
| 27 |
-
temperature=0.3,
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
class HFEmbeddingAPI:
|
| 32 |
-
def __init__(self, api_url, token):
|
| 33 |
-
self.api_url = api_url
|
| 34 |
-
self.headers = {
|
| 35 |
-
"Authorization": f"Bearer {os.environ.get('HUGGINGFACEHUB_ACCESS_TOKEN')}",
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
def encode(self, texts):
|
| 39 |
-
if isinstance(texts, str):
|
| 40 |
-
texts = [texts]
|
| 41 |
-
response = requests.post(
|
| 42 |
-
self.api_url,
|
| 43 |
-
headers=self.headers,
|
| 44 |
-
json={"inputs": texts}
|
| 45 |
-
)
|
| 46 |
-
response.raise_for_status()
|
| 47 |
-
embeddings=response.json()
|
| 48 |
-
return np.array(embeddings[0]) if len(embeddings) == 1 else np.array(embeddings)
|
| 49 |
-
|
| 50 |
-
# Instantiate your API-backed "SentenceTransformer"
|
| 51 |
-
ST = HFEmbeddingAPI(
|
| 52 |
-
api_url="https://router.huggingface.co/hf-inference/models/mixedbread-ai/mxbai-embed-large-v1/pipeline/feature-extraction",
|
| 53 |
-
token=os.environ.get('HUGGINGFACEHUB_ACCESS_TOKEN')
|
| 54 |
-
)
|
| 55 |
|
| 56 |
improver_llm = llm_anthropic
|
| 57 |
ideator_llm = llm_anthropic
|
| 58 |
critic_llm = llm_anthropic
|
| 59 |
-
validator_llm = llm_anthropic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
captioning_model = "meta-llama/llama-4-scout-17b-16e-instruct"
|
| 62 |
-
image_generation_model = "black-forest-labs/FLUX.1-schnell"
|
| 63 |
|
| 64 |
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
from langchain_groq import ChatGroq
|
| 4 |
from langchain_openai import ChatOpenAI
|
|
|
|
| 7 |
from langchain_openai import OpenAIEmbeddings
|
| 8 |
from huggingface_hub import login
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
+
|
| 11 |
load_dotenv()
|
| 12 |
os.environ['HUGGINGFACEHUB_ACCESS_TOKEN']=os.getenv('HUGGINGFACEHUB_ACCESS_TOKEN')
|
| 13 |
login(os.environ['HUGGINGFACEHUB_ACCESS_TOKEN'])
|
| 14 |
+
|
| 15 |
|
| 16 |
embedding_model = OpenAIEmbeddings(model="text-embedding-3-small", dimensions=1536)
|
| 17 |
llm_anthropic = ChatAnthropic(model='claude-3-5-sonnet-20241022', temperature=0.7, max_tokens=500)
|
| 18 |
llm_gemini = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
|
| 19 |
+
llm_groq = ChatGroq(model="llama-3.1-8b-instant",temperature=0.7)
|
| 20 |
+
llm_gpt = ChatOpenAI(model="gpt-4o-mini",temperature=0.3)
|
| 21 |
|
| 22 |
+
captioning_model = "meta-llama/llama-4-scout-17b-16e-instruct"
|
| 23 |
+
image_generation_model = "black-forest-labs/FLUX.1-schnell"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
improver_llm = llm_anthropic
|
| 26 |
ideator_llm = llm_anthropic
|
| 27 |
critic_llm = llm_anthropic
|
| 28 |
+
validator_llm = llm_anthropic
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
|
|
|
|
|
|
|
| 39 |
|
| 40 |
|