Notebooks
M
MongoDB
Function Calling Mongodb As A Toolbox

Function Calling Mongodb As A Toolbox

advanced_techniquesagentsartificial-intelligencellmsmongodb-genai-showcasenotebooksgenerative-airag

MongoDB As A Toolbox For Agentic Systems

Open In Colab

[1]
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 361.3/361.3 kB 7.0 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 21.4 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 307.7/307.7 kB 13.4 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.6/75.6 kB 4.2 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.9/77.9 kB 3.9 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 318.9/318.9 kB 14.3 MB/s eta 0:00:00
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 3.2 MB/s eta 0:00:00
[2]
OpenAI API Key: ··········
Enter MongoDB URI: ··········
[3]

Define MongoDB Tool Decorator

[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[{'function': {'description': 'Convert a statement to uppercase letters to '
                              'emulate shouting. Use this when a user wants to '
                              'emphasize something strongly or when they '
                              "explicitly ask to 'shout' something..",
               'name': 'shout',
               'parameters': {'additionalProperties': False,
                              'properties': {'statement': {'description': 'Parameter '
                                                                          'statement',
                                                           'type': 'string'}},
                              'required': ['statement'],
                              'type': 'object'}},
  'type': 'function'},
 {'function': {'description': 'Get the current stock price for a given stock '
                              'symbol.\n'
                              'Use this when a user asks about the current '
                              'price of a specific stock.\n'
                              '\n'
                              ':param symbol: The stock symbol to look up '
                              "(e.g., 'AAPL' for Apple Inc.).\n"
                              ':return: A string with the current stock price.',
               'name': 'get_stock_price',
               'parameters': {'additionalProperties': False,
                              'properties': {'symbol': {'description': 'Parameter '
                                                                       'symbol',
                                                        'type': 'string'}},
                              'required': ['symbol'],
                              'type': 'object'}},
  'type': 'function'}]
[13]
[14]
[15]
ChatCompletionMessage(content=None, refusal=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_U7kkN9X2ohVasUD5ReOaRwcG', function=Function(arguments='{"statement":"We are there"}', name='shout'), type='function')])
[16]
Debug - Tool call received: shout
Debug - Arguments: {"statement":"We are there"}
WE ARE THERE! How can I assist you further?