tharu280's picture
updated the bio issue
dd32905
import google.generativeai as genai
from .database import query_sqlite
# --- Python Implementation of Tools ---
def get_projects(): return query_sqlite("projects")
def get_skills(): return query_sqlite("skills")
def get_certifications(): return query_sqlite("certifications")
def get_articles(): return query_sqlite("articles")
def get_videos(): return query_sqlite("videos")
def get_research(): return query_sqlite("research")
def get_content():
return {
"articles": query_sqlite("articles"),
"videos": query_sqlite("videos"),
"research": query_sqlite("research")
}
def get_resume():
"""Returns metadata for the resume file."""
return {
"file_path": "images/resume.pdf",
"preview_image": "images/resume_preview.png",
"title": "Tharushika Abedheera - CV",
"description": "Machine Learning Engineer & AI Specialist"
}
# Mapping for execution
TOOL_FUNCTIONS = {
"get_projects": get_projects,
"get_skills": get_skills,
"get_certifications": get_certifications,
"get_articles": get_articles,
"get_videos": get_videos,
"get_research": get_research,
"get_content": get_content,
"get_resume": get_resume
}
# Mapping for Frontend Action Codes
TOOL_CODE_MAP = {
"get_projects": "show_projects",
"get_skills": "show_skills",
"get_certifications": "show_certifications",
"get_articles": "show_articles",
"get_videos": "show_videos",
"get_research": "show_research",
"get_content": "show_content",
"get_resume": "show_resume"
}
# --- Gemini Schema Definitions ---
projects_tool = genai.protos.FunctionDeclaration(
name="get_projects",
# STRICTER DESCRIPTION:
description="ONLY use this when the user explicitly asks to SEE a list of projects, portfolio items, or coding work. Do NOT use for general questions.",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
skills_tool = genai.protos.FunctionDeclaration(
name="get_skills",
# STRICTER DESCRIPTION:
description="ONLY use this when the user explicitly asks to SEE technical skills, languages, or the tech stack. Do NOT use for general questions.",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
certifications_tool = genai.protos.FunctionDeclaration(
name="get_certifications",
description="Retrieve certifications.",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
articles_tool = genai.protos.FunctionDeclaration(
name="get_articles",
description="Retrieve articles.",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
videos_tool = genai.protos.FunctionDeclaration(
name="get_videos",
description="Retrieve videos.",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
research_tool = genai.protos.FunctionDeclaration(
name="get_research",
description="Retrieve research.",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
content_tool = genai.protos.FunctionDeclaration(
name="get_content",
description="Retrieve ALL content (articles, videos, research).",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
resume_tool = genai.protos.FunctionDeclaration(
name="get_resume",
description="Retrieve Tharushika's official resume/CV. Use this when the user asks to see, download, or get a copy of the resume.",
parameters=genai.protos.Schema(
type=genai.protos.Type.OBJECT, properties={}, required=[])
)
# List to pass to the model
ALL_TOOLS_LIST = [
projects_tool, skills_tool, certifications_tool,
articles_tool, videos_tool, research_tool, content_tool,
resume_tool
]