Skip to content

Commit 1441a9f

Browse files
Kannav02luarss
andauthored
Documentation for Backend (#120)
* docs: added documentation for Google, HuggingFace and LangChain * docs: added assets for documentation * chore: removed assets to avoid CI issues --------- Signed-off-by: Kannav02 <kannavsethi02@gmail.com> Co-authored-by: Song Luar <espsluar@gmail.com>
1 parent 5f57e2e commit 1441a9f

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

backend/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Backend For ORAssistant
2+
3+
This folder contains the backend code for the ORAssistant. Follow the instructions below to set up the environment and run the backend.
4+
5+
## Preparing the Environment Variables
6+
7+
To configure the application, you'll need to set up the environment variables in your `.env` file:
8+
9+
The given command would copy the template for environment variables to a local `.env` file
10+
11+
12+
```
13+
cp .env.example .env
14+
```
15+
16+
17+
### Setting Up Google API Key and Credentials Variables
18+
19+
There are 2 variables that needs to be set up
20+
21+
- `GOOGLE_API_KEY`
22+
23+
This key is used to access the various google cloud functions.
24+
- Go to [Google Cloud Console](https://console.cloud.google.com/)
25+
- Create new project or select existing one
26+
- Enable required APIs:
27+
- Google Gemini API
28+
- Vertex AI API
29+
- Go to APIs & Services > Credentials
30+
- Click "Create Credentials" > "API Key"
31+
- Copy the generated key and it to the `.env` file
32+
33+
- `GOOGLE_APPLICATION_CREDENTIALS`
34+
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
35+
Steps to set up Service Account Credentials:
36+
- In Google Cloud Console, go to IAM & Admin > Service Accounts
37+
- Click "Create Service Account"
38+
Fill in service account details
39+
- Grant required roles:
40+
- Vertex AI User
41+
- Vertex AI Service Agent
42+
- Create key (JSON format)
43+
- Download JSON file
44+
- Store securely and add path to .env:
45+
`GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json`
46+
47+
**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
48+
49+
### Setting Up LangChain Variables
50+
51+
There are 4 variables that needs to be set up
52+
53+
- `LANGCHAIN_TRACING_V2`
54+
55+
This is used to enable LangChain's debugging and monitoring features,
56+
can be set to either `true` or `false`
57+
58+
- `LANGCHAIN_ENDPOINT`
59+
60+
The URL endpoint for LangSmith (LangChain's monitoring platform).
61+
Default value should be `https://api.smith.langchain.com` for cloud-hosted LangSmith.
62+
Used to send trace data, metrics, and debugging information from your LangChain applications.
63+
64+
- `LANGCHAIN_API_KEY`
65+
66+
API key required to authenticate with LangSmith platform.
67+
- Get your key from: https://smith.langchain.com/
68+
- Create account if you don't have one
69+
- Navigate to Settings > API Keys
70+
- Create new API key
71+
- Format: starts with `lsv2_` followed by a unique string
72+
73+
- `LANGCHAIN_PROJECT`
74+
75+
Project identifier in LangSmith to organize and track your traces.
76+
- Create new project in LangSmith dashboard
77+
- Use the project name or ID provided
78+
- Example: "my-rag-project"
79+
- Helps organize different applications/environments
80+
- Multiple apps can share same project
81+
82+
83+
### Setting Up Huggingface User Access Token
84+
85+
To set up the `HF_TOKEN` variable in `.env` file , go through the following instructions:
86+
87+
- Go the official website for [Huggingface](https://huggingface.co/) and either Login or Sign up.
88+
- On the main page click on user access token
89+
- Click on create access token
90+
- Provide only Read Instruction for the token and Click on Generate Token
91+
92+
93+
94+
95+
Provide the value for `HF_TOKEN` with the token that is generated
96+
97+
## Running the Application
98+
99+
### Install Required Packages
100+
101+
Ensure you have the necessary dependencies installed by running:
102+
103+
```bash
104+
pip install -r requirements.txt
105+
```
106+
### Docker Command
107+
108+
If you want to run an isolated container for backend, you can use the following command
109+
110+
```bash
111+
docker build -t (image_name) .
112+
```
113+
114+
Make sure you are in the backend folder before running the above command.
115+
116+
**NOTE**: The project does support a `docker-compose` file that would run all of the containers together

0 commit comments

Comments
 (0)