Skip to content

Commit

Permalink
Update tools, remove examples
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesLoder committed Dec 11, 2024
1 parent 9c8af74 commit 185691b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions chat/src/agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from setup import opensearch_vector_store

def get_keyword_fields(properties, prefix=''):
"""
Filters a nested list of opensearch mappings and returns a flat list of keyword fields
"""
keyword_fields = []
for field_name, field_mapping in properties.items():
current_path = f"{prefix}{field_name}"
Expand All @@ -28,7 +31,6 @@ def discover_fields():
fields = opensearch.client.indices.get_mapping(index=opensearch.index)
top_properties = list(fields.values())[0]['mappings']['properties']
result = get_keyword_fields(top_properties)

return json.dumps(result, default=str), result

@tool(response_format="content_and_artifact")
Expand All @@ -53,10 +55,6 @@ def aggregate(agg_field: str, term_field: str, term: str):
You must use the discover_fields tool first to obtain the list of appropriate fields for aggregration in the index.
Do not use any fields that do not exist in the list returned by discover_fields!
Examples:
- Number of collections: collection.title.keyword
- Number of works by work type: work_type
"""
try:
response = opensearch_vector_store().aggregations_search(agg_field, term_field, term)
Expand Down

0 comments on commit 185691b

Please sign in to comment.