1
Setup your project in a new directory called
note-assistant.2
Write your first AI primitive using Agentica.
3
Start sharing your code with the AI over RPC.
4
Bundle up your first AI application.
5
How you could extend your application using agents.
Installation
We’ll setup our project in a new directory callednote-assistant.
- Python+uv
- Python+pip
- TypeScript+Node
- TypeScript+Bun
Prerequisites:Export your API key under the Then, start editing your
- Python version
3.12.* uvpackage manager- Your Agentica API key from the login page
AGENTICA_API_KEY environment variable.main.py file.Your First Magic Function
Our note assistant will need the ability to search notes. Let’s start by adding a magic function which is capable of summarizing the content of a note.- Python
- TypeScript
main.py
- The
@magicdecorator turned a function into an AI-powered function which can be called like a normal function. - The arguments to the magic function became available to the AI per call.
- The docstring in the function body told the AI what it should do.
- The function body was otherwise empty, since the AI dynamically generates the return value per call.
Adding Tools
Create a magic function which can search for a specific note in a list of notes.- Python
- TypeScript
Say our note-store is a list of strings.
Our intelligent magic function will get a query for a note and return the index of the most relevant note in the list.Let’s first define a helper resource (in this case, a function) which will show the notes with their indices.We can give the magic function access to this resource by passing it as an argument to the Now let’s use it to search for a note.In this example,
main.py
@magic decorator.main.py
main.py
print_list_with_indices was a function that might have been helpful for the AI to accurately implement the magic function.
In general, you can pass in any function, class, object or other Python value that you want the AI to use or have access to.Putting it together
We have summarization, and searching for notes. To avoid overwhelming our AI, we can have it search through summarized notes instead of the raw notes. Let’s also cache the summarized notes so we don’t re-summarize them each time.- Python
- TypeScript
main.py
Using Agents
Now we could extend our application to include a chat-with-notes feature. This requires a stateful context of that potentially includes retrieving many related notes.- Python
- TypeScript
main.py