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

Update from ghe #7

Merged
merged 12 commits into from
Nov 12, 2024
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
S3_RAG_DOCUMENT_BUCKET=
DB_URL=jdbc:h2:../databases/rag

# If using CAII, fill these in:
CAII_DOMAIN=
CAII_INFERENCE_ENDPOINT_NAME=
CAII_EMBEDDING_ENDPOINT_NAME=
4 changes: 2 additions & 2 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:

- name: Run Java backend tests
run: ./gradlew test
working-directory: api
working-directory: backend

- name: Build with Gradle
run: ./gradlew build
working-directory: api
working-directory: backend

- uses: pnpm/action-setup@v4
name: Install pnpm
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,16 @@ jobs:

- name: Run Java backend tests
run: ./gradlew test
working-directory: api
working-directory: backend

- name: Build with Gradle
run: ./gradlew build
working-directory: api
working-directory: backend

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9

- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -82,7 +81,7 @@ jobs:
name: ${{ github.event.inputs.VERSION }}
tag_name: ${{ github.event.inputs.VERSION }}
files: |
api/build/libs/rag-api.jar
backend/build/libs/rag-api.jar
ui/fe-dist.tar.gz
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
1 change: 1 addition & 0 deletions .project-metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ environment_variables:
description: "Internal API URL. Do not change."
required: true


runtimes:
- editor: JupyterLab
kernel: Python 3.10
Expand Down
2 changes: 1 addition & 1 deletion .run/Tests in 'rag-api.test'.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration default="false" name="Tests in 'rag-api.test'" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/api" />
<option name="externalProjectPath" value="$PROJECT_DIR$/backend" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
Expand Down
21 changes: 21 additions & 0 deletions .run/pytest in _llm-service.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="pytest in /llm-service" type="tests" factoryName="py.test">
<module name="backend.rag-api.test" />
<option name="ENV_FILES" value="$PROJECT_DIR$/.env" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="SDK_NAME" value="Python 3.10 (AmpRagStudio)" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/llm-service" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
</component>
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "interactive",
"python.analysis.extraPaths": ["./pybackend"]
}
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# RAG Studio
# RAG Studio

### What is Rag Studio?

An AMP that provides a no-code tool to build RAG applications

### Pre-requisites

RAG Studio requires AWS for access to both LLM and embedding models. Please complete the following steps before using the RAG Studio:
RAG Studio requires AWS for access to both LLM and embedding models. Please complete the following steps before using the RAG Studio:

- A S3 bucket to store the documents
- The following models configured and accessible via AWS Bedrock. Any of the models not enabled will not function in the UI.
- The following models configured and accessible via AWS Bedrock. Any of the models not enabled will not function in the UI.
- Llama3.1 8b Instruct V1 (`meta.llama3-1-8b-instruct-v1:0`) - This model is required for the RAG Studio to function
- Llama3.1 70b Instruct V1 (`meta.llama3-1-70b-instruct-v1:0`)
- Llama3.1 405b Instruct V1 (`meta.llama3-1-405b-instruct-v1:0`)
Expand All @@ -18,21 +18,21 @@ RAG Studio requires AWS for access to both LLM and embedding models. Please com

### Cloudera DataFlow (Nifi) Setup:

Rag Studio provides a Nifi template that can be downloaded for a given Knowledge Base from the `Connections` tab.
The Nifi template can then be imported into your Cloudera DataFlow (CDF) environment and used to setup a pipeline into Rag Studio.
Rag Studio provides a Nifi template that can be downloaded for a given Knowledge Base from the `Connections` tab.
The Nifi template can then be imported into your Cloudera DataFlow (CDF) environment and used to setup a pipeline into Rag Studio.

IMPORTANT: In order to inject data from CDF, users must disable authentication of the AMP Project from their Cloudera Machine Learning (CML) workspace.
This carries a security risk and should be carefully considered before proceeding.

### Updating RAG Studio

The Rag Studio UI will show a banner at the top of the page when a new version of the AMP is available.
To update the Rag Studio, click on the banner and follow the instructions. If any issues are encountered, please contact
Cloudera for assistance. Additionally, further details on the AMP status can be found from the CML workspace.
The Rag Studio UI will show a banner at the top of the page when a new version of the AMP is available.
To update the Rag Studio, click on the banner and follow the instructions. If any issues are encountered, please contact
Cloudera for assistance. Additionally, further details on the AMP status can be found from the CML workspace.

### Common Issues

- Both the Llama and Cohere models must be enabled in AWS Bedrock for the Rag Studio to function properly. If the models are not enabled, Rag Studio will not function as expected.
- Both the Llama and Cohere models must be enabled in AWS Bedrock for the Rag Studio to function properly. If the models are not enabled, Rag Studio will not function as expected.

## Installation

Expand Down Expand Up @@ -64,8 +64,8 @@ Make a copy of the `.env.example` file and rename it to `.env`. Fill in the valu

### Local Development

Every service can be started locally for development by running `./local-dev.sh`. Once started, the UI can be accessed
at `http://localhost:5173`. Additionally, each service can be started individually by following the instructions below.
Every service can be started locally for development by running `./local-dev.sh`. Once started, the UI can be accessed
at `http://localhost:5173`. Additionally, each service can be started individually by following the instructions below.

#### FE Setup

Expand All @@ -76,8 +76,8 @@ at `http://localhost:5173`. Additionally, each service can be started individua

#### Node Setup

The Node Service is used as a proxy and to serve static assets. For local development, the proxying and static
asset serving is handled by the FE service. The Node service is only used in production. However, if you want to run
The Node Service is used as a proxy and to serve static assets. For local development, the proxying and static
asset serving is handled by the FE service. The Node service is only used in production. However, if you want to run
the Node service locally, you can do so by following these steps:

- Build the FE service (`cd ./ui` and then `pnpm build`)
Expand All @@ -91,15 +91,16 @@ the Node service locally, you can do so by following these steps:
- Create a virtual environment (`python -m venv venv; source venv/bin/activate`)
- Install dependencies (`python -m pip install -r requirements.txt`)
- `fastapi dev`
- ends up running on port 8000
- ends up running on port 8000

#### Java Setup

- Install Java 21 and make default JDK
- `cd ./api`
- `cd ./backend`
- `./gradlew bootRun`

#### To run quadrant locally

```
docker run -p 6333:6333 -p 6334:6334 -v $(pwd)/databases/qdrant_storage:/qdrant/storage:z qdrant/qdrant
```
Expand Down
191 changes: 191 additions & 0 deletions api/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: RAG Studio API
license:
name: MIT
servers:
- url: http://localhost:8000/api/v1
paths:
/configurations/cloud:
get:
summary: List cloud configurations
operationId: listCloudConfigurations
tags:
- config_cloud
responses:
'200':
description: List of clouds
content:
application/json:
schema:
$ref: '#/components/schemas/CloudConfigurationList'
post:
summary: Create a cloud configuration
operationId: createCloudConfiguration
tags:
- config_cloud
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CloudConfigurationCreateRequest'
responses:
'200':
description: Cloud configuration
content:
application/json:
schema:
$ref: '#/components/schemas/CloudConfiguration'

/configurations/cloud/{id}:
get:
summary: Get a cloud configuration
operationId: getCloudConfiguration
tags:
- config_cloud
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Cloud configuration
content:
application/json:
schema:
$ref: '#/components/schemas/CloudConfiguration'
put:
summary: Update a cloud configuration
operationId: updateCloudConfiguration
tags:
- config_cloud
parameters:
- name: id
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CloudConfigurationUpdateRequest'
responses:
'200':
description: Cloud configuration
content:
application/json:
schema:
$ref: '#/components/schemas/CloudConfiguration'
delete:
summary: Delete a cloud configuration
operationId: deleteCloudConfiguration
tags:
- config_cloud
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Cloud configuration deleted

components:
schemas:
CloudConfiguration:
type: object
required:
- id
- name
- configuration
properties:
id:
type: string
description: Cloud configuration ID
name:
type: string
description: Cloud configuration name
configuration:
type: object
oneOf:
- $ref: '#/components/schemas/CloudConfigurationAws'

CloudConfigurationAws:
type: object
required:
- aws
properties:
aws:
type: object
required:
- region
- type
properties:
region:
type: string
type:
oneOf:
- $ref: '#/components/schemas/CloudConfigurationAwsInstanceProfile'
- $ref: '#/components/schemas/CloudConfigurationAwsKey'

CloudConfigurationAwsInstanceProfile:
type: string
enum:
- instance_profile

CloudConfigurationAwsKey:
type: object
required:
- access_key_id
- secret_access_key
properties:
access_key_id:
type: string
secret_access_key:
type: string

CloudConfigurationCreateRequest:
type: object
required:
- name
- configuration
properties:
name:
type: string
description: Cloud configuration name
configuration:
type: object
oneOf:
- $ref: '#/components/schemas/CloudConfigurationAws'

CloudConfigurationList:
type: object
required:
- items
properties:
items:
type: array
items:
$ref: "#/components/schemas/CloudConfiguration"

CloudConfigurationUpdateRequest:
type: object
required:
- name
- configuration
properties:
name:
type: string
description: Cloud configuration name
configuration:
type: object
oneOf:
- $ref: '#/components/schemas/CloudConfigurationAws'

8 changes: 8 additions & 0 deletions api/defs/api_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: RAG Studio API
license:
name: MIT
servers:
- url: http://localhost:8000/api/v1
Loading