diff --git a/notebook/agentchat_graph_rag_neo4j.ipynb b/notebook/agentchat_graph_rag_neo4j.ipynb index 4141e2560a..d68ba8971d 100644 --- a/notebook/agentchat_graph_rag_neo4j.ipynb +++ b/notebook/agentchat_graph_rag_neo4j.ipynb @@ -4,16 +4,18 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Using Neo4j LlamaIndex query engine with AG2 agents for GraphRAG Question & Answering\n", + "# Using Neo4j's graph database with AG2 agents for Question & Answering\n", "\n", - " AG2 provides GraphRAG integration using agent capabilities. This is an example to integrate Neo4j property graph and LlamaIndex graph query engine.\n", + "AG2 provides GraphRAG integration through agent capabilities. This is an example utilising the integration of Neo4j's property graph database with LlamaIndex's graph query engine.\n", "\n", "\n", - "### info Requirements\n", - "llama-index dependencies, which is required to use Neo4j prpoerty graph\n", + "````{=mdx}\n", + ":::info Requirements\n", + "To install the LlamaIndex, Neo4j, and document processing dependencies, install with the 'neo4j' extra:\n", "\n", - "`pip install llama-index==0.12.5 llama-index-graph-stores-neo4j==0.4.2 llama-index-core==0.12.5`\n", - "\n" + "```bash\n", + "pip install ag2[neo4j]\n", + "```" ] }, { @@ -37,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -45,7 +47,7 @@ "\n", "import autogen\n", "\n", - "config_list = autogen.config_list_from_json(env_or_file=\"OAI_CONFIG_LIST\", file_location=\"../\")\n", + "config_list = autogen.config_list_from_json(env_or_file=\"OAI_CONFIG_LIST\", file_location=\".\")\n", "\n", "# Put the OpenAI API key into the environment\n", "os.environ[\"OPENAI_API_KEY\"] = config_list[0][\"api_key\"]" @@ -53,7 +55,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -96,6 +98,20 @@ "We initialise the database with a Word document, creating the Property graph in Neo4j." ] }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# IMPORTS\n", + "from llama_index.embeddings.openai import OpenAIEmbedding\n", + "from llama_index.llms.openai import OpenAI\n", + "\n", + "from autogen import ConversableAgent, UserProxyAgent\n", + "from autogen.agentchat.contrib.graph_rag.neo4j_graph_query_engine import Neo4jGraphQueryEngine" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -111,7 +127,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -122,46 +138,6 @@ "input_documents = [Document(doctype=DocumentType.TEXT, path_or_url=input_path)]" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Parsing nodes: 100%|██████████| 1/1 [00:00<00:00, 21.26it/s]\n", - "Extracting paths from text with schema: 100%|██████████| 12/12 [00:17<00:00, 1.45s/it]\n", - "Generating embeddings: 100%|██████████| 1/1 [00:00<00:00, 2.17it/s]\n", - "Generating embeddings: 100%|██████████| 1/1 [00:00<00:00, 1.60it/s]\n" - ] - } - ], - "source": [ - "# pip install docx2txt\n", - "# Auto generate graph schema from unstructured data\n", - "from llama_index.embeddings.openai import OpenAIEmbedding\n", - "from llama_index.llms.openai import OpenAI\n", - "\n", - "from autogen import ConversableAgent, UserProxyAgent\n", - "from autogen.agentchat.contrib.graph_rag.neo4j_graph_query_engine import Neo4jGraphQueryEngine\n", - "\n", - "# Create Neo4jGraphQueryEngine\n", - "query_engine = Neo4jGraphQueryEngine(\n", - " username=\"neo4j\", # Change if you reset username\n", - " password=\"password\", # Change if you reset password\n", - " host=\"bolt://172.17.0.3\", # Change\n", - " port=7687, # if needed\n", - " llm=OpenAI(model=\"gpt-4o\", temperature=0.0), # Default, no need to specify\n", - " embedding=OpenAIEmbedding(model_name=\"text-embedding-3-small\"), # except you want to use a different model\n", - " database=\"neo4j\", # Change if you want to store the graphh in your custom database\n", - ")\n", - "\n", - "# Ingest data and initialize the database\n", - "query_engine.init_db(input_doc=input_documents)" - ] - }, { "attachments": { "neo4j_property_graph_1.png": { @@ -171,7 +147,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The Property graph screenshot is shown below:\n", + "An example property graph:\n", "\n", "![neo4j_property_graph_1.png](attachment:neo4j_property_graph_1.png)" ] @@ -180,123 +156,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Add capability to a ConversableAgent and query them\n", - "Please be aware that currently query engine doesn't have a conversation history itself (TODO)" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", - "\n", - "Which company is the employer?\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", - "\n", - "BUZZ\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", - "\n", - "What policies does BUZZ have?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", - "\n", - "BUZZ has policies related to severe weather conditions, liberal leave, reimbursement of expenses, separation including resignation, termination or lay-off, and discharge criteria.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", - "\n", - "How is reimbursement of expenses defined?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", - "\n", - "Reimbursement of expenses is authorized for reasonable and necessary expenses incurred in carrying out job responsibilities. This includes expenses such as mileage or transportation, parking fees, business telephone calls, and meal costs when required to attend a luncheon or banquet. Employees serving in an official capacity for BUZZ at conferences and meetings are reimbursed for actual and necessary expenses incurred, such as travel expenses, meal costs, lodging, tips, and registration fees. Requests for reimbursement must be supported by receipts for all expenditures made.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", - "\n", - "Does Donald Trump work here?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", - "\n", - "There is no information provided in the context about Donald Trump working at the organization mentioned.\n", - "\n", - "--------------------------------------------------------------------------------\n" - ] - }, - { - "data": { - "text/plain": [ - "ChatResult(chat_id=None, chat_history=[{'content': 'Which company is the employer?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'BUZZ', 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'What policies does BUZZ have?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'BUZZ has policies related to severe weather conditions, liberal leave, reimbursement of expenses, separation including resignation, termination or lay-off, and discharge criteria.', 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'How is reimbursement of expenses defined?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Reimbursement of expenses is authorized for reasonable and necessary expenses incurred in carrying out job responsibilities. This includes expenses such as mileage or transportation, parking fees, business telephone calls, and meal costs when required to attend a luncheon or banquet. Employees serving in an official capacity for BUZZ at conferences and meetings are reimbursed for actual and necessary expenses incurred, such as travel expenses, meal costs, lodging, tips, and registration fees. Requests for reimbursement must be supported by receipts for all expenditures made.', 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'Does Donald Trump work here?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'There is no information provided in the context about Donald Trump working at the organization mentioned.', 'role': 'user', 'name': 'paul_graham_agent'}], summary='There is no information provided in the context about Donald Trump working at the organization mentioned.', cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['What policies does BUZZ have?', 'How is reimbursement of expenses defined?', 'Does Donald Trump work here?', 'exit'])" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from autogen.agentchat.contrib.graph_rag.neo4j_graph_rag_capability import Neo4jGraphCapability\n", - "\n", - "# Create a ConversableAgent (no LLM configuration)\n", - "graph_rag_agent = ConversableAgent(\n", - " name=\"paul_graham_agent\",\n", - " human_input_mode=\"NEVER\",\n", - ")\n", - "\n", - "# Associate the capability with the agent\n", - "graph_rag_capability = Neo4jGraphCapability(query_engine)\n", - "graph_rag_capability.add_to_agent(graph_rag_agent)\n", - "\n", - "# Create a user proxy agent to converse with our RAG agent\n", - "user_proxy = UserProxyAgent(\n", - " name=\"user_proxy\",\n", - " human_input_mode=\"ALWAYS\",\n", - ")\n", - "\n", - "user_proxy.initiate_chat(graph_rag_agent, message=\"Which company is the employer?\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Revisit the example by defining custom entities, relations and schema" + "### Schema\n", + "Define our custom entities, relations and schema" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Parsing nodes: 100%|██████████| 1/1 [00:00<00:00, 49.17it/s]\n", - "Extracting paths from text with schema: 100%|██████████| 12/12 [00:29<00:00, 2.43s/it]\n", - "Generating embeddings: 100%|██████████| 1/1 [00:00<00:00, 1.64it/s]\n", - "Generating embeddings: 100%|██████████| 3/3 [00:01<00:00, 2.61it/s]\n" - ] - } - ], + "outputs": [], "source": [ "from typing import Literal\n", "\n", @@ -325,20 +193,48 @@ " \"DEPARTMENT\": [\"PART_OF\", \"MANAGES\", \"REQUIRES\"],\n", " \"CONTRACT\": [\"PROVIDES\", \"REQUIRES\", \"APPLIES_TO\"],\n", " \"RESPONSIBILITY\": [\"ASSIGNED_TO\", \"REQUIRES\", \"DEFINED_AS\"],\n", - "}\n", - "\n", + "}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Create the query engine and load the document" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/mark/miniconda3/envs/ag2neo4j/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n", + "Parsing nodes: 100%|██████████| 1/1 [00:00<00:00, 321.70it/s]\n", + "Extracting paths from text with schema: 100%|██████████| 3/3 [00:29<00:00, 9.92s/it]\n", + "Generating embeddings: 100%|██████████| 1/1 [00:00<00:00, 1.41it/s]\n", + "Generating embeddings: 100%|██████████| 1/1 [00:01<00:00, 1.19s/it]\n" + ] + } + ], + "source": [ "# Create Neo4jGraphQueryEngine\n", "query_engine = Neo4jGraphQueryEngine(\n", - " username=\"neo4j\", # Change if you reset username\n", - " password=\"password\", # Change if you reset password\n", - " host=\"bolt://172.17.0.3\", # Change\n", - " port=7687, # if needed\n", - " database=\"neo4j\", # Change if you want to store the graphh in your custom database\n", - " llm=OpenAI(model=\"gpt-4o\", temperature=0.0), # Default, no need to specify\n", + " username=\"neo4j\", # Change these as needed\n", + " password=\"neo4jneo4j\",\n", + " host=\"bolt://192.168.0.115\",\n", + " port=7687,\n", + " database=\"neo4j\",\n", + " llm=OpenAI(model=\"gpt-4o\", temperature=0.0),\n", + " embedding=OpenAIEmbedding(model_name=\"text-embedding-3-small\"),\n", " entities=entities, # possible entities\n", " relations=relations, # possible relations\n", " validation_schema=validation_schema, # schema to validate the extracted triplets\n", - " strict=True, # enofrce the extracted triplets to be in the schema\n", + " strict=True, # enforce the extracted triplets to be in the schema\n", ")\n", "\n", "# Ingest data and initialize the database\n", @@ -363,77 +259,47 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Add capability to a ConversableAgent and query them again\n", - "You should find the answers improve if the schema fits well" + "### Create Neo4j-based RAG agents\n", + "With the schema defined and data loaded, we can now create a capable agent!" ] }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", + "\u001b[33muser_proxy\u001b[0m (to rag_agent):\n", "\n", "Which company is the employer?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", + "\u001b[33mrag_agent\u001b[0m (to user_proxy):\n", "\n", - "BUZZ\n", + "BUZZ Co.\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", + "\u001b[33muser_proxy\u001b[0m (to rag_agent):\n", "\n", - "What polices does BUZZ have?\n", + "Tell me about sick leave\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", + "\u001b[33mrag_agent\u001b[0m (to user_proxy):\n", "\n", - "BUZZ has policies related to employment, computer and information security, internet acceptable use, solicitation, hours of work, attendance, punctuality, and unauthorized access to other organizations' computer systems and data.\n", + "Employees at BUZZ Co. are entitled to one day of sick leave per month for full-time employees, which is prorated for part-time employees, with a maximum accumulation of up to 30 days.\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", + "\u001b[33muser_proxy\u001b[0m (to rag_agent):\n", "\n", - "How is attendance policy defined?\n", + "And vacation?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", + "\u001b[33mrag_agent\u001b[0m (to user_proxy):\n", "\n", - "Employees are expected to meet the performance standards of their job at BUZZ and will be evaluated based on these standards. They are also required to adhere to BUZZ scheduling demands regardless of any outside work requirements. If outside employment interferes with an employee's job performance or their ability to meet BUZZ's requirements, they may be asked to terminate the outside employment. Additionally, outside employment that creates a conflict of interest is prohibited at BUZZ.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", - "\n", - "What does computer and information security policy require?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", - "\n", - "The computer and information security policy requires that users do not attempt to bypass or render ineffective security facilities provided by the company. It also specifies that passwords should not be shared between users, personal software should not be loaded onto company computers, and unlicensed software should not be loaded or executed on company computers. Additionally, the policy prohibits the downloading of programs from bulletin board systems or copying from other computers outside the company onto company computers.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", - "\n", - "What benefits does BUZZ provide?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", - "\n", - "BUZZ provides a competitive package of benefits to all eligible full-time and part-time employees. These benefits include individual health and dental insurance, Social Security, Medicare, and Medicaid participation, Workers' Compensation coverage, and participation in the District of Columbia unemployment program.\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", - "\n", - "Does Donald Trump like BUZZ's policies?\n", - "\n", - "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", - "\n", - "There is no information provided in the context about Donald Trump's opinion on BUZZ's policies.\n", + "Full-time employees at BUZZ Co. earn 10 days of vacation after the first year, 15 days after the third year, and 20 days after the fourth year. Part-time employees' vacation days are prorated based on their hours worked.\n", "\n", "--------------------------------------------------------------------------------\n" ] @@ -441,10 +307,10 @@ { "data": { "text/plain": [ - "ChatResult(chat_id=None, chat_history=[{'content': 'Which company is the employer?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'BUZZ', 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'What polices does BUZZ have?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"BUZZ has policies related to employment, computer and information security, internet acceptable use, solicitation, hours of work, attendance, punctuality, and unauthorized access to other organizations' computer systems and data.\", 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'How is attendance policy defined?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"Employees are expected to meet the performance standards of their job at BUZZ and will be evaluated based on these standards. They are also required to adhere to BUZZ scheduling demands regardless of any outside work requirements. If outside employment interferes with an employee's job performance or their ability to meet BUZZ's requirements, they may be asked to terminate the outside employment. Additionally, outside employment that creates a conflict of interest is prohibited at BUZZ.\", 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'What does computer and information security policy require?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'The computer and information security policy requires that users do not attempt to bypass or render ineffective security facilities provided by the company. It also specifies that passwords should not be shared between users, personal software should not be loaded onto company computers, and unlicensed software should not be loaded or executed on company computers. Additionally, the policy prohibits the downloading of programs from bulletin board systems or copying from other computers outside the company onto company computers.', 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'What benefits does BUZZ provide?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"BUZZ provides a competitive package of benefits to all eligible full-time and part-time employees. These benefits include individual health and dental insurance, Social Security, Medicare, and Medicaid participation, Workers' Compensation coverage, and participation in the District of Columbia unemployment program.\", 'role': 'user', 'name': 'paul_graham_agent'}, {'content': \"Does Donald Trump like BUZZ's policies?\", 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"There is no information provided in the context about Donald Trump's opinion on BUZZ's policies.\", 'role': 'user', 'name': 'paul_graham_agent'}], summary=\"There is no information provided in the context about Donald Trump's opinion on BUZZ's policies.\", cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['What polices does BUZZ have?', 'How is attendance policy defined?', 'What does computer and information security policy require?', 'What benefits does BUZZ provide?', \"Does Donald Trump like BUZZ's policies?\", 'exit'])" + "ChatResult(chat_id=None, chat_history=[{'content': 'Which company is the employer?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'BUZZ Co.', 'role': 'user', 'name': 'rag_agent'}, {'content': 'Tell me about sick leave', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Employees at BUZZ Co. are entitled to one day of sick leave per month for full-time employees, which is prorated for part-time employees, with a maximum accumulation of up to 30 days.', 'role': 'user', 'name': 'rag_agent'}, {'content': 'And vacation?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"Full-time employees at BUZZ Co. earn 10 days of vacation after the first year, 15 days after the third year, and 20 days after the fourth year. Part-time employees' vacation days are prorated based on their hours worked.\", 'role': 'user', 'name': 'rag_agent'}], summary=\"Full-time employees at BUZZ Co. earn 10 days of vacation after the first year, 15 days after the third year, and 20 days after the fourth year. Part-time employees' vacation days are prorated based on their hours worked.\", cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['Tell me about sick leave', 'And vacation?', 'exit'])" ] }, - "execution_count": 27, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -454,7 +320,7 @@ "\n", "# Create a ConversableAgent (no LLM configuration)\n", "graph_rag_agent = ConversableAgent(\n", - " name=\"paul_graham_agent\",\n", + " name=\"rag_agent\",\n", " human_input_mode=\"NEVER\",\n", ")\n", "\n", @@ -463,10 +329,7 @@ "graph_rag_capability.add_to_agent(graph_rag_agent)\n", "\n", "# Create a user proxy agent to converse with our RAG agent\n", - "user_proxy = UserProxyAgent(\n", - " name=\"user_proxy\",\n", - " human_input_mode=\"ALWAYS\",\n", - ")\n", + "user_proxy = UserProxyAgent(name=\"user_proxy\", human_input_mode=\"ALWAYS\", code_execution_config=False)\n", "\n", "user_proxy.initiate_chat(graph_rag_agent, message=\"Which company is the employer?\")" ] @@ -480,17 +343,17 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Parsing nodes: 100%|██████████| 1/1 [00:00<00:00, 103.34it/s]\n", - "Extracting paths from text with schema: 100%|██████████| 1/1 [00:07<00:00, 7.95s/it]\n", - "Generating embeddings: 100%|██████████| 1/1 [00:00<00:00, 1.40it/s]\n", - "Generating embeddings: 100%|██████████| 1/1 [00:00<00:00, 1.62it/s]\n" + "Parsing nodes: 100%|██████████| 1/1 [00:00<00:00, 545.99it/s]\n", + "Extracting paths from text with schema: 100%|██████████| 1/1 [00:30<00:00, 30.24s/it]\n", + "Generating embeddings: 100%|██████████| 1/1 [00:00<00:00, 2.61it/s]\n", + "Generating embeddings: 100%|██████████| 1/1 [00:01<00:00, 1.20s/it]\n" ] } ], @@ -510,7 +373,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Checking the property graph, we'll find a new pocily (entity) called Equal Employment Opportunity Policy is added\n", + "Checking the property graph, we'll find a new policy (entity) called Equal Employment Opportunity Policy is added\n", "\n", "![neo4j_property_graph_3.png](attachment:neo4j_property_graph_3.png)" ] @@ -524,31 +387,41 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", + "\u001b[33muser_proxy\u001b[0m (to rag_agent):\n", "\n", "What is Equal Employment Opportunity Policy at BUZZ?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", + "\u001b[33mrag_agent\u001b[0m (to user_proxy):\n", + "\n", + "The Equal Employment Opportunity Policy at BUZZ Co. ensures non-discrimination and equal employment opportunities for all employees and applicants. It prohibits discrimination or harassment based on various factors and covers aspects such as recruitment, promotion, training, working conditions, wages, and benefits. The policy is disseminated by BUZZ Co. officers, implemented by directors, managers, and supervisors, and enforced by the Human Resources department to ensure company-wide compliance with anti-discrimination laws and regulations.\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33muser_proxy\u001b[0m (to rag_agent):\n", + "\n", + "What's the scope of the Equal Employment Opportunity and Anti-Discrimination Policy?\n", + "\n", + "--------------------------------------------------------------------------------\n", + "\u001b[33mrag_agent\u001b[0m (to user_proxy):\n", "\n", - "Equal Employment Opportunity Policy at BUZZ ensures that discrimination and harassment are prohibited, and it provides equal employment opportunities to all employees and applicants without regard to various characteristics such as race, color, religion, sex, sexual orientation, and more. The policy applies to officers of BUZZ, temporary agencies, employees, firms doing business with BUZZ, personnel working on premises, HR department, Directors, managers, supervisors, and independent contractors. BUZZ conforms to all applicable laws and regulations related to equal employment opportunity.\n", + "The scope of the Equal Employment Opportunity and Anti-Discrimination Policy includes all aspects of the employment relationship at BUZZ Co., such as recruitment, employment, promotion, transfer, training, working conditions, wages and salary administration, and employee benefits. This policy also extends to the selection and treatment of independent contractors, temporary agency personnel working on BUZZ Co. premises, and any other individuals or firms conducting business for or with BUZZ Co.\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33muser_proxy\u001b[0m (to paul_graham_agent):\n", + "\u001b[33muser_proxy\u001b[0m (to rag_agent):\n", "\n", - "List additional policies execpt Equal Employment Opportunity Policy at BUZZ\n", + "Is Promotion part of the scope of the Equal Employment Opportunity and Anti-Discrimination Policy?\n", "\n", "--------------------------------------------------------------------------------\n", - "\u001b[33mpaul_graham_agent\u001b[0m (to user_proxy):\n", + "\u001b[33mrag_agent\u001b[0m (to user_proxy):\n", "\n", - "Outside Employment Policy, Non-Disclosure of Confidential Information, Computer and Information Security\n", + "Yes.\n", "\n", "--------------------------------------------------------------------------------\n" ] @@ -556,10 +429,10 @@ { "data": { "text/plain": [ - "ChatResult(chat_id=None, chat_history=[{'content': 'What is Equal Employment Opportunity Policy at BUZZ?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Equal Employment Opportunity Policy at BUZZ ensures that discrimination and harassment are prohibited, and it provides equal employment opportunities to all employees and applicants without regard to various characteristics such as race, color, religion, sex, sexual orientation, and more. The policy applies to officers of BUZZ, temporary agencies, employees, firms doing business with BUZZ, personnel working on premises, HR department, Directors, managers, supervisors, and independent contractors. BUZZ conforms to all applicable laws and regulations related to equal employment opportunity.', 'role': 'user', 'name': 'paul_graham_agent'}, {'content': 'List additional policies execpt Equal Employment Opportunity Policy at BUZZ', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Outside Employment Policy, Non-Disclosure of Confidential Information, Computer and Information Security', 'role': 'user', 'name': 'paul_graham_agent'}], summary='Outside Employment Policy, Non-Disclosure of Confidential Information, Computer and Information Security', cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['List additional policies execpt Equal Employment Opportunity Policy at BUZZ', 'exit'])" + "ChatResult(chat_id=None, chat_history=[{'content': 'What is Equal Employment Opportunity Policy at BUZZ?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'The Equal Employment Opportunity Policy at BUZZ Co. ensures non-discrimination and equal employment opportunities for all employees and applicants. It prohibits discrimination or harassment based on various factors and covers aspects such as recruitment, promotion, training, working conditions, wages, and benefits. The policy is disseminated by BUZZ Co. officers, implemented by directors, managers, and supervisors, and enforced by the Human Resources department to ensure company-wide compliance with anti-discrimination laws and regulations.', 'role': 'user', 'name': 'rag_agent'}, {'content': \"What's the scope of the Equal Employment Opportunity and Anti-Discrimination Policy?\", 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'The scope of the Equal Employment Opportunity and Anti-Discrimination Policy includes all aspects of the employment relationship at BUZZ Co., such as recruitment, employment, promotion, transfer, training, working conditions, wages and salary administration, and employee benefits. This policy also extends to the selection and treatment of independent contractors, temporary agency personnel working on BUZZ Co. premises, and any other individuals or firms conducting business for or with BUZZ Co.', 'role': 'user', 'name': 'rag_agent'}, {'content': 'Is Promotion part of the scope of the Equal Employment Opportunity and Anti-Discrimination Policy?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Yes.', 'role': 'user', 'name': 'rag_agent'}], summary='Yes.', cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=[\"What's the scope of the Equal Employment Opportunity and Anti-Discrimination Policy?\", 'Is Promotion part of the scope of the Equal Employment Opportunity and Anti-Discrimination Policy?', 'exit'])" ] }, - "execution_count": 32, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -574,7 +447,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "ag2neo4j", "language": "python", "name": "python3" }, @@ -588,7 +461,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.10" + "version": "3.13.1" } }, "nbformat": 4,