### Configure Elysia Global Models with OpenAI Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md Sets the default base and complex language models for all Elysia functions using OpenAI. Requires specifying model names, providers, and an OpenAI API key. ```python from elysia import configure configure( base_model="gpt-4.1-mini", base_provider="openai", complex_model="gpt-4.1", complex_provider="openai", openai_api_key="..." # replace with your API key ) ``` -------------------------------- ### Create and Use Elysia Settings Object Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md Demonstrates creating a custom Settings object for Elysia and passing it to a Tree instance. This allows for isolated settings management, overriding global configurations. ```python from elysia import Settings, Tree my_settings = Settings() tree = Tree(settings=my_settings) ``` -------------------------------- ### Configure Elysia for Weaviate Cloud Connection Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md Sets up Elysia to connect to a Weaviate cloud instance using environment variables or the configure function. Requires WCD_URL and WCD_API_KEY. ```python from elysia import configure configure( wcd_url=..., # replace with your WCD_URL wcd_api_key=... # replace with your WCD_API_KEY ) ``` ```shell WCD_URL=... # replace with your WCD_URL WCD_API_KEY=... # replace with your WCD_API_KEY ``` -------------------------------- ### Preprocess Weaviate Collections with Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md Prepares a Weaviate collection for use with Elysia's built-in tools by generating summaries, creating field mappings, calculating statistics, and collecting metadata. This function must be called before using the collection with Elysia. ```python from elysia import preprocess preprocess("") ``` -------------------------------- ### Configure Elysia for Custom Weaviate Connections Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md Allows manual configuration of REST and GRPC endpoints for a Weaviate connection. Set WEAVIATE_IS_CUSTOM to True and specify host, port, and security settings for both HTTP and GRPC. ```shell WEAVIATE_IS_CUSTOM=True CUSTOM_HTTP_HOST=your.weaviate.host CUSTOM_HTTP_PORT=443 # 443 = default for Weaviate cloud CUSTOM_HTTP_SECURE=True CUSTOM_GRPC_HOST=your.weaviate.host CUSTOM_GRPC_PORT=443 # 443 = default for Weaviate cloud CUSTOM_GRPC_SECURE=True WCD_API_KEY= # if you require an API key, set it under WCD_API_KEY ``` ```python from elysia import configure configure( weaviate_is_custom=True, custom_http_host="...", # replace with your HTTP host custom_http_port=443, custom_http_secure=True, custom_grpc_host="...", # replace with your GRPC host custom_grpc_port=443, custom_grpc_secure=True, wcd_api_key="..." # replace with your API key (optional, depends on your weaviate config) ) ``` -------------------------------- ### Configure Elysia for Local Weaviate Connection Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md Enables Elysia to connect to a local Weaviate instance, typically run via Docker. Configuration can be done via a .env file or the configure function, setting WEAVIATE_IS_LOCAL to True and specifying connection details. ```shell WEAVIATE_IS_LOCAL=True WCD_URL=localhost # or http://localhost:8080 LOCAL_WEAVIATE_PORT=8080 # optional override LOCAL_WEAVIATE_GRPC_PORT=50051 # optional override WCD_API_KEY= ``` ```python from elysia import configure configure( weaviate_is_local=True, wcd_url="http://localhost:8080", # or "localhost" local_weaviate_port=8080, local_weaviate_grpc_port=50051, ) ``` -------------------------------- ### Start Elysia Application Source: https://github.com/weaviate/elysia/blob/main/docs/index.md Illustrates the command to start the Elysia application. The `--port` option can be used to specify a custom port, with 8000 as the default. ```bash elysia start # Optionally: elysia start --port 9000 ``` -------------------------------- ### Install Elysia from Source with Dev Extra Source: https://github.com/weaviate/elysia/blob/main/CONTRIBUTING.md Installs the Elysia project from local source code, including the development extra. This is useful when working directly with the project's source files. ```bash pip install ".[dev]" ``` -------------------------------- ### Start Elysia REST API Server Source: https://context7.com/weaviate/elysia/llms.txt Instructions for starting the Elysia REST API server using the command line. This allows interaction with Elysia services via HTTP requests. ```bash # Start the Elysia server elysia start --port 8000 ``` -------------------------------- ### Install Elysia Dev Extra Source: https://github.com/weaviate/elysia/blob/main/CONTRIBUTING.md Installs the development extra for Elysia, which includes necessary dependencies for testing and development. This command uses pip to install from the Python Package Index. ```bash pip install "elysia-ai[dev]" ``` -------------------------------- ### Disable Reasoning for Elysia Models Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md Disables chain-of-thought prompting for Elysia's base and complex models to potentially improve performance, though it may reduce accuracy. Use with caution. ```python settings.configure( base_use_reasoning=False, complex_use_reasoning=False ) ``` -------------------------------- ### Configure Elysia Models and API Keys Source: https://github.com/weaviate/elysia/blob/main/docs/basic.md Sets up the necessary language models and API keys for Elysia to interact with Weaviate and other services. It requires specifying base and complex models, their providers, and API credentials. This leverages LiteLLM for model compatibility. ```python from elysia import configure configure( base_model="gpt-4o-mini", base_provider="openai", complex_model="gpt-4o", complex_provider="openai", openai_api_key="sk-...", # replace with your API key wcd_url="...", # replace with your weaviate cloud url wcd_api_key="..." # replace with your weaviate cloud api key ) ``` -------------------------------- ### Install Elysia AI Package Source: https://github.com/weaviate/elysia/blob/main/docs/index.md Provides the command to install the Elysia AI Python package using pip. This is a prerequisite for using Elysia in a Python environment. ```bash pip install elysia-ai ``` -------------------------------- ### Download Example Dataset (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/query_weaviate.md Downloads a small JSON dataset of Jeopardy questions and answers from a GitHub repository using the `requests` library. This data is used for populating a Weaviate collection. ```python import requests, json url = "https://raw.githubusercontent.com/weaviate/weaviate-examples/main/jeopardy_small_dataset/jeopardy_tiny.json" resp = requests.get(url) data = json.loads(resp.text) ``` -------------------------------- ### Install scikit-learn Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/data_analysis.md Installs the scikit-learn library, which is required for fitting the linear regression model. This is a prerequisite for using the `fit_linear_regression` tool. ```bash pip install -U scikit-learn ``` -------------------------------- ### Start Elysia Application Source: https://github.com/weaviate/elysia/blob/main/README.md Launches the Elysia application. After running this command, the application will be accessible at localhost:8000. You can optionally specify a different port using the --port argument. ```bash elysia start # Optionally specify a port: # elysia start --port 9000 ``` -------------------------------- ### Preprocess Weaviate Collection for Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/basic.md Prepares a specified Weaviate collection to be accessible and understood by Elysia's AI models. This step ensures that the models are aware of the collection's schema and data structure. ```python from elysia import preprocess preprocess("Tickets") ``` -------------------------------- ### Python Environment Structure Example Source: https://github.com/weaviate/elysia/blob/main/docs/Advanced/environment.md Demonstrates the typical structure of the Elysia environment after executing 'query' and 'aggregate' tools. It shows how results are nested under tool names and result names, containing lists of objects and their associated metadata. ```python { "query": { "message_result": [ { "objects": [ {"message_id": 1, "message_content": "Hi this is an example message about frogs!"}, {"message_id": 2, "message_content": "Hi this is also an example message about reindeer!"}, ], "metadata": { "collection_name": "example_email_messages_collection", "query_search_term": "animals" } }, ] }, "aggregate": { "pet_food_result": [ { "objects": [ { "average_price": 45.99, "product_count": 150, } ], "metadata": { "collection_name": "pet_food", "group_by": {"field": "animal", "value": "frog"} } } ] } } ``` -------------------------------- ### Install Elysia from GitHub with Editable Mode Source: https://github.com/weaviate/elysia/blob/main/README.md Installs the Elysia package directly from its GitHub repository in editable mode. This is useful for development purposes, allowing changes in the cloned repository to be reflected immediately. It requires cloning the repository first and setting up a Python virtual environment. ```bash git clone https://github.com/weaviate/elysia cd elysia python3.12 -m venv .venv source .venv/bin/activate pip install -e . ``` -------------------------------- ### Interact with Weaviate Collections using Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/index.md Shows how to use the Elysia `Tree` to query Weaviate collections. It specifies collection names and retrieves data, utilizing pre-built query or aggregate tools. Requires Weaviate integration setup. ```python from elysia import Tree tree = Tree() response, objects = tree( "What are the 10 most expensive items in the Ecommerce collection?", collection_names = ["Ecommerce"] ) ``` -------------------------------- ### Decision Agent Reasoning Example Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/query_weaviate.md This snippet shows the internal reasoning of the decision agent, explaining the steps taken to retrieve and present a Jeopardy question. It details the context, retrieved information, and the final action. ```text Decision: text_response Reasoning: I have already retrieved a science question from the JeopardyQuestion collection in the previous turn. The question is: "This organ removes excess glucose from the blood & stores it as glycogen". The answer is "Liver". I should now respond to the user with this question. ``` -------------------------------- ### Run Elysia Decision Tree for Data Query Source: https://github.com/weaviate/elysia/blob/main/docs/basic.md Initializes and runs the Elysia decision tree to process natural language queries against the preprocessed Weaviate collections. It returns the concatenated text responses from the models and any data objects retrieved during the query. ```python from elysia import Tree tree = Tree() response, objects = tree("what were the 10 most recent Github issues?") print(response) print(objects) ``` -------------------------------- ### Assistant's Text Response Example Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/query_weaviate.md This is an example of the assistant's final text response to the user, providing the science question that was retrieved. It's the user-facing output after the decision process. ```text Here's a science question for you: "This organ removes excess glucose from the blood & stores it as glycogen?" ``` -------------------------------- ### Configure LLM API Key (OpenRouter Example) Source: https://github.com/weaviate/elysia/blob/main/README.md Sets the API key for the chosen Large Language Model (LLM) provider. The example uses OpenRouter, which provides access to various models. This key is used for LLM interactions within Elysia. ```env OPENROUTER_API_KEY=... ``` -------------------------------- ### Initialize Elysia Decision Tree Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/query_weaviate.md Creates a new Elysia Tree instance. This is the basic step to start using the decision tree functionality. The default parameters will work automatically if models and Weaviate integrations are set up. ```python from elysia import Tree tree = Tree() ``` -------------------------------- ### Elysia Python Usage with Weaviate Integration Source: https://github.com/weaviate/elysia/blob/main/README.md Shows how to use Elysia with Weaviate by initializing the Tree and querying a Weaviate collection. This example uses the built-in query or aggregate tools to interact with the 'Ecommerce' collection. ```python import elysia tree = elysia.Tree() response, objects = tree( "What are the 10 most expensive items in the Ecommerce collection?", collection_names = ["Ecommerce"] ) ``` -------------------------------- ### Clone Elysia Repository and Create Branch (Bash) Source: https://github.com/weaviate/elysia/blob/main/README.md Provides the bash commands to clone the Elysia GitHub repository and create a new branch for contributing. This is the starting point for making code contributions to the project. ```bash git clone https://github.com/weaviate/elysia git checkout -b ``` -------------------------------- ### Define and Add a Simple Async Tool in Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/creating_tools.md This snippet demonstrates how to define a basic asynchronous tool using the `@tool` decorator in Elysia and subsequently add it to an Elysia `Tree`. The function's docstring serves as its description, and type hints guide the LLM. The tool is added to the root of the tree. ```python from elysia import tool @tool async def add(x: int, y: int) -> int: """ Return the sum of two numbers. """ return x + y from elysia import Tree tree = Tree() tree.add_tool(add) response, objects = tree("What is 1238213 + 1238213?") print(response) ``` -------------------------------- ### Elysia Tool: Basic Text Response Implementation with DSPy Source: https://github.com/weaviate/elysia/blob/main/docs/Advanced/advanced_tool_construction.md An example of a basic `TextResponse` tool in Elysia that utilizes DSPy for generating a final text response. It initializes a `Tool` with specific properties and its `__call__` method employs `ElysiaChainOfThought` to process `tree_data` and generate a response using a language model. ```python import dspy from elysia.objects import Response, Tool from elysia.tree.objects import TreeData from elysia.util.client import ClientManager from elysia.tools.text.prompt_templates import TextResponsePrompt from elysia.util.elysia_chain_of_thought import ElysiaChainOfThought class TextResponse(Tool): def __init__(self, **kwargs): super().__init__( name="final_text_response", description="", status="Writing response...", inputs={}, end=True, ) async def __call__( self, tree_data: TreeData, inputs: dict, base_lm: dspy.LM, complex_lm: dspy.LM, client_manager: ClientManager | None = None, **kwargs ): text_response = ElysiaChainOfThought( TextResponsePrompt, tree_data=tree_data, environment=True, tasks_completed=True, message_update=False, ) output = await text_response.aforward( lm=base_lm, ) yield Response(text=output.response) ``` -------------------------------- ### Edit Preprocessed Collection Metadata in Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md The `edit_preprocessed_collection` function allows manual updates to the metadata of a preprocessed collection. You can modify fields such as `named_vectors`, `summary`, `mappings`, and `fields`. Any fields not provided in the function call will remain unchanged, offering granular control over updates. ```python from elysia import edit_preprocessed_collection properties = edit_preprocessed_collection( collection_name = ..., named_vectors = ..., summary = ..., mappings = ..., fields = ... ) ``` -------------------------------- ### Check if Preprocessed Collection Exists in Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md The `preprocessed_collection_exists` function checks if a given collection has already been preprocessed within the Weaviate cluster. It takes the collection name as input and returns a boolean value indicating its status. This is useful for avoiding redundant preprocessing operations. ```python from elysia import preprocessed_collection_exists preprocessed_collection_exists(collection_name = ...) ``` -------------------------------- ### Delete Preprocessed Collection Metadata in Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/setting_up.md The `delete_preprocessed_collection` function removes the cached preprocessed metadata for a specified collection from the Weaviate cluster. This operation does not affect the original collection. Rerunning the preprocess function is necessary for the Weaviate integration to utilize the original collection's data again. ```python delete_preprocessed_collection(collection_name = ...) ``` -------------------------------- ### Initialize Elysia Tree and Add BasicLinearRegression Tool Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/old_data_analysis.md This Python code initializes an Elysia Tree, adds the BasicLinearRegression tool, and then executes a query to perform linear regression. It demonstrates how to set up and utilize tools within the Elysia framework for specific analytical tasks. ```python from elysia import Tree tree = Tree() tree.add_tool(BasicLinearRegression) response, objects = tree( "Perform linear regression on the relationship between the price of a product and the review rating it has", collection_names = ["Ecommerce"] ) ``` -------------------------------- ### Get Available API Collections Source: https://context7.com/weaviate/elysia/llms.txt This snippet shows how to retrieve a list of available collections from the API using a GET request. It requires the user ID as a query parameter. ```bash curl -X GET "http://localhost:8000/api/collections?user_id=user-123" ``` -------------------------------- ### Example Jeopardy Question Retrieval Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/query_weaviate.md This example illustrates a scenario where the model retrieves a science question from the 'JeopardyQuestion' collection in Weaviate. It highlights the use of filtering by category and retrieving a single question. ```json [ { 'category': 'SCIENCE', 'question': 'This organ removes excess glucose from the blood & stores it as glycogen', 'answer': 'Liver', 'uuid': 'b28ca48a-9a8d-417c-9ed1-e487132740ed', 'collection_name': 'JeopardyQuestion', 'chunk_spans': [], '_REF_ID': 'query_JeopardyQuestion_0_0' } ] ``` -------------------------------- ### Initialize Tool Call and Extract Inputs (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/old_data_analysis.md Sets up the tool call by defining the __call__ method and extracting necessary inputs such as environment data, input keys, and variable fields from the provided arguments. It prepares the stage for subsequent data processing steps. ```python async def __call__( self, tree_data, inputs, base_lm, complex_lm, client_manager, **kwargs, ): environment = tree_data.environment.environment environment_key = inputs["environment_key"] x_variable_field = inputs["x_variable_field"] y_variable_field = inputs["y_variable_field"] ``` -------------------------------- ### Get API Conversation History Source: https://context7.com/weaviate/elysia/llms.txt This snippet demonstrates how to fetch the conversation history using a GET request. It requires both the user ID and the specific conversation ID as query parameters to retrieve relevant past interactions. ```bash curl -X GET "http://localhost:8000/api/conversations?user_id=user-123&conversation_id=conv-456" ``` -------------------------------- ### Define Elysia Tool with Assigned Inputs and Default Arguments Source: https://github.com/weaviate/elysia/blob/main/docs/creating_tools.md This code demonstrates an Elysia tool that accepts a list of numbers and an operation type, with a default operation. The function signature includes type hints and a default value for `operation`, enabling the LLM to select inputs and handle optional parameters. The tool description specifies input constraints. ```python from elysia import tool from math import prod @tool async def perform_mathematical_operations(numbers: list[int | float], operation: str = "sum"): """ This function calculates a mathematical operation on the `numbers` list. The `numbers` input must be a list of integers or floats. The `operation` input must be one of: "sum" or "product". These are the only options. """ if operation == "sum": yield sum(numbers) elif operation == "product": yield prod(numbers) yield f"I just performed a {operation} on {numbers}." ``` -------------------------------- ### Configuration Management for Elysia Source: https://context7.com/weaviate/elysia/llms.txt Configure Elysia settings globally using `configure` or per-tree instance using `tree.configure`. It supports setting base and complex models, API keys, Weaviate URLs, and logging levels. `smart_setup` can auto-detect available models and keys. Access current settings via the `settings` object. Requires the 'elysia' library. ```python from elysia import configure, settings, Settings, smart_setup # Global configuration configure( base_model="gpt-4o-mini", base_provider="openai", complex_model="gpt-4o", complex_provider="openai", openai_api_key="sk-...". wcd_url="https://cluster.weaviate.network", wcd_api_key="weaviate-key", weaviate_is_local=False, base_use_reasoning=True, logging_level="INFO" ) # Smart setup (auto-detect available models and keys) smart_setup() # Per-tree configuration tree = Tree() tree.configure( base_model="claude-3-5-haiku-20241022", base_provider="anthropic", anthropic_api_key="sk-ant-..." ) # Access current settings print(f"Base model: {settings.BASE_MODEL}") print(f"Complex model: {settings.COMPLEX_MODEL}") print(f"Weaviate URL: {settings.WCD_URL}") ``` -------------------------------- ### Configure and Test Elysia with Local Model (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Advanced/local_models.md This Python code configures Elysia's settings to connect to a local Ollama instance and then tests the direct connection to the base language model. This helps verify Elysia's integration with the model. It requires the 'elysia' package and assumes a running Ollama instance. Inputs are settings and a simple prompt; outputs are diagnostic print statements. ```python from elysia import Tree, Settings settings = Settings() settings.configure( base_model="gemma3:4b", # or whichever model you are using complex_model="gemma3:4b", # or whichever model you are using base_provider="ollama", complex_provider="ollama", model_api_base="http://localhost:11434", # or wherever your Ollama instance is ) tree = Tree(settings=settings) print(tree.base_lm("hi")) # should be a generic response without using elysia ``` -------------------------------- ### GET /api/conversations Source: https://context7.com/weaviate/elysia/llms.txt Retrieves the conversation history for a specific user and conversation. ```APIDOC ## GET /api/conversations ### Description Retrieves the conversation history for a specific user and conversation. ### Method GET ### Endpoint /api/conversations ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user. - **conversation_id** (string) - Required - The ID of the conversation. ### Response #### Success Response (200) - **history** (array of objects) - A list of messages in the conversation history. ``` -------------------------------- ### BasicLinearRegression Tool Initialization (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/old_data_analysis.md This Python snippet details the initialization of the BasicLinearRegression tool. It configures the tool's name, a descriptive text, status message, and defines the required input parameters including environment key, independent variables (x_variable_fields), and the dependent variable (y_variable_field), along with their types and descriptions. ```python def __init__(self, logger, **kwargs): super().__init__( name="basic_linear_regression_tool", description=""" Use this tool to perform linear regression on objects in the environment with numeric data types. """, status="Running linear regression...", inputs={ "environment_key": { "description": ( "A single key (string) of the `environment` dictionary that will be used in the analysis. " "Choose the most relevant key for the analysis according to the user prompt. " "All objects under that key will be used to create the dataframe. " ), "required": True, "type": str, "default": None, }, "x_variable_fields": { "description": ( "The independent variables for the regression. " "Choose one or more fields within the `objects` underneath the specific `environment_key`. " ), "required": True, "type": list[str], "default": None, }, "y_variable_field": { "description": ( "The dependent variable for the regression. " "Choose one single field within the `objects` underneath the specific `environment_key`. " ), "required": True, "type": str, "default": None, }, }, end=False, ) ``` -------------------------------- ### GET /api/collections Source: https://context7.com/weaviate/elysia/llms.txt Retrieves a list of available collections for a given user. ```APIDOC ## GET /api/collections ### Description Retrieves a list of available collections for a given user. ### Method GET ### Endpoint /api/collections ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user whose collections are to be retrieved. ### Response #### Success Response (200) - **collections** (array of strings) - A list of available collection names. ``` -------------------------------- ### Load scikit-learn Diabetes Dataset Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/data_analysis.md Loads the example diabetes dataset provided by scikit-learn. This data will be used for demonstrating the linear regression tool. ```python from sklearn import datasets data = datasets.load_diabetes() X, Y = data.data, data.target ``` -------------------------------- ### Define and Use a Custom Tool with Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/index.md Demonstrates how to define a custom asynchronous tool using the `@tool` decorator and then invoke it within an Elysia `Tree`. This requires the `elysia-ai` library and assumes necessary model configurations. ```python from elysia import tool, Tree tree = Tree() @tool(tree=tree) async def add(x: int, y: int) -> int: return x + y tree("What is the sum of 9009 and 6006?") ``` -------------------------------- ### Tool Initialization - Python Source: https://github.com/weaviate/elysia/blob/main/docs/Advanced/advanced_tool_construction.md Defines the constructor for a custom tool in Elysia. It accepts optional logger and keyword arguments, and calls the parent Tool class constructor with essential parameters like name, description, and optional status, inputs, and end flags. ```python def __init__(self, logger: Logger | None = None, **kwargs): super().__init__( name=..., description=..., status=..., # optional inputs=..., # optional end=..., # optional **kwargs # required ) ``` -------------------------------- ### Execute Augmented Module with aforward (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Advanced/advanced_tool_construction.md Shows how to use the .aforward() method of an augmented module initialized with ElysiaChainOfThought. Pass new inputs as keyword arguments; environment and user_prompt are automatically handled. The 'lm' parameter can be inherited or defined. ```python my_module.aforward(input1=..., input2=..., lm=...) ``` -------------------------------- ### Yield Error Object from Tool (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Advanced/advanced_tool_construction.md Provides an example of yielding an Elysia Error object from within a tool. This informs the decision tree and LLM calls about potential issues, allowing for self-healing mechanisms. ```python yield Error("Informative error message about the issue.") ``` -------------------------------- ### Initialize UserManager with Timeout Configurations Source: https://github.com/weaviate/elysia/blob/main/docs/API/user_and_tree_managers.md Demonstrates how to initialize the UserManager with specific timeout configurations for trees, users, and clients. These timeouts control inactivity periods before actions are taken. If not provided, default values from environment variables are used. A value of 0 disables the respective timeout. ```python from datetime import timedelta # Example using timedelta objects user_manager = UserManager(tree_timeout=timedelta(minutes=15), user_timeout=timedelta(minutes=30), client_timeout=timedelta(minutes=5)) # Example using integer minutes (will be converted to timedelta) user_manager_int = UserManager(tree_timeout=15, user_timeout=30, client_timeout=5) ``` -------------------------------- ### Configure Elysia for Weaviate and LLMs (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/query_weaviate.md Sets up Elysia with Weaviate connection details and language model configurations. It requires Weaviate URL, API key, and LLM model/provider details. It supports various LLM providers like Gemini and OpenAI. ```python from elysia import configure configure( weaviate_is_local = False, # replace with True if locally running Weaviate wcd_url = "...", # replace with your Weaviate REST endpoint URL wcd_api_key = "..." # replace with your Weaviate cluster API key, base_model = "gemini-2.0.flash-001", # replace with whichever model you are using base_provider = "gemini", # replace with your model provider or 'ollama' for locally running ollama models complex_model = "gemini-2.5.flash-001", complex_provider = "gemini", gemini_api_key = "..." # replace with your GEMINI_API_KEY from Google AI studio, or whichever API key you need for Weaviate/your LLMs ) ``` -------------------------------- ### Configure Elysia Source: https://github.com/weaviate/elysia/blob/main/docs/Examples/data_analysis.md Configures Elysia with model API keys and Weaviate connection details. This setup ensures that Elysia can authenticate with language models and Weaviate, and specifies the models to be used for different tasks. ```python configure( base_model="gemini-2.0-flash-001", # replace models and providers with which ever LM you want to use complex_model="gemini-2.0-flash-001", base_provider="openrouter/google", complex_provider="openrouter/google", wcd_url="...", # replace with your Weaviate REST endpoint URL wcd_api_key="...", # replace with your Weaviate cloud API key openrouter_api_key="...", # replace with whichever API key you will use for your LMs ) ``` -------------------------------- ### Initialize Elysia Tree with Custom Parameters Source: https://github.com/weaviate/elysia/blob/main/docs/advanced_usage.md Demonstrates initializing the Elysia Tree with custom style, agent description, and end goal parameters during tree creation. This allows for immediate customization of the tree's behavior and output. ```python from elysia import Tree tree = Tree( style = "...", agent_description = "...", end_goal = "..." ) ``` -------------------------------- ### Change Elysia Tree Style Source: https://github.com/weaviate/elysia/blob/main/docs/advanced_usage.md Shows how to modify the style of Elysia's text responses. This can be done either during initialization or by calling the `change_style` method on an existing tree object. The example demonstrates changing the style after the tree has been created. ```python tree = Tree() tree.change_style("Always speak in rhyming couplets.") response, _ = tree("Hi Elysia, how are you?") print(response) ``` -------------------------------- ### Initialize and Yield Result from Tool (Python) Source: https://github.com/weaviate/elysia/blob/main/docs/Advanced/environment.md Demonstrates yielding a Result object from a tool, which is then automatically processed and appended to the environment. It includes the structure of the Result object with its 'objects' and 'metadata' fields. ```Python yield Result( name="pet_food_result", objects = [ { "average_price": 12.52, "product_count": 33, } ], metadata = { "collection_name": "pet_food", "group_by": {"field": "animal", "value": "reindeer"} } ) ```