A Python library for interacting with LLMs (Large Language Models) and function calling capabilities.
- Integration with OpenAI-compatible LLM APIs, especially llama-3.3
- Function registration and tool calling system
- Optimization of the tool calling process with the selection of the relevant top N functions to be fed into the LLM prompt
- Support for conversation history and recursive function calls
- Python 3.10+
- OpenAI API key
- Moralis API key
Create a .env file in the root directory and add your API keys. Look at the .env.example file for reference.
chat.py: Main file for the chat interface based on gradiollm.py: File for the Generic Tool Calling LLM class that enables tool registration and tool callingtools.py: File for theTool Managerclass that stores tool embeddings and select the top N tools to be fed into the LLM prompt related to the user queryfunctions.py: File for the definition of the functions available for the LLM to call. It contains the actual functions that interact with the Moralis Solana APIapp.py: File for the initialization of the tool calling LLM and its integration with the Moralis Solana APIrequirements.txt: File for the dependencies.env.example: Reference file to create the.envfile for the environment variablesREADME.md: This file.
pip install -r requirements.txtpython chat.pyThis will start the chat interface. Copy the URL of the interface and paste it in your browser (e.g., http://127.0.0.1:7860).
Look at functions.py to formulate your queries based on the list of available functions.
Sample queries:
- "What is the balance of the account [account_address] on mainnet?"
- "What is the balance of the account [account_address]?" (Default network is mainnet)
- "What is the token price of [token_address]?"
- "I want to know the global token metadata for the contract [contract_address]"
- "What are the latest news on [topic]?" (Should not call any function)
Note: You can take a look at the terminal output to see the tool selection process (similarity scores, top N functions), tool calls, message history, raw outputs, etc.
The focus is now on tool calling, the integration with the Moralis Solana API has just started.