Skip to content

Commit

Permalink
Merge branch 'master' into tj202/PR_readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ThejasNU authored Jan 15, 2025
2 parents 0f2cc87 + 0fd86da commit 615ca92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
19 changes: 6 additions & 13 deletions libs/agentc_core/agentc_core/catalog/catalog/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def find(
"""Returns the catalog items that best match a query."""

# Catalog item has to be queried directly
if name is not None and snapshot is not None:
if name is not None:
if snapshot == LATEST_SNAPSHOT_VERSION:
snapshot = self.version.identifier
# TODO (GLENN): Need to add some validation around bucket (to prevent injection)
# TODO (GLENN): Need to add some validation around name (to prevent injection)
item_query = f"""
Expand All @@ -77,18 +79,6 @@ def find(
return []
query_embeddings = None

elif name is not None:
item_query = f"""
FROM `{self.bucket}`.`{DEFAULT_CATALOG_SCOPE}`.`{self.kind}_catalog` AS a
WHERE a.name = $name
SELECT a.*;
"""
res, err = execute_query_with_parameters(self.cluster, item_query, {"name": name})
if err is not None:
logger.error(err)
return []
query_embeddings = None

else:
# Generate embeddings for user query
query_embeddings = self.embedding_model.encode(query)
Expand Down Expand Up @@ -202,6 +192,9 @@ def find(
descriptors.append(descriptor)

# We compute the true cosine distance here (Couchbase uses a different score :-)).
if name is not None:
return [SearchResult(entry=descriptors[0], delta=1)]

deltas = self.get_deltas(query_embeddings, [t.embedding for t in descriptors])
results = [SearchResult(entry=descriptors[i], delta=deltas[i]) for i in range(len(deltas))]
return sorted(results, key=lambda t: t.delta, reverse=True)
Expand Down
2 changes: 1 addition & 1 deletion libs/agentc_core/tests/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Agent-Catalog Core Tests

1. Set your current working directory to be the parent folder (`libs/agentc_core`).
2. Activate your Poetry environment with `poetry shell`.
2. Activate your Poetry environment.
3. Run `pytest tests` and wait for the results! To run just the smoke tests, use `pytest tests -m smoke`.
1 change: 0 additions & 1 deletion templates/agents/with_controlflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ This directory contains a starter project for building agents with Couchbase, Co

```bash
poetry install --with analysis
poetry shell
```

5. Run `agentc` to make sure this project has installed correctly (note that your first run will take a couple of
Expand Down

0 comments on commit 615ca92

Please sign in to comment.