This is the backend for the AI-Agent project. It is built using NestJS and TypeORM, and it integrates with OpenAI and Pinecone for various AI and database functionalities.
- Clone the repository:
git clone https://github.com/your-repo/ai-agent-backend.git
cd ai-agent-backend
- Install the dependencies:
npm install
- Configuration
Create a .env file in the root directory and add the following configurations:
# Environment Setup
NODE_ENV=development
PORT=4000
# Database configuration
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_db_name
DB_URL=your_database_url
# OpenAI configuration
OPENAI_API_KEY=your_openai_api_key
LLM_MODEL=gpt-4o-mini
# Pinecone configuration
PINECONE_API_KEY=your_pinecone_api_key
INDEX_NAME=your_index_name
INDEX_HOST=your_index_host
TOP_K_VALUE=3
EMBEDDING_MODEL=text-embedding-ada-002
# JWT configuration
JWT_SECRET_KEY=your_jwt_secret_key
# Swagger Docs Setup
API_VERSION='1'
APP_NAME='Ai-Agent'
- Running the Application:
npm run start
The application will be available at http://localhost:4000.
Authentication
POST /auth/login-or-signup: Login or signup a user.
Review (POST)
POST /review/submit-reference: Submit a reference document.POST /review/generate-review: Generate a personalized review.POST /review/submit-feedback: Submit feedback on a review to improve future responses.
Reference
GET /reference/get-reference: Get all references.GET /reference/get-reference/:referenceId: Get a single reference by ID.
Review (GET)
GET /review/get-review: Get all reviews.GET /review/get-review/:reviewId: Get a single review by ID.
LlmService
This service integrates with OpenAI to generate feedback based on a given prompt.
VectorDbService
This service integrates with Pinecone to upsert and search embeddings.
ReviewService
This service handles the logic for generating reviews and processing references.
AuthService
This service handles the authentication logic, including login and signup.
DatabaseService
This service handles the database operations for saving and retrieving references and reviews.
saveReference: Save a reference (e.g., snippet and embedding) to the database.saveReview: Save a review to the database.updateReviewWithFeedback: Update a review with user feedback.getAllReferences: Fetch all references for debugging or audit purposes.getSingleReference: Fetch a single reference by ID.getAllReviews: Fetch all reviews for debugging or audit purposes.getSingleReview: Fetch a single review by ID.
User
Represents a user in the system.
Reference
Represents a reference document in the system.
Review
Represents a review in the system.
This project is licensed under the MIT License.