The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docs: Use Kinetica Sql context API (#21993)
Chad Juliano9a66c4314658
diff --git a/docs/docs/integrations/chat/kinetica.ipynb b/docs/docs/integrations/chat/kinetica.ipynbindex 36bb049e78..93fd51f4ac 100644--- a/docs/docs/integrations/chat/kinetica.ipynb+++ b/docs/docs/integrations/chat/kinetica.ipynb@@ -62,10 +62,10 @@"%pip install --upgrade --quiet langchain-core langchain-community\n","\n","# Install Kineitca DB connection package\n",- "%pip install --upgrade --quiet gpudb typeguard\n",+ "%pip install --upgrade --quiet 'gpudb>=7.2.0.8' typeguard pandas tqdm\n","\n","# Install packages needed for this tutorial\n",- "%pip install --upgrade --quiet faker"+ "%pip install --upgrade --quiet faker ipykernel "]},{@@ -114,7 +114,7 @@},{"cell_type": "code",- "execution_count": 2,+ "execution_count": 11,"metadata": {},"outputs": [{@@ -139,11 +139,11 @@"\n"," birthdate \n","id \n",- "0 1997-12-01 \n",- "1 1924-07-27 \n",- "2 1933-11-28 \n",- "3 1988-10-19 \n",- "4 1931-03-12 \n"+ "0 1997-12-08 \n",+ "1 1924-08-03 \n",+ "2 1933-12-05 \n",+ "3 1988-10-26 \n",+ "4 1931-03-19 \n"]}],@@ -222,39 +222,60 @@},{"cell_type": "code",- "execution_count": 4,+ "execution_count": 7,"metadata": {},"outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "CREATE OR REPLACE CONTEXT \"demo\".\"test_llm_ctx\" (\n",+ " TABLE = \"demo\".\"user_profiles\",\n",+ " COMMENT = 'Contains user profiles.'\n",+ "),\n",+ "(\n",+ " SAMPLES = ( \n",+ " 'How many male users are there?' = 'select count(1) as num_users\n",+ " from demo.user_profiles\n",+ " where sex = ''M'';' )\n",+ ")\n"+ ]+ },{"data": {"text/plain": ["1"]},- "execution_count": 4,+ "execution_count": 7,"metadata": {},"output_type": "execute_result"}],"source": [- "# create an LLM context for the table.\n",- "\n",- "sql = f\"\"\"\n",- "CREATE OR REPLACE CONTEXT {kinetica_ctx}\n",- "(\n",- " TABLE = {table_name}\n",- " COMMENT = 'Contains user profiles.'\n",- "),\n",- "(\n",- " SAMPLES = (\n",- " 'How many male users are there?' = \n",- " 'select count(1) as num_users\n",- " from {table_name}\n",- " where sex = ''M'';')\n",+ "from gpudb import GPUdbSamplesClause, GPUdbSqlContext, GPUdbTableClause\n",+ "\n",+ "table_ctx = GPUdbTableClause(table=table_name, comment=\"Contains user profiles.\")\n",+ "\n",+ "samples_ctx = GPUdbSamplesClause(\n",+ " samples=[\n",+ " (\n",+ " \"How many male users are there?\",\n",+ " f\"\"\"\n",+ " select count(1) as num_users\n",+ " from {table_name}\n",+ " where sex = 'M';\n",+ " \"\"\",\n",+ " )\n",+ " ]\n",")\n",- "\"\"\"\n","\n",- "count_affected = kinetica_llm.kdbc.execute(sql)\n",+ "context_sql = GPUdbSqlContext(\n",+ " name=kinetica_ctx, tables=[table_ctx], samples=samples_ctx\n",+ ").build_sql()\n",+ "\n",+ "print(context_sql)\n",+ "count_affected = kinetica_llm.kdbc.execute(context_sql)\n","count_affected"]},@@ -273,7 +294,7 @@},{"cell_type": "code",- "execution_count": 5,+ "execution_count": 8,"metadata": {},"outputs": [{@@ -334,7 +355,7 @@},{"cell_type": "code",- "execution_count": 6,+ "execution_count": 9,"metadata": {},"outputs": [],"source": [@@ -357,7 +378,7 @@},{"cell_type": "code",- "execution_count": 7,+ "execution_count": 10,"metadata": {},"outputs": [{@@ -404,7 +425,7 @@"name": "python","nbconvert_exporter": "python","pygments_lexer": "ipython3",- "version": "3.8.19"+ "version": "3.9.19"}},"nbformat": 4,