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

Setup documentation files #23

Merged
merged 4 commits into from
Nov 30, 2023
Merged
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This should match the owning team set up in https://github.com/orgs/opensearch-project/teams
* @lezzago @joshuali925 @anirudha @sejli
Copy link
Member

Choose a reason for hiding this comment

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

I see a warning:

Unknown owner on line 2: make sure @sejli exists and has write access to the repository
…ezzago @joshuali925 @anirudha @sejli

80 changes: 80 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
- [Developer guide](#developer-guide)
- [Forking and Cloning](#forking-and-cloning)
- [Install Prerequisites](#install-prerequisites)
- [Environment Setup](#environment-setup)
- [Build](#build)
- [Run](#run)
- [Test](#test)

## Developer guide

So you want to contribute code to this project? Excellent! We're glad you're here. Here's what you need to do.

### Forking and Cloning

Fork this repository on GitHub, and clone locally with `git clone`.

### Install Prerequisites

You will need to install [node.js](https://nodejs.org/en/), [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md), and [yarn](https://yarnpkg.com/) in your environment to properly pull down dependencies to build and bootstrap the plugin.

### Environment Setup

1. Download OpenSearch for the version that matches the [OpenSearch Dashboard version specified in package.json](./package.json#L9).
1. Download and install the appropriate [OpenSearch ML Commons plugin](https://github.com/opensearch-project/ml-commons).
1. Download the OpenSearch-Dashboards source code for the [version specified in package.json](./package.json#L9) you want to set up.

See the [OpenSearch Dashboards developer guide](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/DEVELOPER_GUIDE.md) for more instructions on setting up your development environment.

1. Change your node version to the version specified in `.node-version` inside the OpenSearch-Dashboards root directory.
1. cd into the `plugins` directory of the OpenSearch-Dashboards source code directory.
1. Check out this package from version control into the `plugins` directory.
1. Set `assistant.chat.enabled` to `true` in `opensearch_dashboards.yml` if you want to enable the chat feature.
1. Run `yarn osd bootstrap` inside `Opensearch-Dashboards/plugins/dashboards-assistant`.

Ultimately, your directory structure should look like this:

```md
.
├── OpenSearch-Dashboards
│ └── plugins
│ └── dashboards-assistant
```


## Build

To build the plugin's distributable zip simply run `yarn build`.

Example output: `./build/assistantDashboards-2.11.0.zip`


## Run

- `yarn start`

- Starts OpenSearch-Dashboards and includes this plugin. OpenSearch-Dashboards will be available on `localhost:5601`.
- Please run in the OpenSearch-Dashboards root directory
- You must have OpenSearch running with the ML Commons plugin

## Test

There are unit/stubbed integration tests.

- `yarn test`

- Runs the plugin unit tests.

### Formatting

This codebase uses Prettier as our code formatter. All new code that is added has to be reformatted using the Prettier version listed in `package.json`. In order to keep consistent formatting across the project developers should only use the prettier CLI to reformat their code using the following command:

```
yarn lint --fix
```

> NOTE: There also exists prettier plugins on several editors that allow for automatic reformatting on saving the file. However using this is discouraged as you must ensure that the plugin uses the correct version of prettier (listed in `package.json`) before using such a plugin.

### Backport

- [Link to backport documentation](https://github.com/opensearch-project/opensearch-plugins/blob/main/BACKPORT.md)
133 changes: 133 additions & 0 deletions GETTING_STARTED_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
## Getting started guide

### How to run assistant on your own machine
Below are the set of steps to run OpenSearch and OpenSearch dashboards with the OpenSearch assistant and the query generation functionality in the Observability Log Explorer page correctly on the cluster.
**Note** that the `feature/langchain` is the branch used in this guide.

1. Follow steps here to setup docker for OpenSearch: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/
1. Note: When running docker pull, use this command instead: `docker pull public.ecr.aws/w1m7p7g2/opensearch-reinvent2023:latest`


2. Follow steps here to setup docker to OpenSearch Dashboards: https://opensearch.org/docs/latest/install-and-configure/install-dashboards/docker/
1. Note: When running docker pull, use this command instead for OSD: `docker pull public.ecr.aws/w1m7p7g2/opensearch-dashboards-reinvent2023:latest`
2. If you want to enable the chat assistant feature, set `assistant.chat.enabled` to `true` in the `opensearch_dashboards.yml` file.
3. After OpenSearch and OpenSearch Dashboards are running, we will setup ML Commons to connect to the LLM model
4. Run ML commons on Data node
```
PUT _cluster/settings
{
"persistent" : {
"plugins.ml_commons.only_run_on_ml_node":"false"
}
}
```
5. Add Trusted Endpoints ([reference doc](https://opensearch.org/docs/latest/ml-commons-plugin/remote-models/index/))
```
PUT _cluster/settings
{
"persistent" : {
"plugins.ml_commons.trusted_connector_endpoints_regex":
[ "^https://runtime\\.sagemaker\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",
"^https://api\\.openai\\.com/.*$",
"^https://api\\.cohere\\.ai/.*$",
"^https://bedrock-runtime\\.us-east-1\\.amazonaws\\.com/.*$"
]
}
}
```
6. Create a connector ([reference doc](https://opensearch.org/docs/latest/ml-commons-plugin/remote-models/index/)). The below example is for connecting to the AWS Bedrock Claude model. Keep note of the connector id from the API response. (Ensure the credentials passed should have access to call the LLM model)
```
POST /_plugins/_ml/connectors/_create
{
"name": "BedRock test claude Connector",
"description": "The connector to BedRock service for claude model",
"version": 1,
"protocol": "aws_sigv4",
"parameters": {
"region": "us-east-1",
"service_name": "bedrock",
"anthropic_version": "bedrock-2023-05-31",
"endpoint": "bedrock.us-east-1.amazonaws.com",
"auth": "Sig_V4",
"content_type": "application/json",
"max_tokens_to_sample": 8000,
"temperature": 0.0001,
"response_filter": "$.completion"
},
"credential": {
"access_key": "<IAM access key>",
"secret_key": "<IAM secret key"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"url": "https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-instant-v1/invoke",
"headers": {
"content-type": "application/json",
"x-amz-content-sha256": "required"
},
"request_body": "{\"prompt\":\"${parameters.prompt}\", \"max_tokens_to_sample\":${parameters.max_tokens_to_sample}, \"temperature\":${parameters.temperature}, \"anthropic_version\":\"${parameters.anthropic_version}\" }"
}
]
}
```
7. Create a model group with an example below ([reference doc](https://opensearch.org/docs/latest/ml-commons-plugin/remote-models/index/)) and note the model group id.
```
POST /_plugins/_ml/model_groups/_register
{
"name": "test_model_group_bedrock",
"description": "This is a public model group"
}
```
8. Create a model and note the model id
```
POST /_plugins/_ml/models/_register
{
"name": "Bedrock Claude instant model",
"function_name": "remote",
"model_group_id": "<model group id from previous API call>",
"description": "test model",
"connector_id": "<connector id from previous API call>"
}
```
9. Create Embedding Model and note the model id from the get tasks API call
```
POST /_plugins/_ml/models/_register
{
"name": "huggingface/sentence-transformers/all-mpnet-base-v2",
"version": "1.0.1",
"model_group_id": "<model group id from previous API call>",
"model_format": "TORCH_SCRIPT"
}
GET /_plugins/_ml/tasks/<task id from above model register call>
```
10. Deploy the LLM and embedding models. Confirm the model has been deployed with the task id from the response with the get tasks API call
```
POST /_plugins/_ml/models/<llm_model_id>/_deploy
POST /_plugins/_ml/models/<embedding_model_id>/_deploy

GET /_plugins/_ml/tasks/<task id from above deploy model calls>
```
11. Test connection with calling the Predict API
```
POST /_plugins/_ml/models/<llm_model_id>/_predict
{
"parameters": {
"prompt": "\n\nHuman:hello\n\nnAssistant:"
}
}
```
12. Connect OS Assistant to the deployed models
```
POST /.chat-assistant-config/_doc/model-config
{
"model_type":"claude_bedrock",
"model_id":"<model-id>",
"embeddings_model_id":"<embedding-model-id>"
}
```
### How to create your own skill
1. To create your skill, you need to work backwards to see how that skill can be achieved by accessing different OpenSearch APIs/functions. For example, a skill to find the alerts related to a question would need to use the Alerting plugin APIs to get this info.
1. To power the skill to get alerts, we must build a tool to search alerts.
1. To create a tool, you must extend this [class](https://github.com/opensearch-project/ml-commons/blob/feature/agent_framework_dev/spi/src/main/java/org/opensearch/ml/common/spi/tools/Tool.java) and implement the specific tool. [This is an example tool](https://github.com/opensearch-project/ml-commons/pull/1629) that search alerts.
17 changes: 17 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Overview

This document contains a list of maintainers in this repo. See [opensearch-project/.github/RESPONSIBILITIES.md](https://github.com/opensearch-project/.github/blob/main/RESPONSIBILITIES.md#maintainer-responsibilities) that explains what the role of maintainer means, what maintainers do in this and other repos, and how they should be doing it. If you're interested in contributing, and becoming a maintainer, see [CONTRIBUTING](CONTRIBUTING.md).

## Current Maintainers

| Maintainer | GitHub ID | Affiliation |
|-----------------|-----------------------------------------------| ----------- |
| Ashish Agrawal | [lezzago](https://github.com/lezzago) | Amazon |
| Joshua Li | [joshuali925](https://github.com/joshuali925) | Amazon |
| Anirudha Jadhav | [anirudha](https://github.com/anirudha) | Amazon |
| Sean Li | [sejli](https://github.com/sejli) | Amazon |
| Yulong Ruan | [ruanyl](https://github.com/ruanyl) | Amazon |
| Su Zhou | [SuZhou-Joe](https://github.com/SuZhou-Joe) | Amazon |
| Tianyu Gao | [raintygao](https://github.com/raintygao) | Amazon |
| Hailong Cui | [Hailong-am](https://github.com/Hailong-am) | Amazon |
| HLin Wang | [wanglam](https://github.com/wanglam) | Amazon |
59 changes: 52 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,62 @@
## My Project
[![Forum](https://img.shields.io/badge/chat-on%20forums-blue)](https://forum.opensearch.org/t/feedback-opensearch-assistant/16741)
![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success)

TODO: Fill this README out!
<img src="https://opensearch.org/assets/brand/SVG/Logo/opensearch_logo_default.svg" height="64px"/>

Be sure to:
- [OpenSearch Assistant Dashboards](#opensearch-assistant-dashboards)
- [Highlights](#highlights)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [Code of Conduct](#code-of-conduct)
- [Security](#security)
- [License](#license)
- [Copyright](#copyright)

* Change the title in this README
* Edit your repository description on GitHub
# OpenSearch Assistant Dashboards

The OpenSearch Assistant Dashboards plugin lets you have an opensearch assistant to help dashboards users use OpenSearch.

## How to get started

See [getting started guide](GETTING_STARTED_GUIDE.md) to how to deploy this Assistant on your machine with docker images.
**Note** that the `feature/langchain` is the branch used in the getting started guide.

### Supported tools
This requires setting `assistant.chat.enabled` to `true` in `opensearch_dashboards.yml` to use these skills:
1. Query OpenSearch: Use to generate and run a PPL Query to get results for a generic user question related to data stored in their OpenSearch cluster.
2. Get log info: Use to get information of logs if the question contains an OpenSearch log index.
3. Get log error info: Use to get information of logs with errors if the question contains an OpenSearch log index.
4. Search Alerting Monitors By Index: Use this tool to search alerting monitors by index name in the OpenSearch cluster.
5. Get All Alerts: Use this tool to search all alerts triggered in the OpenSearch cluster.
6. Get ticket information: Use this tool to find tickets in the system with incidents that are relevant to a question about error causes.
Copy link
Member

Choose a reason for hiding this comment

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

@sejli i remember you changed this to work with documentations vector store, do you have the text/wording? it might be better than having the ticket tool here

7. Get generic information: Use this tool to answer a generic question not related to OpenSearch cluster. This tool takes the question as input.
8. Get OpenSearch indices: Use this tool to get high-level information (e. health, status, index, docs.count) about indices in a cluster, including backing indices for data streams in the OpenSearch cluster.
9. Check OpenSearch index existence: Use this tool to check if a data stream, index, or alias exists in the OpenSearch cluster.
10. Find Visualizations: Use this tool to find user created visualizations.
11. Get trace groups: Use this to get information about each trace group.
12. Get traces: Use this to get information about each trace.
13. Get trace services: Use this to get information about each service in trace analytics.

## Documentation

In the works.

## Contributing

See [developer guide](DEVELOPER_GUIDE.md) and [how to contribute to this project](CONTRIBUTING.md).

## Code of Conduct

This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUCT.md). For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq), or contact [opensource-codeofconduct@amazon.com](mailto:opensource-codeofconduct@amazon.com) with any additional questions or comments.

## Security

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue.

## License

This project is licensed under the Apache-2.0 License.
This project is licensed under the [Apache v2.0 License](LICENSE).

## Copyright

Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details.