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

Add Elasticsearch log retriever #100

Closed
wants to merge 0 commits into from
Closed

Conversation

Justicea83
Copy link
Contributor

@Justicea83 Justicea83 commented May 3, 2024

Thank you for contributing to the Cohere Toolkit!

  • PR title: "Add search to ELK cluster"

    • Add changes to add search from ELK stack
    • Example: "deployment: Cohere Platform"
  • PR message: Delete this entire checklist and replace with

    • Description: Add Elasticsearch retriever
    • Dependencies: elasticsearch
Screenshot 2024-05-03 at 19 02 05 Screenshot 2024-05-03 at 19 17 45

@Justicea83 Justicea83 requested a review from a team as a code owner May 3, 2024 23:02
@Justicea83 Justicea83 changed the title Add Custom Logger ELK Seach Add Elasticsearch log retriever May 3, 2024
.env-template Outdated Show resolved Hide resolved
@@ -12,6 +12,7 @@
LangChainVectorDBRetriever,
LangChainWikiRetriever,
TavilyInternetSearch,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We recently added a new backend/community/tools folder, can you move all logic there instead?

@@ -32,6 +33,7 @@ class ToolName(StrEnum):
Python_Interpreter = "Python_Interpreter"
Calculator = "Calculator"
Tavily_Internet_Search = "Internet Search"
Logs_Retriever = "App Logs"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename this to clarify that the source is Elasticsearch

},
is_visible=True,
is_available=LogsRetriever.is_available(),
error_message="LogsRetriever not available.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add here that the host and index env variables are required

self.index = index
self.deployment_name = deployment_name
self.client = Elasticsearch(host_url)
self.cohere_api_key = os.environ.get("COHERE_API_KEY")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks cohere_api_key is not required?

logger = get_logger()


class NYCServiceRequestRetriever(BaseRetrieval):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this retriever tool isn't present in the dict mapping, should we add it? Or was this for testing?

index: str,
deployment_name: str,
) -> None:
self.index = index
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Rather than instantiating LogsRetriever() with the index and host, can you add these as params on the class, eg :

class LogsRetriever(BaseRetrieval):
    index = os.environ.get(.., None)
    host = os.environ.get(.., None)

Then your __init__() method would use self.index and self.host,

And your classmethod
is_available() should check return all[self.index is not None, self.host is not None]

Copy link
Collaborator

@tianjing-li tianjing-li left a comment

Choose a reason for hiding this comment

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

Requested some changes

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.

None yet

2 participants