Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions dimos/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,22 +889,5 @@ def _send_query(self, messages: list) -> Any:
logger.error(f"Unexpected error in API call: {e}")
raise

def stream_query(self, query_text: str) -> Observable:
"""Creates an observable that processes a text query and emits the response.

This method provides a simple way to send a text query and get an observable
stream of the response. It's designed for one-off queries rather than
continuous processing of input streams.

Args:
query_text (str): The query text to process.

Returns:
Observable: An observable that emits the response as a string.
"""
return create(
lambda observer, _: self._observable_query(observer, incoming_query=query_text)
)


# endregion OpenAIAgent Subclass (OpenAI-Specific Implementation)
28 changes: 0 additions & 28 deletions dimos/agents/agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,3 @@ def __init__(self, agents: list[Agent] | None = None) -> None:
agents (List[Agent], optional): List of Agent instances. Defaults to empty list.
"""
self.agents = agents if agents is not None else []

def add_agent(self, agent: Agent) -> None:
"""
Add an agent to the configuration.

Args:
agent (Agent): Agent instance to add
"""
self.agents.append(agent)

def remove_agent(self, agent: Agent) -> None:
"""
Remove an agent from the configuration.

Args:
agent (Agent): Agent instance to remove
"""
if agent in self.agents:
self.agents.remove(agent)

def get_agents(self) -> list[Agent]:
"""
Get the list of configured agents.

Returns:
List[Agent]: List of configured agents
"""
return self.agents
25 changes: 0 additions & 25 deletions dimos/agents/agent_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import time

from dimos.agents.agent_types import AgentImage
from dimos.msgs.sensor_msgs.Image import Image


@dataclass
Expand All @@ -42,22 +41,6 @@ def add_text(self, text: str) -> None:
if text: # Only add non-empty text
self.messages.append(text)

def add_image(self, image: Image | AgentImage) -> None:
"""Add an image. Converts Image to AgentImage if needed."""
if isinstance(image, Image):
# Convert to AgentImage
agent_image = AgentImage(
base64_jpeg=image.agent_encode(),
width=image.width,
height=image.height,
metadata={"format": image.format.value, "frame_id": image.frame_id},
)
self.images.append(agent_image)
elif isinstance(image, AgentImage):
self.images.append(image)
else:
raise TypeError(f"Expected Image or AgentImage, got {type(image)}")

def has_text(self) -> bool:
"""Check if message contains text."""
# Check if we have any non-empty messages
Expand All @@ -71,14 +54,6 @@ def is_multimodal(self) -> bool:
"""Check if message contains both text and images."""
return self.has_text() and self.has_images()

def get_primary_text(self) -> str | None:
"""Get the first text message, if any."""
return self.messages[0] if self.messages else None

def get_primary_image(self) -> AgentImage | None:
"""Get the first image, if any."""
return self.images[0] if self.images else None

def get_combined_text(self) -> str:
"""Get all text messages combined into a single string."""
# Filter out any empty strings and join
Expand Down
36 changes: 0 additions & 36 deletions dimos/agents/agent_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,42 +185,6 @@ def add_tool_result(self, tool_call_id: str, content: str, name: str | None = No
)
self._trim()

def add_raw_message(self, message: dict[str, Any]) -> None:
"""Add a raw message dict to history.

Args:
message: Message dict with role and content
"""
with self._lock:
# Extract fields from raw message
role = message.get("role", "user")
content = message.get("content", "")

# Handle tool calls if present
tool_calls = None
if "tool_calls" in message:
tool_calls = [
ToolCall(
id=tc["id"],
name=tc["function"]["name"],
arguments=json.loads(tc["function"]["arguments"])
if isinstance(tc["function"]["arguments"], str)
else tc["function"]["arguments"],
status="completed",
)
for tc in message["tool_calls"]
]

# Handle tool_call_id for tool responses
tool_call_id = message.get("tool_call_id")

self._messages.append(
ConversationMessage(
role=role, content=content, tool_calls=tool_calls, tool_call_id=tool_call_id
)
)
self._trim()

def to_openai_format(self) -> list[dict[str, Any]]:
"""Export history in OpenAI format.

Expand Down
9 changes: 0 additions & 9 deletions dimos/agents/memory/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ def query(self, query_texts, n_results: int = 4, similarity_threshold=None):
ConnectionError: If database connection fails during query.
"""

## Update ##
@abstractmethod
def update_vector(self, vector_id, new_vector_data):
"""Update an existing vector in the database.
Args:
vector_id (any): The identifier of the vector to update.
new_vector_data (any): The new data to replace the existing vector data.
"""

## Delete ##
@abstractmethod
def delete_vector(self, vector_id):
Expand Down
56 changes: 0 additions & 56 deletions dimos/agents/memory/chroma_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from collections.abc import Sequence
import os

from langchain_chroma import Chroma
from langchain_openai import OpenAIEmbeddings
import torch

from dimos.agents.memory.base import AbstractAgentSemanticMemory

Expand Down Expand Up @@ -71,10 +69,6 @@ def query(self, query_texts, n_results: int = 4, similarity_threshold=None):
documents = self.db_connection.similarity_search(query=query_texts, k=n_results)
return [(doc, None) for doc in documents]

def update_vector(self, vector_id, new_vector_data):
# TODO
return super().connect()

def delete_vector(self, vector_id):
"""Delete a vector from the ChromaDB using its identifier."""
if not self.db_connection:
Expand Down Expand Up @@ -122,53 +116,3 @@ def create(self):
embedding_function=self.embeddings,
collection_metadata={"hnsw:space": "cosine"},
)


class LocalSemanticMemory(ChromaAgentSemanticMemory):
"""Semantic memory implementation using local models."""

def __init__(
self,
collection_name: str = "my_collection",
model_name: str = "sentence-transformers/all-MiniLM-L6-v2",
) -> None:
"""Initialize the local semantic memory using SentenceTransformer.

Args:
collection_name (str): Name of the Chroma collection
model_name (str): Embeddings model
"""

self.model_name = model_name
super().__init__(collection_name=collection_name)

def create(self) -> None:
"""Create local embedding model and initialize the ChromaDB client."""
# Load the sentence transformer model
# Use CUDA if available, otherwise fall back to CPU
device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"Using device: {device}")
self.model = SentenceTransformer(self.model_name, device=device)

# Create a custom embedding class that implements the embed_query method
class SentenceTransformerEmbeddings:
def __init__(self, model) -> None:
self.model = model

def embed_query(self, text: str):
"""Embed a single query text."""
return self.model.encode(text, normalize_embeddings=True).tolist()

def embed_documents(self, texts: Sequence[str]):
"""Embed multiple documents/texts."""
return self.model.encode(texts, normalize_embeddings=True).tolist()

# Create an instance of our custom embeddings class
self.embeddings = SentenceTransformerEmbeddings(self.model)

# Create the database
self.db_connection = Chroma(
collection_name=self.collection_name,
embedding_function=self.embeddings,
collection_metadata={"hnsw:space": "cosine"},
)
12 changes: 0 additions & 12 deletions dimos/agents/memory/visual_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,6 @@ def get(self, image_id: str) -> np.ndarray | None:
logger.warning(f"Failed to decode image for ID {image_id}: {e!s}")
return None

def contains(self, image_id: str) -> bool:
"""
Check if an image ID exists in visual memory.

Args:
image_id: Unique identifier for the image

Returns:
True if the image exists, False otherwise
"""
return image_id in self.images

def count(self) -> int:
"""
Get the number of images in visual memory.
Expand Down
41 changes: 0 additions & 41 deletions dimos/agents/modules/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Base agent module that wraps BaseAgent for DimOS module usage."""

import threading
from typing import Any

from dimos.agents.agent_message import AgentMessage
from dimos.agents.agent_types import AgentResponse
Expand Down Expand Up @@ -147,13 +146,6 @@ def stop(self) -> None:
logger.info("Agent module stopped")
super().stop()

@rpc
def clear_history(self) -> None:
"""Clear conversation history."""
with self._history_lock:
self.history = []
logger.info("Conversation history cleared")

@rpc
def add_skill(self, skill: AbstractSkill) -> None:
"""Add a skill to the agent."""
Expand All @@ -166,12 +158,6 @@ def set_system_prompt(self, prompt: str) -> None:
self.system_prompt = prompt
logger.info("System prompt updated")

@rpc
def get_conversation_history(self) -> list[dict[str, Any]]:
"""Get current conversation history."""
with self._history_lock:
return self.history.copy()

def _handle_agent_message(self, message: AgentMessage) -> None:
"""Handle AgentMessage from module input."""
# Process through BaseAgent query method
Expand All @@ -182,30 +168,3 @@ def _handle_agent_message(self, message: AgentMessage) -> None:
except Exception as e:
logger.error(f"Agent message processing error: {e}")
self.response_subject.on_error(e)

def _handle_module_query(self, query: str) -> None:
"""Handle legacy query from module input."""
# For simple text queries, just convert to AgentMessage
agent_msg = AgentMessage()
agent_msg.add_text(query)

# Process through unified handler
self._handle_agent_message(agent_msg)

def _update_latest_data(self, data: dict[str, Any]) -> None:
"""Update latest data context."""
with self._data_lock:
self._latest_data = data

def _update_latest_image(self, img: Any) -> None:
"""Update latest image."""
with self._image_lock:
self._latest_image = img

def _format_data_context(self, data: dict[str, Any]) -> str:
"""Format data dictionary as context string."""
# Simple formatting - can be customized
parts = []
for key, value in data.items():
parts.append(f"{key}: {value}")
return "\n".join(parts)
21 changes: 0 additions & 21 deletions dimos/agents/modules/gateway/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from types import TracebackType
from typing import Any

import httpx
from tenacity import retry, stop_after_attempt, wait_exponential

from .tensorzero_embedded import TensorZeroEmbeddedGateway
Expand Down Expand Up @@ -61,26 +60,6 @@ def __init__(
logger.error(f"Failed to initialize TensorZero: {e}")
raise

def _get_client(self) -> httpx.Client:
"""Get or create sync HTTP client."""
if self._client is None:
self._client = httpx.Client(
base_url=self.gateway_url,
timeout=self.timeout,
headers={"Content-Type": "application/json"},
)
return self._client

def _get_async_client(self) -> httpx.AsyncClient:
"""Get or create async HTTP client."""
if self._async_client is None:
self._async_client = httpx.AsyncClient(
base_url=self.gateway_url,
timeout=self.timeout,
headers={"Content-Type": "application/json"},
)
return self._async_client

@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))
def inference(
self,
Expand Down
Loading
Loading