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

Documentation for Backend #120

Merged
merged 5 commits into from
Jan 16, 2025
Merged
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
116 changes: 116 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Backend For ORAssistant

This folder contains the backend code for the ORAssistant. Follow the instructions below to set up the environment and run the backend.

## Preparing the Environment Variables

To configure the application, you'll need to set up the environment variables in your `.env` file:

The given command would copy the template for environment variables to a local `.env` file


```
cp .env.example .env
```


### Setting Up Google API Key and Credentials Variables

There are 2 variables that needs to be set up

- `GOOGLE_API_KEY`

This key is used to access the various google cloud functions.
- Go to [Google Cloud Console](https://console.cloud.google.com/)
- Create new project or select existing one
- Enable required APIs:
- Google Gemini API
- Vertex AI API
- Go to APIs & Services > Credentials
- Click "Create Credentials" > "API Key"
- Copy the generated key and it to the `.env` file

- `GOOGLE_APPLICATION_CREDENTIALS`
Since most of the GCP functions / services would be used by our app, we need to have a special credential that would allow `ORAssistant`'s access to the GCP
Steps to set up Service Account Credentials:
- In Google Cloud Console, go to IAM & Admin > Service Accounts
- Click "Create Service Account"
Fill in service account details
- Grant required roles:
- Vertex AI User
- Vertex AI Service Agent
- Create key (JSON format)
- Download JSON file
- Store securely and add path to .env:
`GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json`

**NOTE**: The user might need billing to be set up on google cloud account and make sure to name the file as `credentials.json` as this would be ignored by `.git` and wouldn't be exposed on Github

### Setting Up LangChain Variables

There are 4 variables that needs to be set up

- `LANGCHAIN_TRACING_V2`

This is used to enable LangChain's debugging and monitoring features,
can be set to either `true` or `false`

- `LANGCHAIN_ENDPOINT`

The URL endpoint for LangSmith (LangChain's monitoring platform).
Default value should be `https://api.smith.langchain.com` for cloud-hosted LangSmith.
Used to send trace data, metrics, and debugging information from your LangChain applications.

- `LANGCHAIN_API_KEY`

API key required to authenticate with LangSmith platform.
- Get your key from: https://smith.langchain.com/
- Create account if you don't have one
- Navigate to Settings > API Keys
- Create new API key
- Format: starts with `lsv2_` followed by a unique string

- `LANGCHAIN_PROJECT`

Project identifier in LangSmith to organize and track your traces.
luarss marked this conversation as resolved.
Show resolved Hide resolved
- Create new project in LangSmith dashboard
- Use the project name or ID provided
- Example: "my-rag-project"
- Helps organize different applications/environments
- Multiple apps can share same project


### Setting Up Huggingface User Access Token

To set up the `HF_TOKEN` variable in `.env` file , go through the following instructions:

- Go the official website for [Huggingface](https://huggingface.co/) and either Login or Sign up.
- On the main page click on user access token
- Click on create access token
- Provide only Read Instruction for the token and Click on Generate Token




Provide the value for `HF_TOKEN` with the token that is generated

## Running the Application

### Install Required Packages

Ensure you have the necessary dependencies installed by running:

```bash
pip install -r requirements.txt
```
### Docker Command

If you want to run an isolated container for backend, you can use the following command

```bash
docker build -t (image_name) .
```

Make sure you are in the backend folder before running the above command.

**NOTE**: The project does support a `docker-compose` file that would run all of the containers together