-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into test-add-sessions-service-ut
- Loading branch information
Showing
16 changed files
with
735 additions
and
111 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# This should match the owning team set up in https://github.com/orgs/opensearch-project/teams | ||
* @pjfitzgibbons @ps48 @kavithacm @derek-ho @joshuali925 @dai-chen @YANG-DB @rupal-bq @mengweieric @vamsi-amazon @swiddis @penghuo @seankao-az @anirudha | ||
* @lezzago @joshuali925 @anirudha @ruanyl @SuZhou-Joe @xluo-aws @gaobinlong @Hailong-am @wanglam @raintygao |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,59 @@ | ||
## Contributing to this Project | ||
# Contributing Guidelines | ||
|
||
OpenSearch is a community project that is built and maintained by people just like **you**. | ||
[This document](https://github.com/opensearch-project/.github/blob/main/CONTRIBUTING.md) explains how you can contribute to this and related projects. | ||
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional | ||
documentation, we greatly value feedback and contributions from our community. | ||
|
||
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary | ||
information to effectively respond to your bug report or contribution. | ||
|
||
|
||
## Reporting Bugs/Feature Requests | ||
|
||
We welcome you to use the GitHub issue tracker to report bugs or suggest features. | ||
|
||
When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already | ||
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: | ||
|
||
* A reproducible test case or series of steps | ||
* The version of our code being used | ||
* Any modifications you've made relevant to the bug | ||
* Anything unusual about your environment or deployment | ||
|
||
|
||
## Contributing via Pull Requests | ||
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: | ||
|
||
1. You are working against the latest source on the *main* branch. | ||
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. | ||
3. You open an issue to discuss any significant work - we would hate for your time to be wasted. | ||
|
||
To send us a pull request, please: | ||
|
||
1. Fork the repository. | ||
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. | ||
3. Ensure local tests pass. | ||
4. Commit to your fork using clear commit messages. | ||
5. Send us a pull request, answering any default questions in the pull request interface. | ||
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. | ||
|
||
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and | ||
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/). | ||
|
||
|
||
## Finding contributions to work on | ||
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. | ||
|
||
|
||
## Code of Conduct | ||
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). | ||
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact | ||
[email protected] with any additional questions or comments. | ||
|
||
|
||
## Security issue notifications | ||
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. | ||
|
||
|
||
## Licensing | ||
|
||
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
## 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. Note: This docker image may get incrementally updated over time. | ||
|
||
|
||
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. Note: This docker image may get incrementally updated over time. | ||
3. 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}\" }" | ||
} | ||
] | ||
} | ||
``` | ||
1. If you are using AWS Bedrock, ensure the IAM user or IAM role used have these policy permissions. Feel free to restrict the resources to the specific endpoints you want ML Commons to connect to. | ||
``` | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "Stmt1688544995813", | ||
"Action": [ | ||
"bedrock:ListBuiltInModels", | ||
"bedrock:ListFoundationModels", | ||
"bedrock:InvokeModel" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
``` | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.