Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement tests for search index tool #11

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yuye-aws
Copy link
Member

@yuye-aws yuye-aws commented Feb 2, 2024

Description

Implement test script and runner for search index tool. You can run tests by
npm run test -- src/tests/search_index/search_index.test.ts
Remember to specify SEARCH_INDEX_AGENT_ID in .env first.

Issues Resolved

Implement test script and runner for search index tool.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, minor comments. Seems this tool is not used by react agent directly? If it doesn't use any LLM or embeddings model then UT and IT should cover it, adding it here can be optional.

Also could you attach a flow template you used to create the agent? thanks

@@ -25,6 +25,11 @@ export class ApiProviderFactory {
return new AgentFrameworkApiProvider(undefined, options.agentIdKey);
return new OllyPPLGeneratorApiProvider();

case PROVIDERS.SEARCH_INDEX_TOOL:
if (process.env.API_PROVIDER === PROVIDERS.AGENT_FRAMEWORK)
return new AgentFrameworkApiProvider(undefined, options.agentIdKey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i didn't realize options.agentIdKey isn't passed when provider is agent_framework

could you revert this and change

return new AgentFrameworkApiProvider();

to

return new AgentFrameworkApiProvider(undefined, options.agentIdKey);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, we no longer need a switch case for PROVIDERS.SEARCH_INDEX_TOOL

method: 'GET',
path: index + '/_search',
body: query,
})) as ApiResponse<DSLResponse>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a search response interface provided import { SearchResponse } from '@opensearch-project/opensearch/api/types';

Suggested change
})) as ApiResponse<DSLResponse>;
})) as ApiResponse<SearchResponse>;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminding me. I will change the type.

@yuye-aws
Copy link
Member Author

yuye-aws commented Feb 4, 2024

Seems this tool is not used by react agent directly? If it doesn't use any LLM or embeddings model then UT and IT should cover it, adding it here can be optional.

Can I test this tool with both flow agent and conversational agent? I think we can just add a new runner for search index tool.

@yuye-aws
Copy link
Member Author

yuye-aws commented Feb 4, 2024

Also could you attach a flow template you used to create the agent? thanks

The flow template is:

POST /_plugins/_ml/agents/_register
{
  "name": "Test_Agent_For_Search_Index_Tool",
  "type": "flow",
  "description": "this is a test agent for search index tool",
  "memory": {
    "type": "demo"
  },
  "tools": [
    {
      "type": "SearchIndexTool"
    }
  ]
}

In which file should I attach the flow template?

@joshuali925
Copy link
Member

"type": "flow",

thanks, i think flow agent case can be covered by unit tests, since there's no model logic involved. I don't mind this PR adding them here, but if this will be used by a conversational agent that uses LLM, it would be better to add those tests

@yuye-aws yuye-aws closed this Apr 25, 2024
@yuye-aws yuye-aws deleted the feat/searchIndexToolTest branch April 25, 2024 08:30
@yuye-aws yuye-aws restored the feat/searchIndexToolTest branch April 25, 2024 08:31
@yuye-aws yuye-aws reopened this Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants