Close Menu
  • AI
  • Content Creation
  • Tech
  • Robotics
AI-trends.todayAI-trends.today
  • AI
  • Content Creation
  • Tech
  • Robotics
Trending
  • OpenAI Releases GPT-5.5, a Absolutely Retrained Agentic Mannequin That Scores 82.7% on Terminal-Bench 2.0 and 84.9% on GDPval
  • Your Favorite AI Gay Thirst Traps: The Men Behind them
  • Mend Releases AI Safety Governance Framework: Masking Asset Stock, Danger Tiering, AI Provide Chain Safety, and Maturity Mannequin
  • Google DeepMind Introduces Decoupled DiLoCo: An Asynchronous Coaching Structure Attaining 88% Goodput Below Excessive {Hardware} Failure Charges
  • Mend.io releases AI Security Governance Framework covering asset inventory, risk tiering, AI Supply Chain Security and Maturity model
  • Stanford Students Wait in Line to Hear From Silicon Valley Royalty at ‘AI Coachella’
  • Google Cloud AI Research introduces ReasoningBank: a memory framework that distills reasoning strategies from agent successes and failures.
  • Equinox Detailed implementation with JAX Native Moduls, Filtered Transformations, Stateful Ladders and Workflows from End to end.
AI-trends.todayAI-trends.today
Home»Tech»The implementation of IWE’s Context Bridge into an AI-Powered Knowledge Graph using Agentic RAG with OpenAI function calling, Graph Traversal, and OpenAI functions.

The implementation of IWE’s Context Bridge into an AI-Powered Knowledge Graph using Agentic RAG with OpenAI function calling, Graph Traversal, and OpenAI functions.

Tech By Gavin Wallace27/03/20263 Mins Read
Facebook Twitter LinkedIn Email
Samsung Researchers Introduced ANSE (Active Noise Selection for Generation): A
Samsung Researchers Introduced ANSE (Active Noise Selection for Generation): A
Share
Facebook Twitter LinkedIn Email
print("─" * 72)
print("  5 · Agentic RAG — AI Navigates Your Knowledge Graph")
print("─" * 72)




AGENT_TOOLS = [
   {
       "type": "function",
       "function": {
           "name": "iwe_find",
           "description": "Search the knowledge graph for documents matching a query. Returns a list of document keys.",
           "parameters": {
               "type": "object",
               "properties": {
                   "query": {"type": "string", "description": "Search query"},
                   "roots_only": {"type": "boolean", "description": "Only return root/MOC documents", "default": False},
               },
               "required": ["query"],
           },
       },
   },
   {
       "type": "function",
       "function": {
           "name": "iwe_retrieve",
           "description": "Retrieve a document's content with linked context. Use depth>0 to follow outgoing links, context>0 to include parent documents.",
           "parameters": {
               "type": "object",
               "properties": {
                   "key": {"type": "string", "description": "Document key to retrieve"},
                   "depth": {"type": "integer", "description": "How many levels of child links to follow (0-2)", "default": 1},
                   "context": {"type": "integer", "description": "How many levels of parent context (0-1)", "default": 0},
               },
               "required": ["key"],
           },
       },
   },
   {
       "type": "function",
       "function": {
           "name": "iwe_tree",
           "description": "Show the document hierarchy starting from a given key.",
           "parameters": {
               "type": "object",
               "properties": {
                   "key": {"type": "string", "description": "Root document key"},
               },
               "required": ["key"],
           },
       },
   },
   {
       "type": "function",
       "function": {
           "name": "iwe_stats",
           "description": "Get statistics about the entire knowledge base.",
           "parameters": {"type": "object", "properties": {}},
       },
   },
]




def execute_tool(name: str, args: dict) -> str:
 If Name == "iwe_find":
 Results = kg.find (args)["query"], roots_only=args.get("roots_only", False))
       return json.dumps({"results": results})
 "elif" name="=" "iwe_retrieve":
 Content = kg.retrieve (
 The args["key"],
           depth=args.get("depth", 1),
           context=args.get("context", 0),
       )
 Return content[:3000]
 "elif" name="" "iwe_tree":
 Return kg.tree["key"])
 "elif" name="=" "iwe_stats":
     Return to the Homepage json.dumps(kg.stats(), indent=2)
   return "Unknown tool"




def run_agent(question: str, max_turns: int = 6, model: str = "gpt-4o-mini") -> str:
   system_prompt = textwrap.dedent("""
 Your AI assistant has access to your personal knowledge graph.
 Navigate the graph using the available tools.


       Workflow:
       1. Find relevant documents using iwe_find
       2. Use iwe_retrieve for reading content (set the depth=1 option to follow links).
       3. To build a comprehensive understanding, follow relationships.
       4. Combine information in multiple documents


 Cite the documents that you used to find information.
 Do not hesitate to say that you are unable to find sufficient information.
   """)


 The message = [
       {"role": "system", "content": system_prompt},
       {"role": "user", "content": question},
   ]


 For turn within range (max_turns).
       response = client.chat.completions.create(
           model=model, messages=messages, tools=AGENT_TOOLS,
           tool_choice="auto",
       )
 Response.choices = msg[0].message


 If the msg.tool_calls are:
           messages.append(msg)
 For tc calls in msg.tool_calls
               fn_name = tc.function.name
               fn_args = json.loads(tc.function.arguments)
               print(f"   🔧 Agent calls: {fn_name}({fn_args})")
               result = execute_tool(fn_name, fn_args)
               messages.append({
                   "role": "tool",
                   "tool_call_id": tc.id,
                   "content": result,
               })
       else:
 Content returned msg


 Return to the Homepage "Agent reached maximum turns without completing."




Question [
   "How does our authentication system work, and what database tables does it depend on?",
   "What is our deployment pipeline, and what are the performance SLO targets?",
   "Give me a high-level overview of the entire project architecture.",
]


Questions, 1:
   print(f"n{'═' * 72}")
   print(f"  Question {i}: {q}")
   print(f"{'═' * 72}n")
 Answer = run_agent (q)
   print(f"n💡 Agent Answer:n{answer}n")


print("n✅  Section 5 complete — Agentic RAG demonstrated.n")
AI openai x
Share. Facebook Twitter LinkedIn Email
Avatar
Gavin Wallace

Related Posts

OpenAI Releases GPT-5.5, a Absolutely Retrained Agentic Mannequin That Scores 82.7% on Terminal-Bench 2.0 and 84.9% on GDPval

24/04/2026

Mend Releases AI Safety Governance Framework: Masking Asset Stock, Danger Tiering, AI Provide Chain Safety, and Maturity Mannequin

24/04/2026

Google DeepMind Introduces Decoupled DiLoCo: An Asynchronous Coaching Structure Attaining 88% Goodput Below Excessive {Hardware} Failure Charges

24/04/2026

Mend.io releases AI Security Governance Framework covering asset inventory, risk tiering, AI Supply Chain Security and Maturity model

23/04/2026
Top News

Nvidia is planning to launch an open-source AI agent platform

Google Wants to Get Better at Spotting Wildfires From Space

Moltbook – the social network for AI Agents – exposed data of real humans

Why AI Wants Massive Numerical Fashions (LNMs) for Mathematical Mastery • AI Weblog

Allbirds will be focusing more on AI Compute. You can’t say no.

Load More
AI-Trends.Today

Your daily source of AI news and trends. Stay up to date with everything AI and automation!

X (Twitter) Instagram
Top Insights

50+ Model Context Protocol (MCP) Servers Worth Exploring

08/06/2025

OpenAI Leadership’s Response to Meta Offers, ‘Someone is Breaking into Our House’

29/06/2025
Latest News

OpenAI Releases GPT-5.5, a Absolutely Retrained Agentic Mannequin That Scores 82.7% on Terminal-Bench 2.0 and 84.9% on GDPval

24/04/2026

Your Favorite AI Gay Thirst Traps: The Men Behind them

24/04/2026
X (Twitter) Instagram
  • Privacy Policy
  • Contact Us
  • Terms and Conditions
© 2026 AI-Trends.Today

Type above and press Enter to search. Press Esc to cancel.