Skip to content

Commit 62c2e78

Browse files
authored
Setup documentation files (#23)
Signed-off-by: Ashish Agrawal <[email protected]>
1 parent 14ede79 commit 62c2e78

File tree

5 files changed

+284
-7
lines changed

5 files changed

+284
-7
lines changed

Diff for: .github/CODEOWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This should match the owning team set up in https://github.com/orgs/opensearch-project/teams
2+
* @lezzago @joshuali925 @anirudha @sejli

Diff for: DEVELOPER_GUIDE.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
- [Developer guide](#developer-guide)
2+
- [Forking and Cloning](#forking-and-cloning)
3+
- [Install Prerequisites](#install-prerequisites)
4+
- [Environment Setup](#environment-setup)
5+
- [Build](#build)
6+
- [Run](#run)
7+
- [Test](#test)
8+
9+
## Developer guide
10+
11+
So you want to contribute code to this project? Excellent! We're glad you're here. Here's what you need to do.
12+
13+
### Forking and Cloning
14+
15+
Fork this repository on GitHub, and clone locally with `git clone`.
16+
17+
### Install Prerequisites
18+
19+
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.
20+
21+
### Environment Setup
22+
23+
1. Download OpenSearch for the version that matches the [OpenSearch Dashboard version specified in package.json](./package.json#L9).
24+
1. Download and install the appropriate [OpenSearch ML Commons plugin](https://github.com/opensearch-project/ml-commons).
25+
1. Download the OpenSearch-Dashboards source code for the [version specified in package.json](./package.json#L9) you want to set up.
26+
27+
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.
28+
29+
1. Change your node version to the version specified in `.node-version` inside the OpenSearch-Dashboards root directory.
30+
1. cd into the `plugins` directory of the OpenSearch-Dashboards source code directory.
31+
1. Check out this package from version control into the `plugins` directory.
32+
1. Set `assistant.chat.enabled` to `true` in `opensearch_dashboards.yml` if you want to enable the chat feature.
33+
1. Run `yarn osd bootstrap` inside `Opensearch-Dashboards/plugins/dashboards-assistant`.
34+
35+
Ultimately, your directory structure should look like this:
36+
37+
```md
38+
.
39+
├── OpenSearch-Dashboards
40+
│ └── plugins
41+
│ └── dashboards-assistant
42+
```
43+
44+
45+
## Build
46+
47+
To build the plugin's distributable zip simply run `yarn build`.
48+
49+
Example output: `./build/assistantDashboards-2.11.0.zip`
50+
51+
52+
## Run
53+
54+
- `yarn start`
55+
56+
- Starts OpenSearch-Dashboards and includes this plugin. OpenSearch-Dashboards will be available on `localhost:5601`.
57+
- Please run in the OpenSearch-Dashboards root directory
58+
- You must have OpenSearch running with the ML Commons plugin
59+
60+
## Test
61+
62+
There are unit/stubbed integration tests.
63+
64+
- `yarn test`
65+
66+
- Runs the plugin unit tests.
67+
68+
### Formatting
69+
70+
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:
71+
72+
```
73+
yarn lint --fix
74+
```
75+
76+
> 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.
77+
78+
### Backport
79+
80+
- [Link to backport documentation](https://github.com/opensearch-project/opensearch-plugins/blob/main/BACKPORT.md)

Diff for: GETTING_STARTED_GUIDE.md

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
## Getting started guide
2+
3+
### How to run assistant on your own machine
4+
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.
5+
**Note** that the `feature/langchain` is the branch used in this guide.
6+
7+
1. Follow steps here to setup docker for OpenSearch: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/
8+
1. Note: When running docker pull, use this command instead: `docker pull public.ecr.aws/w1m7p7g2/opensearch-reinvent2023:latest`
9+
10+
11+
2. Follow steps here to setup docker to OpenSearch Dashboards: https://opensearch.org/docs/latest/install-and-configure/install-dashboards/docker/
12+
1. Note: When running docker pull, use this command instead for OSD: `docker pull public.ecr.aws/w1m7p7g2/opensearch-dashboards-reinvent2023:latest`
13+
2. If you want to enable the chat assistant feature, set `assistant.chat.enabled` to `true` in the `opensearch_dashboards.yml` file.
14+
3. After OpenSearch and OpenSearch Dashboards are running, we will setup ML Commons to connect to the LLM model
15+
4. Run ML commons on Data node
16+
```
17+
PUT _cluster/settings
18+
{
19+
"persistent" : {
20+
"plugins.ml_commons.only_run_on_ml_node":"false"
21+
}
22+
}
23+
```
24+
5. Add Trusted Endpoints ([reference doc](https://opensearch.org/docs/latest/ml-commons-plugin/remote-models/index/))
25+
```
26+
PUT _cluster/settings
27+
{
28+
"persistent" : {
29+
"plugins.ml_commons.trusted_connector_endpoints_regex":
30+
[ "^https://runtime\\.sagemaker\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",
31+
"^https://api\\.openai\\.com/.*$",
32+
"^https://api\\.cohere\\.ai/.*$",
33+
"^https://bedrock-runtime\\.us-east-1\\.amazonaws\\.com/.*$"
34+
]
35+
}
36+
}
37+
```
38+
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)
39+
```
40+
POST /_plugins/_ml/connectors/_create
41+
{
42+
"name": "BedRock test claude Connector",
43+
"description": "The connector to BedRock service for claude model",
44+
"version": 1,
45+
"protocol": "aws_sigv4",
46+
"parameters": {
47+
"region": "us-east-1",
48+
"service_name": "bedrock",
49+
"anthropic_version": "bedrock-2023-05-31",
50+
"endpoint": "bedrock.us-east-1.amazonaws.com",
51+
"auth": "Sig_V4",
52+
"content_type": "application/json",
53+
"max_tokens_to_sample": 8000,
54+
"temperature": 0.0001,
55+
"response_filter": "$.completion"
56+
},
57+
"credential": {
58+
"access_key": "<IAM access key>",
59+
"secret_key": "<IAM secret key"
60+
},
61+
"actions": [
62+
{
63+
"action_type": "predict",
64+
"method": "POST",
65+
"url": "https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-instant-v1/invoke",
66+
"headers": {
67+
"content-type": "application/json",
68+
"x-amz-content-sha256": "required"
69+
},
70+
"request_body": "{\"prompt\":\"${parameters.prompt}\", \"max_tokens_to_sample\":${parameters.max_tokens_to_sample}, \"temperature\":${parameters.temperature}, \"anthropic_version\":\"${parameters.anthropic_version}\" }"
71+
}
72+
]
73+
}
74+
```
75+
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.
76+
```
77+
POST /_plugins/_ml/model_groups/_register
78+
{
79+
"name": "test_model_group_bedrock",
80+
"description": "This is a public model group"
81+
}
82+
```
83+
8. Create a model and note the model id
84+
```
85+
POST /_plugins/_ml/models/_register
86+
{
87+
"name": "Bedrock Claude instant model",
88+
"function_name": "remote",
89+
"model_group_id": "<model group id from previous API call>",
90+
"description": "test model",
91+
"connector_id": "<connector id from previous API call>"
92+
}
93+
```
94+
9. Create Embedding Model and note the model id from the get tasks API call
95+
```
96+
POST /_plugins/_ml/models/_register
97+
{
98+
"name": "huggingface/sentence-transformers/all-mpnet-base-v2",
99+
"version": "1.0.1",
100+
"model_group_id": "<model group id from previous API call>",
101+
"model_format": "TORCH_SCRIPT"
102+
}
103+
GET /_plugins/_ml/tasks/<task id from above model register call>
104+
```
105+
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
106+
```
107+
POST /_plugins/_ml/models/<llm_model_id>/_deploy
108+
POST /_plugins/_ml/models/<embedding_model_id>/_deploy
109+
110+
GET /_plugins/_ml/tasks/<task id from above deploy model calls>
111+
```
112+
11. Test connection with calling the Predict API
113+
```
114+
POST /_plugins/_ml/models/<llm_model_id>/_predict
115+
{
116+
"parameters": {
117+
"prompt": "\n\nHuman:hello\n\nnAssistant:"
118+
}
119+
}
120+
```
121+
12. Connect OS Assistant to the deployed models
122+
```
123+
POST /.chat-assistant-config/_doc/model-config
124+
{
125+
"model_type":"claude_bedrock",
126+
"model_id":"<model-id>",
127+
"embeddings_model_id":"<embedding-model-id>"
128+
}
129+
```
130+
### How to create your own skill
131+
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.
132+
1. To power the skill to get alerts, we must build a tool to search alerts.
133+
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.

Diff for: MAINTAINERS.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Overview
2+
3+
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).
4+
5+
## Current Maintainers
6+
7+
| Maintainer | GitHub ID | Affiliation |
8+
|-----------------|-----------------------------------------------| ----------- |
9+
| Ashish Agrawal | [lezzago](https://github.com/lezzago) | Amazon |
10+
| Joshua Li | [joshuali925](https://github.com/joshuali925) | Amazon |
11+
| Anirudha Jadhav | [anirudha](https://github.com/anirudha) | Amazon |
12+
| Sean Li | [sejli](https://github.com/sejli) | Amazon |
13+
| Yulong Ruan | [ruanyl](https://github.com/ruanyl) | Amazon |
14+
| Su Zhou | [SuZhou-Joe](https://github.com/SuZhou-Joe) | Amazon |
15+
| Tianyu Gao | [raintygao](https://github.com/raintygao) | Amazon |
16+
| Hailong Cui | [Hailong-am](https://github.com/Hailong-am) | Amazon |
17+
| HLin Wang | [wanglam](https://github.com/wanglam) | Amazon |

Diff for: README.md

+52-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,62 @@
1-
## My Project
1+
[![Forum](https://img.shields.io/badge/chat-on%20forums-blue)](https://forum.opensearch.org/t/feedback-opensearch-assistant/16741)
2+
![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success)
23

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

5-
Be sure to:
6+
- [OpenSearch Assistant Dashboards](#opensearch-assistant-dashboards)
7+
- [Highlights](#highlights)
8+
- [Documentation](#documentation)
9+
- [Contributing](#contributing)
10+
- [Code of Conduct](#code-of-conduct)
11+
- [Security](#security)
12+
- [License](#license)
13+
- [Copyright](#copyright)
614

7-
* Change the title in this README
8-
* Edit your repository description on GitHub
15+
# OpenSearch Assistant Dashboards
16+
17+
The OpenSearch Assistant Dashboards plugin lets you have an opensearch assistant to help dashboards users use OpenSearch.
18+
19+
## How to get started
20+
21+
See [getting started guide](GETTING_STARTED_GUIDE.md) to how to deploy this Assistant on your machine with docker images.
22+
**Note** that the `feature/langchain` is the branch used in the getting started guide.
23+
24+
### Supported tools
25+
This requires setting `assistant.chat.enabled` to `true` in `opensearch_dashboards.yml` to use these skills:
26+
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.
27+
2. Get log info: Use to get information of logs if the question contains an OpenSearch log index.
28+
3. Get log error info: Use to get information of logs with errors if the question contains an OpenSearch log index.
29+
4. Search Alerting Monitors By Index: Use this tool to search alerting monitors by index name in the OpenSearch cluster.
30+
5. Get All Alerts: Use this tool to search all alerts triggered in the OpenSearch cluster.
31+
6. Get ticket information: Use this tool to find tickets in the system with incidents that are relevant to a question about error causes.
32+
7. Get generic information: Use this tool to answer a generic question not related to OpenSearch cluster. This tool takes the question as input.
33+
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.
34+
9. Check OpenSearch index existence: Use this tool to check if a data stream, index, or alias exists in the OpenSearch cluster.
35+
10. Find Visualizations: Use this tool to find user created visualizations.
36+
11. Get trace groups: Use this to get information about each trace group.
37+
12. Get traces: Use this to get information about each trace.
38+
13. Get trace services: Use this to get information about each service in trace analytics.
39+
40+
## Documentation
41+
42+
In the works.
43+
44+
## Contributing
45+
46+
See [developer guide](DEVELOPER_GUIDE.md) and [how to contribute to this project](CONTRIBUTING.md).
47+
48+
## Code of Conduct
49+
50+
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 [[email protected]](mailto:[email protected]) with any additional questions or comments.
951

1052
## Security
1153

12-
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
54+
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.
1355

1456
## License
1557

16-
This project is licensed under the Apache-2.0 License.
58+
This project is licensed under the [Apache v2.0 License](LICENSE).
59+
60+
## Copyright
1761

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

0 commit comments

Comments
 (0)