|
|
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="KGraph-MCP: An intelligent orchestration layer for MCP servers using Knowledge Graphs and AI Agents for autonomous tool discovery, planning, and execution."><meta name=author content="KGraph-MCP Development Team"><link href=https://basalganglia.github.io/kgraph-mcp-hackathon/progress/sprint2_plan/ rel=canonical><link rel=icon href=../../assets/favicon.png><meta name=generator content="mkdocs-1.6.1, mkdocs-material-9.6.14"><title>Sprint 2 (MVP 1): Real Embeddings & Semantic Search Logic - KGraph-MCP - The Self-Orchestrating Tool Network</title><link rel=stylesheet href=../../assets/stylesheets/main.342714a4.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.06af60db.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style><link rel=stylesheet href=../../assets/_mkdocstrings.css><link rel=stylesheet href=../../overrides/stylesheets/extra.css><script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script><script id=__analytics>function __md_analytics(){function e(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],e("js",new Date),e("config",""),document.addEventListener("DOMContentLoaded",(function(){document.forms.search&&document.forms.search.query.addEventListener("blur",(function(){this.value&&e("event","search",{search_term:this.value})}));document$.subscribe((function(){var t=document.forms.feedback;if(void 0!==t)for(var a of t.querySelectorAll("[type=submit]"))a.addEventListener("click",(function(a){a.preventDefault();var n=document.location.pathname,d=this.getAttribute("data-md-value");e("event","feedback",{page:n,data:d}),t.firstElementChild.disabled=!0;var r=t.querySelector(".md-feedback__note [data-md-value='"+d+"']");r&&(r.hidden=!1)})),t.hidden=!1})),location$.subscribe((function(t){e("config","",{page_path:t.pathname})}))}));var t=document.createElement("script");t.async=!0,t.src="https://www.googletagmanager.com/gtag/js?id=",document.getElementById("__analytics").insertAdjacentElement("afterEnd",t)}</script><script>if("undefined"!=typeof __md_analytics){var consent=__md_get("__consent");consent&&consent.analytics&&__md_analytics()}</script> <link href="../../assets/stylesheets/glightbox.min.css" rel="stylesheet"/><style> |
|
|
html.glightbox-open { overflow: initial; height: 100%; } |
|
|
.gslide-title { margin-top: 0px; user-select: text; } |
|
|
.gslide-desc { color: #666; user-select: text; } |
|
|
.gslide-image img { background: white; } |
|
|
.gscrollbar-fixer { padding-right: 15px; } |
|
|
.gdesc-inner { font-size: 0.75rem; } |
|
|
body[data-md-color-scheme="slate"] .gdesc-inner { background: var(--md-default-bg-color);} |
|
|
body[data-md-color-scheme="slate"] .gslide-title { color: var(--md-default-fg-color);} |
|
|
body[data-md-color-scheme="slate"] .gslide-desc { color: var(--md-default-fg-color);}</style> <script src="../../assets/javascripts/glightbox.min.js"></script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#sprint-2-mvp-1-real-embeddings-semantic-search-logic class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <div data-md-color-scheme=default data-md-component=outdated hidden> </div> <header class="md-header md-header--shadow md-header--lifted" data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../.. title="KGraph-MCP - The Self-Orchestrating Tool Network" class="md-header__button md-logo" aria-label="KGraph-MCP - The Self-Orchestrating Tool Network" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M19.5 17c-.14 0-.26 0-.39.04L17.5 13.8c.45-.45.75-1.09.75-1.8a2.5 2.5 0 0 0-2.5-2.5c-.14 0-.25 0-.4.04L13.74 6.3c.47-.46.76-1.09.76-1.8a2.5 2.5 0 0 0-5 0c0 .7.29 1.34.76 1.79L8.65 9.54c-.15-.04-.26-.04-.4-.04a2.5 2.5 0 0 0-2.5 2.5c0 .71.29 1.34.75 1.79l-1.61 3.25C4.76 17 4.64 17 4.5 17a2.5 2.5 0 0 0 0 5A2.5 2.5 0 0 0 7 19.5c0-.7-.29-1.34-.76-1.79l1.62-3.25c.14.04.26.04.39.04s.25 0 .38-.04l1.63 3.25c-.47.45-.76 1.09-.76 1.79a2.5 2.5 0 0 0 5 0A2.5 2.5 0 0 0 12 17c-.13 0-.26 0-.39.04L10 13.8c.45-.45.75-1.09.75-1.8 0-.7-.29-1.33-.75-1.79l1.61-3.25c.13.04.26.04.39.04s.26 0 .39-.04L14 10.21a2.5 2.5 0 0 0 1.75 4.29c.13 0 .25 0 .38-.04l1.63 3.25c-.47.45-.76 1.09-.76 1.79a2.5 2.5 0 0 0 5 0 2.5 2.5 0 0 0-2.5-2.5m-15 3.5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1m8.5-1c0 .55-.45 1-1 1s-1-.45-1-1 .45-1 1-1 1 .45 1 1M7.25 12c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1M11 4.5c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1m3.75 7.5c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1m4.75 8.5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> KGraph-MCP - The Self-Orchestrating Tool Network </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Sprint 2 (MVP 1): Real Embeddings & Semantic Search Logic </span> </div> </div> </div> <form class=md-header__option data-md-component=palette> <input class=md-option data-md-color-media=(prefers-color-scheme) data-md-color-scheme=default data-md-color-primary=indigo data-md-color-accent=indigo aria-label="Switch to light mode" type=radio name=__palette id=__palette_0> <label class="md-header__button md-icon" title="Switch to light mode" for=__palette_1 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="m14.3 16-.7-2h-3.2l-.7 2H7.8L11 7h2l3.2 9zM20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zm-9.15 3.96h2.3L12 9z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme=default data-md-color-primary=deep-purple data-md-color-accent=purple aria-label="Switch to dark mode" type=radio name=__palette id=__palette_1> <label class="md-header__button md-icon" title="Switch to dark mode" for=__palette_2 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> <input class=md-option data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme=slate data-md-color-primary=deep-purple data-md-color-accent=purple aria-label="Switch to system preference" type=radio name=__palette id=__palette_2> <label class="md-header__button md-icon" title="Switch to system preference" for=__palette_0 hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg> </label> </form> <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> </label> <div class=md-search data-md-component=search role=dialog> <label class=md-search__overlay for=__search></label> <div class=md-search__inner role=search> <form class=md-search__form name=search> <input type=text class=md-search__input name=query aria-label=Search placeholder=Search autocapitalize=off autocorrect=off autocomplete=off spellcheck=false data-md-component=search-query required> <label class="md-search__icon md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg> </label> <nav class=md-search__options aria-label=Search> <a href=javascript:void(0) class="md-search__icon md-icon" title=Share aria-label=Share data-clipboard data-clipboard-text data-md-component=search-share tabindex=-1> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91s2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08"/></svg> </a> <button type=reset class="md-search__icon md-icon" title=Clear aria-label=Clear tabindex=-1> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg> </button> </nav> <div class=md-search__suggest data-md-component=search-suggest></div> </form> <div class=md-search__output> <div class=md-search__scrollwrap tabindex=0 data-md-scrollfix> <div class=md-search-result data-md-component=search-result> <div class=md-search-result__meta> Initializing search </div> <ol class=md-search-result__list role=presentation></ol> </div> </div> </div> </div> </div> <div class=md-header__source> <a href=https://github.com/BasalGanglia/kgraph-mcp-hackathon title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </div> <div class=md-source__repository> BasalGanglia/kgraph-mcp-hackathon </div> </a> </div> </nav> <nav class=md-tabs aria-label=Tabs data-md-component=tabs> <div class=md-grid> <ul class=md-tabs__list> <li class=md-tabs__item> <a href=../.. class=md-tabs__link> Home </a> </li> <li class=md-tabs__item> <a href=../../user-guide/installation/ class=md-tabs__link> Documentation </a> </li> <li class=md-tabs__item> <a href=../../architecture/overview/ class=md-tabs__link> Architecture </a> </li> <li class=md-tabs__item> <a href=../../mvp/mvp1/ class=md-tabs__link> Project Management </a> </li> <li class=md-tabs__item> <a href=../ class=md-tabs__link> Progress Reports </a> </li> <li class=md-tabs__item> <a href=../../workflow/development/ class=md-tabs__link> Tools & Workflow </a> </li> <li class=md-tabs__item> <a href=../../resources/glossary/ class=md-tabs__link> Resources </a> </li> </ul> </div> </nav> </header> <div class=md-container data-md-component=container> <main class=md-main data-md-component=main> <div class="md-main__inner md-grid"> <div class="md-sidebar md-sidebar--primary" data-md-component=sidebar data-md-type=navigation> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--primary md-nav--lifted" aria-label=Navigation data-md-level=0> <label class=md-nav__title for=__drawer> <a href=../.. title="KGraph-MCP - The Self-Orchestrating Tool Network" class="md-nav__button md-logo" aria-label="KGraph-MCP - The Self-Orchestrating Tool Network" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M19.5 17c-.14 0-.26 0-.39.04L17.5 13.8c.45-.45.75-1.09.75-1.8a2.5 2.5 0 0 0-2.5-2.5c-.14 0-.25 0-.4.04L13.74 6.3c.47-.46.76-1.09.76-1.8a2.5 2.5 0 0 0-5 0c0 .7.29 1.34.76 1.79L8.65 9.54c-.15-.04-.26-.04-.4-.04a2.5 2.5 0 0 0-2.5 2.5c0 .71.29 1.34.75 1.79l-1.61 3.25C4.76 17 4.64 17 4.5 17a2.5 2.5 0 0 0 0 5A2.5 2.5 0 0 0 7 19.5c0-.7-.29-1.34-.76-1.79l1.62-3.25c.14.04.26.04.39.04s.25 0 .38-.04l1.63 3.25c-.47.45-.76 1.09-.76 1.79a2.5 2.5 0 0 0 5 0A2.5 2.5 0 0 0 12 17c-.13 0-.26 0-.39.04L10 13.8c.45-.45.75-1.09.75-1.8 0-.7-.29-1.33-.75-1.79l1.61-3.25c.13.04.26.04.39.04s.26 0 .39-.04L14 10.21a2.5 2.5 0 0 0 1.75 4.29c.13 0 .25 0 .38-.04l1.63 3.25c-.47.45-.76 1.09-.76 1.79a2.5 2.5 0 0 0 5 0 2.5 2.5 0 0 0-2.5-2.5m-15 3.5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1m8.5-1c0 .55-.45 1-1 1s-1-.45-1-1 .45-1 1-1 1 .45 1 1M7.25 12c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1M11 4.5c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1m3.75 7.5c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1m4.75 8.5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1"/></svg> </a> KGraph-MCP - The Self-Orchestrating Tool Network </label> <div class=md-nav__source> <a href=https://github.com/BasalGanglia/kgraph-mcp-hackathon title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </div> <div class=md-source__repository> BasalGanglia/kgraph-mcp-hackathon </div> </a> </div> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> <a href=../.. class=md-nav__link> <span class=md-ellipsis> Home </span> <span class="md-nav__icon md-icon"></span> </a> </li> <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> <a href=../../user-guide/installation/ class=md-nav__link> <span class=md-ellipsis> Documentation </span> <span class="md-nav__icon md-icon"></span> </a> </li> <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> <a href=../../architecture/overview/ class=md-nav__link> <span class=md-ellipsis> Architecture </span> <span class="md-nav__icon md-icon"></span> </a> </li> <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> <a href=../../mvp/mvp1/ class=md-nav__link> <span class=md-ellipsis> Project Management </span> <span class="md-nav__icon md-icon"></span> </a> </li> <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> <a href=../ class=md-nav__link> <span class=md-ellipsis> Progress Reports </span> <span class="md-nav__icon md-icon"></span> </a> </li> <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> <a href=../../workflow/development/ class=md-nav__link> <span class=md-ellipsis> Tools & Workflow </span> <span class="md-nav__icon md-icon"></span> </a> </li> <li class="md-nav__item md-nav__item--pruned md-nav__item--nested"> <a href=../../resources/glossary/ class=md-nav__link> <span class=md-ellipsis> Resources </span> <span class="md-nav__icon md-icon"></span> </a> </li> </ul> </nav> </div> </div> </div> <div class="md-sidebar md-sidebar--secondary" data-md-component=sidebar data-md-type=toc> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--secondary" aria-label="On this page"> <label class=md-nav__title for=__toc> <span class="md-nav__icon md-icon"></span> On this page </label> <ul class=md-nav__list data-md-component=toc data-md-scrollfix> <li class=md-nav__item> <a href=#sprint-overview class=md-nav__link> <span class=md-ellipsis> Sprint Overview </span> </a> </li> <li class=md-nav__item> <a href=#task-list class=md-nav__link> <span class=md-ellipsis> Task List </span> </a> <nav class=md-nav aria-label="Task List"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#task-21-implement-live-llm-api-call-in-embeddingservice class=md-nav__link> <span class=md-ellipsis> Task 2.1: Implement Live LLM API Call in EmbeddingService </span> </a> </li> <li class=md-nav__item> <a href=#task-22-implement-real-vector-index-building-in-inmemorykg class=md-nav__link> <span class=md-ellipsis> Task 2.2: Implement Real Vector Index Building in InMemoryKG </span> </a> </li> <li class=md-nav__item> <a href=#task-23-implement-cosine-similarity-search-in-inmemorykg class=md-nav__link> <span class=md-ellipsis> Task 2.3: Implement Cosine Similarity Search in InMemoryKG </span> </a> </li> <li class=md-nav__item> <a href=#task-24-update-dependencies-run-all-checks class=md-nav__link> <span class=md-ellipsis> Task 2.4: Update Dependencies & Run All Checks </span> </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#end-of-sprint-2-review class=md-nav__link> <span class=md-ellipsis> End of Sprint 2 Review </span> </a> </li> <li class=md-nav__item> <a href=#implementation-guidance class=md-nav__link> <span class=md-ellipsis> Implementation Guidance </span> </a> <nav class=md-nav aria-label="Implementation Guidance"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#task-21-implementation-details class=md-nav__link> <span class=md-ellipsis> Task 2.1 Implementation Details </span> </a> </li> <li class=md-nav__item> <a href=#task-22-implementation-details class=md-nav__link> <span class=md-ellipsis> Task 2.2 Implementation Details </span> </a> </li> <li class=md-nav__item> <a href=#task-23-implementation-details class=md-nav__link> <span class=md-ellipsis> Task 2.3 Implementation Details </span> </a> </li> </ul> </nav> </li> </ul> </nav> </div> </div> </div> <div class=md-content data-md-component=content> <article class="md-content__inner md-typeset"> <a href=https://github.com/BasalGanglia/kgraph-mcp-hackathon/edit/main/docs/progress/sprint2_plan.md title="Edit this page" class="md-content__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M10 20H6V4h7v5h5v3.1l2-2V8l-6-6H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h4zm10.2-7c.1 0 .3.1.4.2l1.3 1.3c.2.2.2.6 0 .8l-1 1-2.1-2.1 1-1c.1-.1.2-.2.4-.2m0 3.9L14.1 23H12v-2.1l6.1-6.1z"/></svg> </a> <a href=https://github.com/BasalGanglia/kgraph-mcp-hackathon/raw/main/docs/progress/sprint2_plan.md title="View source of this page" class="md-content__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M17 18c.56 0 1 .44 1 1s-.44 1-1 1-1-.44-1-1 .44-1 1-1m0-3c-2.73 0-5.06 1.66-6 4 .94 2.34 3.27 4 6 4s5.06-1.66 6-4c-.94-2.34-3.27-4-6-4m0 6.5a2.5 2.5 0 0 1-2.5-2.5 2.5 2.5 0 0 1 2.5-2.5 2.5 2.5 0 0 1 2.5 2.5 2.5 2.5 0 0 1-2.5 2.5M9.27 20H6V4h7v5h5v4.07c.7.08 1.36.25 2 .49V8l-6-6H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h4.5a8.2 8.2 0 0 1-1.23-2"/></svg> </a> <h1 id=sprint-2-mvp-1-real-embeddings-semantic-search-logic>Sprint 2 (MVP 1): Real Embeddings & Semantic Search Logic<a class=headerlink href=#sprint-2-mvp-1-real-embeddings-semantic-search-logic title="Permanent link">¶</a></h1> <h2 id=sprint-overview>Sprint Overview<a class=headerlink href=#sprint-overview title="Permanent link">¶</a></h2> <ul> <li><strong>Goal:</strong> Integrate actual LLM calls for generating embeddings, build the vector index within the <code>InMemoryKG</code>, and implement the core semantic search functionality. <em>Still no UI, focus on backend KG capabilities.</em></li> <li><strong>Duration:</strong> Estimated 3-5 hours (flexible within Hackathon Day 1, following Sprint 1).</li> <li><strong>Core Primitives Focused On:</strong> Tool (its description being embedded and searched).</li> <li><strong>Key Artifacts by End of Sprint:</strong></li> <li><code>kg_services/embedder.py</code>: <code>EmbeddingService.get_embedding</code> method now makes live API calls.</li> <li><code>kg_services/knowledge_graph.py</code>: <code>InMemoryKG.build_vector_index</code> now uses real embeddings, and <code>InMemoryKG.find_similar_tools</code> performs actual cosine similarity search.</li> <li>Updated unit tests, potentially including tests that mock the LLM API calls.</li> <li>Updated <code>requirements.txt</code> (if new LLM client libraries were added) and <code>requirements.lock</code>.</li> <li>All code linted, formatted, type-checked, and passing CI.</li> </ul> <h2 id=task-list>Task List<a class=headerlink href=#task-list title="Permanent link">¶</a></h2> <h3 id=task-21-implement-live-llm-api-call-in-embeddingservice>Task 2.1: Implement Live LLM API Call in <code>EmbeddingService</code><a class=headerlink href=#task-21-implement-live-llm-api-call-in-embeddingservice title="Permanent link">¶</a></h3> <ul> <li><strong>Status:</strong> Todo</li> <li><strong>Parent MVP:</strong> MVP 1</li> <li><strong>Parent Sprint (MVP 1):</strong> Sprint 2</li> <li><strong>Description:</strong> Modify <code>kg_services/embedder.py</code>'s <code>EmbeddingService.get_embedding</code> method to make actual API calls to your chosen LLM provider (OpenAI, Anthropic, or Azure OpenAI) to generate text embeddings.</li> <li>Ensure API keys are handled securely via environment variables (e.g., loaded using <code>python-dotenv</code> for local dev, and set as secrets in GitHub Actions/Hugging Face Spaces).</li> <li>Add necessary LLM client libraries (e.g., <code>openai</code>, <code>anthropic</code>) to <code>requirements.txt</code> if not already there.</li> <li><strong>Acceptance Criteria:</strong></li> <li><code>get_embedding</code> method successfully calls the chosen LLM API and returns a valid embedding vector (list of floats).</li> <li>Handles potential API errors gracefully (e.g., logs an error and returns <code>None</code> or raises a custom exception).</li> <li><code>requirements.txt</code> updated with LLM client library.</li> <li>Unit tests (with API mocking) pass.</li> <li><strong>TDD Approach:</strong> In <code>tests/kg_services/test_embedder.py</code>, refactor/add tests:</li> <li><code>test_get_embedding_live_success</code>: Mocks the LLM client's <code>create</code> (or equivalent) method to return a sample successful embedding response. Verifies the method processes this correctly.</li> <li><code>test_get_embedding_api_error</code>: Mocks the LLM client to raise an API error. Verifies <code>get_embedding</code> handles this gracefully.</li> </ul> <h3 id=task-22-implement-real-vector-index-building-in-inmemorykg>Task 2.2: Implement Real Vector Index Building in <code>InMemoryKG</code><a class=headerlink href=#task-22-implement-real-vector-index-building-in-inmemorykg title="Permanent link">¶</a></h3> <ul> <li><strong>Status:</strong> Todo</li> <li><strong>Parent MVP:</strong> MVP 1</li> <li><strong>Parent Sprint (MVP 1):</strong> Sprint 2</li> <li><strong>Description:</strong> Modify <code>kg_services/knowledge_graph.py</code>'s <code>InMemoryKG.build_vector_index</code> method.</li> <li>It should now iterate through the loaded <code>self.tools</code>.</li> <li>For each tool, construct a descriptive text string (e.g., from <code>name</code>, <code>description</code>, <code>tags</code>).</li> <li>Use the (now live) <code>EmbeddingService</code> instance to get a real embedding for this text.</li> <li>Store these real embeddings in <code>self.tool_embeddings</code> and corresponding <code>tool_id</code>s in <code>self.tool_ids_for_vectors</code>.</li> <li>Handle cases where <code>get_embedding</code> might return <code>None</code> (e.g., skip that tool or use a zero vector with a warning).</li> <li><strong>Acceptance Criteria:</strong></li> <li><code>build_vector_index</code> populates <code>self.tool_embeddings</code> with actual vectors from the LLM API.</li> <li>Correctly associates embeddings with <code>tool_id</code>s.</li> <li>Handles potential embedding failures for individual tools.</li> <li>Unit tests pass.</li> <li><strong>TDD Approach:</strong> In <code>tests/kg_services/test_knowledge_graph.py</code>:</li> <li><code>test_build_vector_index_with_real_embeddings</code>:<ul> <li>Needs a mock <code>EmbeddingService</code> that returns predictable (but distinct) vectors for different inputs.</li> <li>Load sample tools into <code>InMemoryKG</code>.</li> <li>Call <code>build_vector_index</code> with the mock embedder.</li> <li>Assert that <code>self.tool_embeddings</code> contains the expected number of vectors and that they match what the mock embedder would have returned.</li> <li>Assert <code>self.tool_ids_for_vectors</code> is populated correctly.</li> </ul> </li> <li><code>test_build_vector_index_handles_embedding_failure</code>:<ul> <li>Mock <code>EmbeddingService.get_embedding</code> to return <code>None</code> for one of the tools.</li> <li>Assert that the index is built for other tools and the failed one is handled (e.g., skipped or has a zero vector).</li> </ul> </li> </ul> <h3 id=task-23-implement-cosine-similarity-search-in-inmemorykg>Task 2.3: Implement Cosine Similarity Search in <code>InMemoryKG</code><a class=headerlink href=#task-23-implement-cosine-similarity-search-in-inmemorykg title="Permanent link">¶</a></h3> <ul> <li><strong>Status:</strong> Todo</li> <li><strong>Parent MVP:</strong> MVP 1</li> <li><strong>Parent Sprint (MVP 1):</strong> Sprint 2</li> <li><strong>Description:</strong> Modify <code>kg_services/knowledge_graph.py</code>'s <code>InMemoryKG.find_similar_tools</code> method.</li> <li>It should now use <code>numpy</code> to perform cosine similarity calculations between the input <code>query_embedding</code> and each of the real embeddings stored in <code>self.tool_embeddings</code>.</li> <li>Return the <code>tool_id</code>s of the <code>top_k</code> most similar tools.</li> <li>Ensure <code>numpy</code> is in <code>requirements.txt</code>.</li> <li><strong>Acceptance Criteria:</strong></li> <li><code>find_similar_tools</code> correctly calculates cosine similarities and returns the top_k tool IDs.</li> <li>Handles empty <code>self.tool_embeddings</code> case.</li> <li><code>numpy</code> is listed in <code>requirements.txt</code>.</li> <li>Unit tests pass.</li> <li><strong>TDD Approach:</strong> In <code>tests/kg_services/test_knowledge_graph.py</code>:</li> <li><code>test_cosine_similarity_calculation</code> (if <code>_cosine_similarity</code> is a helper, test it directly with known vectors).</li> <li><code>test_find_similar_tools_with_populated_index</code>:<ul> <li>Manually set <code>kg.tool_embeddings</code> and <code>kg.tool_ids_for_vectors</code> with a few known vectors and IDs.</li> <li>Provide a <code>query_embedding</code> that is known to be most similar to one of them.</li> <li>Call <code>find_similar_tools</code> and assert that the correct <code>tool_id</code>(s) are returned in the correct order.</li> </ul> </li> <li><code>test_find_similar_tools_empty_index</code>: Assert it returns an empty list.</li> <li><code>test_find_similar_tools_top_k_respected</code>: Test with different <code>top_k</code> values.</li> </ul> <h3 id=task-24-update-dependencies-run-all-checks>Task 2.4: Update Dependencies & Run All Checks<a class=headerlink href=#task-24-update-dependencies-run-all-checks title="Permanent link">¶</a></h3> <ul> <li><strong>Status:</strong> Todo</li> <li><strong>Parent MVP:</strong> MVP 1</li> <li><strong>Parent Sprint (MVP 1):</strong> Sprint 2</li> <li><strong>Description:</strong></li> <li>Ensure <code>requirements.txt</code> includes <code>openai</code> (or <code>anthropic</code>) and <code>numpy</code>.</li> <li>Ensure <code>requirements-dev.txt</code> includes <code>python-dotenv</code> and <code>unittest.mock</code> (mock is part of stdlib, but good to be aware if you were using an external mocking lib).</li> <li>Regenerate <code>requirements.lock</code>: <code>uv pip compile requirements.txt requirements-dev.txt --all-extras -o requirements.lock</code>.</li> <li>Run <code>just install</code> (or <code>uv pip sync requirements.lock</code>).</li> <li>Run <code>just lint</code>, <code>just format</code>, <code>just type-check</code>, <code>just test</code>.</li> <li>Commit all changes.</li> <li>Push to GitHub and verify CI pipeline passes. <em>Note: Live API calls in CI for tests are usually avoided. Ensure your tests for <code>EmbeddingService</code> use mocks. The <code>build_vector_index</code> tests should also use a mocked embedder.</em></li> <li><strong>Acceptance Criteria:</strong></li> <li><code>requirements.lock</code> is updated.</li> <li>All <code>just</code> checks pass locally.</li> <li>Code committed and pushed.</li> <li>GitHub Actions CI pipeline passes for the sprint's commits (leveraging mocks for API calls).</li> </ul> <h2 id=end-of-sprint-2-review>End of Sprint 2 Review<a class=headerlink href=#end-of-sprint-2-review title="Permanent link">¶</a></h2> <ul> <li><strong>What's Done:</strong></li> <li><code>EmbeddingService</code> can now generate real embeddings using an LLM API.</li> <li><code>InMemoryKG</code> can build a vector index using these real embeddings.</li> <li><code>InMemoryKG</code> can perform semantic search (cosine similarity) over the indexed tools.</li> <li>Unit tests cover the new functionalities, using mocks for external API calls.</li> <li>The backend logic for tool suggestion based on semantic similarity is complete.</li> <li><strong>What's Next (Sprint 3):</strong></li> <li>Implement the <code>SimplePlannerAgent</code> logic that ties together the <code>EmbeddingService</code> and <code>InMemoryKG</code> to process a user query and suggest tools.</li> <li><strong>Blockers/Issues:</strong></li> <li>API key setup and management (ensure it's smooth for local dev and CI doesn't expose keys).</li> <li>Potential rate limits or costs if generating many embeddings for testing (though for 3-5 tools, this should be minimal).</li> </ul> <h2 id=implementation-guidance>Implementation Guidance<a class=headerlink href=#implementation-guidance title="Permanent link">¶</a></h2> <h3 id=task-21-implementation-details>Task 2.1 Implementation Details<a class=headerlink href=#task-21-implementation-details title="Permanent link">¶</a></h3> <div class="language-python highlight"><pre><span></span><code><span id=__span-0-1><a id=__codelineno-0-1 name=__codelineno-0-1 href=#__codelineno-0-1></a><span class=c1># In kg_services/embedder.py</span> |
|
|
</span><span id=__span-0-2><a id=__codelineno-0-2 name=__codelineno-0-2 href=#__codelineno-0-2></a><span class=c1># Refactor the EmbeddingService class:</span> |
|
|
</span><span id=__span-0-3><a id=__codelineno-0-3 name=__codelineno-0-3 href=#__codelineno-0-3></a><span class=c1># - In __init__:</span> |
|
|
</span><span id=__span-0-4><a id=__codelineno-0-4 name=__codelineno-0-4 href=#__codelineno-0-4></a><span class=c1># - Initialize the appropriate LLM client (OpenAI, AzureOpenAI, or Anthropic).</span> |
|
|
</span><span id=__span-0-5><a id=__codelineno-0-5 name=__codelineno-0-5 href=#__codelineno-0-5></a><span class=c1># - Read API keys and any necessary endpoint/deployment information from environment variables.</span> |
|
|
</span><span id=__span-0-6><a id=__codelineno-0-6 name=__codelineno-0-6 href=#__codelineno-0-6></a><span class=c1># - Add python-dotenv to requirements-dev.txt and load .env in __init__ if a .env file exists.</span> |
|
|
</span><span id=__span-0-7><a id=__codelineno-0-7 name=__codelineno-0-7 href=#__codelineno-0-7></a><span class=c1># - In get_embedding(self, text: str) -> Optional[List[float]]:</span> |
|
|
</span><span id=__span-0-8><a id=__codelineno-0-8 name=__codelineno-0-8 href=#__codelineno-0-8></a><span class=c1># - Replace the placeholder logic with an actual API call to the embedding endpoint.</span> |
|
|
</span><span id=__span-0-9><a id=__codelineno-0-9 name=__codelineno-0-9 href=#__codelineno-0-9></a><span class=c1># - Include error handling (try-except block) for API calls.</span> |
|
|
</span><span id=__span-0-10><a id=__codelineno-0-10 name=__codelineno-0-10 href=#__codelineno-0-10></a><span class=c1># - Ensure the text is preprocessed if necessary.</span> |
|
|
</span></code></pre></div> <h3 id=task-22-implementation-details>Task 2.2 Implementation Details<a class=headerlink href=#task-22-implementation-details title="Permanent link">¶</a></h3> <div class="language-python highlight"><pre><span></span><code><span id=__span-1-1><a id=__codelineno-1-1 name=__codelineno-1-1 href=#__codelineno-1-1></a><span class=c1># In kg_services/knowledge_graph.py</span> |
|
|
</span><span id=__span-1-2><a id=__codelineno-1-2 name=__codelineno-1-2 href=#__codelineno-1-2></a><span class=c1># Refactor InMemoryKG.build_vector_index(self, embedder: EmbeddingService):</span> |
|
|
</span><span id=__span-1-3><a id=__codelineno-1-3 name=__codelineno-1-3 href=#__codelineno-1-3></a><span class=c1># - Clear self.tool_embeddings and self.tool_ids_for_vectors at the start.</span> |
|
|
</span><span id=__span-1-4><a id=__codelineno-1-4 name=__codelineno-1-4 href=#__codelineno-1-4></a><span class=c1># - Iterate through self.tools.items().</span> |
|
|
</span><span id=__span-1-5><a id=__codelineno-1-5 name=__codelineno-1-5 href=#__codelineno-1-5></a><span class=c1># - For each tool_id, tool:</span> |
|
|
</span><span id=__span-1-6><a id=__codelineno-1-6 name=__codelineno-1-6 href=#__codelineno-1-6></a><span class=c1># - Construct a meaningful text: f"{tool.name} - {tool.description} Tags: {', '.join(tool.tags)}"</span> |
|
|
</span><span id=__span-1-7><a id=__codelineno-1-7 name=__codelineno-1-7 href=#__codelineno-1-7></a><span class=c1># - Call embedding = embedder.get_embedding(text_to_embed)</span> |
|
|
</span><span id=__span-1-8><a id=__codelineno-1-8 name=__codelineno-1-8 href=#__codelineno-1-8></a><span class=c1># - If embedding is not None and is valid:</span> |
|
|
</span><span id=__span-1-9><a id=__codelineno-1-9 name=__codelineno-1-9 href=#__codelineno-1-9></a><span class=c1># - Append embedding to self.tool_embeddings</span> |
|
|
</span><span id=__span-1-10><a id=__codelineno-1-10 name=__codelineno-1-10 href=#__codelineno-1-10></a><span class=c1># - Append tool_id to self.tool_ids_for_vectors</span> |
|
|
</span><span id=__span-1-11><a id=__codelineno-1-11 name=__codelineno-1-11 href=#__codelineno-1-11></a><span class=c1># - Else (embedding failed):</span> |
|
|
</span><span id=__span-1-12><a id=__codelineno-1-12 name=__codelineno-1-12 href=#__codelineno-1-12></a><span class=c1># - Log a warning</span> |
|
|
</span><span id=__span-1-13><a id=__codelineno-1-13 name=__codelineno-1-13 href=#__codelineno-1-13></a><span class=c1># - Optionally, append a zero vector and the tool_id</span> |
|
|
</span></code></pre></div> <h3 id=task-23-implementation-details>Task 2.3 Implementation Details<a class=headerlink href=#task-23-implementation-details title="Permanent link">¶</a></h3> <div class="language-python highlight"><pre><span></span><code><span id=__span-2-1><a id=__codelineno-2-1 name=__codelineno-2-1 href=#__codelineno-2-1></a><span class=c1># In kg_services/knowledge_graph.py</span> |
|
|
</span><span id=__span-2-2><a id=__codelineno-2-2 name=__codelineno-2-2 href=#__codelineno-2-2></a><span class=c1># Refactor InMemoryKG._cosine_similarity(self, vec1: List[float], vec2: List[float]) -> float:</span> |
|
|
</span><span id=__span-2-3><a id=__codelineno-2-3 name=__codelineno-2-3 href=#__codelineno-2-3></a><span class=c1># - Ensure inputs vec1 and vec2 are converted to np.array.</span> |
|
|
</span><span id=__span-2-4><a id=__codelineno-2-4 name=__codelineno-2-4 href=#__codelineno-2-4></a><span class=c1># - Perform dot product.</span> |
|
|
</span><span id=__span-2-5><a id=__codelineno-2-5 name=__codelineno-2-5 href=#__codelineno-2-5></a><span class=c1># - Calculate norms.</span> |
|
|
</span><span id=__span-2-6><a id=__codelineno-2-6 name=__codelineno-2-6 href=#__codelineno-2-6></a><span class=c1># - Handle potential division by zero if a norm is zero (return 0.0 similarity).</span> |
|
|
</span><span id=__span-2-7><a id=__codelineno-2-7 name=__codelineno-2-7 href=#__codelineno-2-7></a><span class=c1># - Return the cosine similarity.</span> |
|
|
</span><span id=__span-2-8><a id=__codelineno-2-8 name=__codelineno-2-8 href=#__codelineno-2-8></a><span class=c1># Refactor InMemoryKG.find_similar_tools(self, query_embedding: List[float], top_k: int = 3) -> List[str]:</span> |
|
|
</span><span id=__span-2-9><a id=__codelineno-2-9 name=__codelineno-2-9 href=#__codelineno-2-9></a><span class=c1># - If not self.tool_embeddings or not query_embedding, return [].</span> |
|
|
</span><span id=__span-2-10><a id=__codelineno-2-10 name=__codelineno-2-10 href=#__codelineno-2-10></a><span class=c1># - Calculate similarities: Iterate through self.tool_embeddings, calling _cosine_similarity.</span> |
|
|
</span><span id=__span-2-11><a id=__codelineno-2-11 name=__codelineno-2-11 href=#__codelineno-2-11></a><span class=c1># - Create pairs of (similarity_score, tool_id).</span> |
|
|
</span><span id=__span-2-12><a id=__codelineno-2-12 name=__codelineno-2-12 href=#__codelineno-2-12></a><span class=c1># - Sort these pairs in descending order of similarity score.</span> |
|
|
</span><span id=__span-2-13><a id=__codelineno-2-13 name=__codelineno-2-13 href=#__codelineno-2-13></a><span class=c1># - Return the tool_ids from the top top_k pairs.</span> |
|
|
</span></code></pre></div> <aside class=md-source-file> <span class=md-source-file__fact> <span class=md-icon title="Last update"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg> </span> <span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date" title="June 7, 2025 10:50:33 UTC">June 7, 2025</span> </span> </aside> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type=button class="md-top md-icon" data-md-component=top hidden> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> <div class=md-copyright__highlight> Copyright © 2024 KGraph-MCP Development Team - <a href=#__consent>Change cookie settings</a> </div> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> <div class=md-social> <a href=https://github.com/BasalGanglia/kgraph-mcp-hackathon target=_blank rel=noopener title=github.com class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg> </a> <a href=https://pypi.org/project/kgraph-mcp/ target=_blank rel=noopener title=pypi.org class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><path d="M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6M286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3M167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4m-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3"/></svg> </a> <a href=mailto:[email protected] target=_blank rel=noopener title class=md-social__link> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 512 512"><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480v-83.6c0-4 1.5-7.8 4.2-10.8l167.6-182.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8l-88.3-44.2C7.1 311.3.3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4"/></svg> </a> </div> </div> </div> </footer> </div> <div class=md-dialog data-md-component=dialog> <div class="md-dialog__inner md-typeset"></div> </div> <div class=md-progress data-md-component=progress role=progressbar></div> <div class=md-consent data-md-component=consent id=__consent hidden> <div class=md-consent__overlay></div> <aside class=md-consent__inner> <form class="md-consent__form md-grid md-typeset" name=consent> <h4>Cookie consent</h4> <p>We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.</p> <input class=md-toggle type=checkbox id=__settings> <div class=md-consent__settings> <ul class=task-list> <li class=task-list-item> <label class=task-list-control> <input type=checkbox name=analytics checked> <span class=task-list-indicator></span> Google Analytics </label> </li> <li class=task-list-item> <label class=task-list-control> <input type=checkbox name=github checked> <span class=task-list-indicator></span> GitHub </label> </li> </ul> </div> <div class=md-consent__controls> <button class="md-button md-button--primary">Accept</button> <label class=md-button for=__settings>Manage settings</label> </div> </form> </aside> </div> <script>var consent=__md_get("__consent");if(consent)for(var input of document.forms.consent.elements)input.name&&(input.checked=consent[input.name]||!1);else"file:"!==location.protocol&&setTimeout((function(){document.querySelector("[data-md-component=consent]").hidden=!1}),250);var form=document.forms.consent;for(var action of["submit","reset"])form.addEventListener(action,(function(e){if(e.preventDefault(),"reset"===e.type)for(var n of document.forms.consent.elements)n.name&&(n.checked=!1);__md_set("__consent",Object.fromEntries(Array.from(new FormData(form).keys()).map((function(e){return[e,!0]})))),location.hash="",location.reload()}))</script> <script id=__config type=application/json>{"base": "../..", "features": ["navigation.instant", "navigation.instant.prefetch", "navigation.instant.progress", "navigation.tracking", "navigation.tabs", "navigation.tabs.sticky", "navigation.sections", "navigation.expand", "navigation.prune", "navigation.indexes", "navigation.top", "navigation.footer", "search.highlight", "search.share", "search.suggest", "header.autohide", "content.action.edit", "content.action.view", "content.code.annotate", "content.code.copy", "content.tabs.link", "content.tooltips", "announce.dismiss"], "search": "../../assets/javascripts/workers/search.d50fe291.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": {"default": "latest", "provider": "mike"}}</script> <script src=../../assets/javascripts/bundle.13a4f30d.min.js></script> <script id="init-glightbox">const lightbox = GLightbox({"touchNavigation": true, "loop": false, "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom", "slideEffect": "slide"}); |
|
|
document$.subscribe(() => { lightbox.reload() }); |
|
|
</script></body> </html> |