Welcome to MultiverseNote! This guide will walk you through the updated steps for setting up and running the project, along with configuration details for customization. The setup process has been streamlined to use uv for management, simplifying the workflow.
Before starting, ensure you have the following installed on your system:
- Python 3.8+: Required for running the backend and management scripts.
The project is managed with uv, which handles all configurations and dependencies. To install uv, run:
pip install uvAfter installing uv, use it to set up the project. Navigate to the project directory and run:
uv syncThis command will download and configure all necessary dependencies and files.
Once synchronization is complete, activate the virtual environment that uv sync creates. Depending on your system type, use the following command:
- Linux/macOS:
source .venv/bin/activate - Windows:
.venv\Scripts\activate
For more information, refer to the Python venv Documentation.
After activating the virtual environment, start the project by running:
python main.pyThis will launch the backend and initialize the application.
MultiverseNote allows customization through configuration files and modular components. Follow these steps to update configurations and extend functionality:
Configurations are stored in the storage/config directory. To update or customize settings:
- Navigate to
storage/config. - Open the desired configuration file (e.g.,
main_config.yamlby default) for editing. - Modify the configuration as needed.
control:
bot:
api_key: # Enter the API key for your bot service.
name: OpenAI # Name of the bot (e.g., OpenAI).
tools:
- searchOnlineTool # List of tool names available for the bot to use.
dao:
db:
activate: false # Set to true if using a database; false otherwise.
db_name: storage/db/db.sqlite # Path to the database file.
db_type: sqlite # Type of database (e.g., sqlite, postgres, etc.).
db_url: null # Database URL (if applicable).
password: null # Database password (if applicable).
user: null # Database username (if applicable).
file:
activate: false # Set to true if using file-based storage.
file_path: storage/file # Path to the file storage location.
runtime:
agent_path: storage/agent # Directory where agent configurations are stored.
current_session_id: # Leave empty for runtime-generated session IDs.
history_path: storage/history # Path to store conversation history.
view:
flask:
activate: true # Enable Flask server.
debug: true # Enable debugging mode for development.
host: localhost # Host address for the Flask server.
port: 5000 # Port for the Flask server.
taipy:
activate: false # Enable Taipy-based frontend (set to true if using).To add a custom agent, follow these steps:
-
Place Your Agent's File in the
storage/agentDirectory:- Add the agent's configuration file to the
storage/agentdirectory. This file defines the behavior and responses of the agent.
- Add the agent's configuration file to the
-
Follow the Same Structure and Naming Conventions as Existing Agent Files:
- Consistency is key. Use the same naming conventions and file structure as the existing agents in the directory. This helps maintain uniformity and ensures that the application can properly identify and load agents.
-
Restart the Application to Load the New Agent:
- After adding your agent, restart the application so that the new agent is recognized and available for use.
name: base # The name of the agent.
args:
- query # Arguments required by the agent (e.g., the input 'query' for conversation).
prompt: >
## Participant Profile
**Name:** KK
**Role:** A helpful assistant.
## Dialogue with USER
While the person asking the question is busy with work, keep the reply concise. KK engages USER in conversation. USER begins by saying: "{query}"Explanation:
name: This is the unique identifier for the agent (e.g., "base"). It helps differentiate between different agents.args: Lists the arguments that the agent expects. Here, it includes "query", which represents the user's input.prompt: Defines the structure of the agent's response.{}(curly braces) are used to insert dynamic content. For instance,{query}will be replaced with the actual user query.- This prompt helps set the tone and behavior of the agent during a conversation, guiding how it should respond based on the user's input.
To integrate new tools into the application, you need to create a new tool file and follow specific guidelines. Each tool must include a function definition, input arguments, a mapping dictionary, and adhere to the OpenAI function calling definition.
-
Navigate to the
app/toolsdirectory: This is where all tool files are stored. -
Add Your Tool File: Create a new Python file for your tool in this directory.
-
Define the Tool Function: Each tool must be implemented as a function. For example:
def fetch_web_page(url): """Fetches and returns the content of a web page.""" try: response = requests.get(url) response.raise_for_status() return response.text except requests.RequestException as e: return "Failed to access: " + str(e)
-
Specify Input Arguments: Define the function input arguments clearly, as they will be used by the OpenAI function calling system.
-
Map the Function to a Dictionary: Use a mapping dictionary to connect the function name to its implementation. For example:
FUNCTION_MAPPING = { "fetch_web_page": fetch_web_page, # Map function name to its implementation. }
-
Define the Tool in
TOOLS_DEFINE: Use the OpenAI function calling format to define the tool. This includes specifying the function's name, description, and input parameters. For example:TOOLS_DEFINE = [ { "type": "function", "function": { "name": "fetch_web_page", "description": "Fetches and returns the content of a web page.", "parameters": { "type": "object", "properties": { "url": { "type": "string", "description": "The URL of the web page to fetch." } }, "required": ["url"] } } } ]
-
Follow Existing Patterns: Refer to other files in the
app/toolsdirectory for guidance and ensure consistency.
For more details on OpenAI function calling definitions, see the OpenAI Documentation.
import requests
def fetch_web_page(url):
"""Fetches and returns the content of a web page."""
try:
response = requests.get(url)
response.raise_for_status() # Raise an error for non-200 responses.
return response.text
except requests.RequestException as e:
return "Failed to access: " + str(e)
def search_duckduckgo(query):
"""Use the DuckDuckGo Instant Answer API to search for a query and return a structured JSON response."""
url = "https://api.duckduckgo.com/"
params = {
'q': query, # The search query text.
'format': 'json', # Response format in JSON.
'no_html': 1, # Remove HTML from responses.
'skip_disambig': 1 # Skip disambiguation pages.
}
try:
response = requests.get(url, params=params)
response.raise_for_status()
data = response.json()
return data # Return raw JSON data from DuckDuckGo API.
except requests.RequestException as e:
return {"error": str(e)}
FUNCTION_MAPPING = {
"fetch_web_page": fetch_web_page, # Map function name to its implementation.
"search_duckduckgo": search_duckduckgo, # Another mapped function.
}
TOOLS_DEFINE = [
{
"type": "function",
"function": {
"name": "fetch_web_page",
"description": "Fetches and returns the content of a web page.",
"parameters": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "The URL of the web page to fetch."
}
},
"required": ["url"]
}
}
},
{
"type": "function",
"function": {
"name": "search_duckduckgo",
"description": "Simulates a simple DuckDuck Go search and returns the first result URL.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query to look up on DuckDuckGo."
}
},
"required": ["query"]
}
}
}
]Once your configurations and customizations are complete, you can:
- Explore Features: Test the tools and agents you've added.
- Contribute: Check the GitHub repository for open issues and tasks.
- Collaborate: Join community discussions to share ideas and receive feedback.
If you encounter any issues:
- Verify Python 3.8+ is installed and working correctly.
- Ensure
uv syncwas run successfully without errors. - Double-check the file structure and naming conventions in the configuration, agent, and tools directories.
- Consult terminal logs for detailed error messages.
- Raise an issue on the GitHub repository or contact project maintainers for support.
Thank you for contributing to MultiverseNote! Your contributions help expand and improve this project. For further assistance, contact us or refer to the documentation.
Happy coding! 🚀