### Setup Development Environment Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/contributing.md Commands to install project dependencies, configure environment variables, and start the local development servers for the AnswerAI project. ```bash pnpm install cp .env.example .env pnpm dev ``` -------------------------------- ### Development Workflow Setup for AnswerAI Contributions Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/contributing.md This snippet outlines the standard development workflow for setting up a local environment, including cloning the repository, creating a feature branch, installing dependencies, and starting the development server. ```bash # Clone your fork git clone https://github.com/YOUR_USERNAME/REPO_NAME.git cd REPO_NAME # Create feature branch git checkout -b feature/your-feature-name # Install dependencies npm install # or pnpm install # Start development server npm run dev ``` -------------------------------- ### Start Local Documentation Server Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/running-locally.md This sequence of bash commands navigates into the `packages/docs` directory and starts the local documentation server using pnpm. This allows developers to preview documentation changes and access the site at `http://localhost:4242`. ```bash cd packages/docs pnpm start ``` -------------------------------- ### Install AnswerAI Project Dependencies Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/running-locally.md Installs all required dependencies for the AnswerAI monorepo across all packages using PNPM, ensuring all modules are available. ```Bash pnpm install ``` -------------------------------- ### Clone AnswerAI Monorepo Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/running-locally.md Clones the AnswerAI monorepo from GitHub and navigates into the project's root directory, preparing for local setup. ```Bash git clone https://github.com/AnswerAI/AnswerAI.git cd AnswerAI ``` -------------------------------- ### PNPM Build and Development Commands Source: https://github.com/the-answerai/theanswer/blob/production/AGENTS.md Lists essential `pnpm` commands for managing project dependencies, building all packages, and starting the development servers. ```bash pnpm install # Install dependencies pnpm build # Build all packages pnpm dev # Start development servers ``` -------------------------------- ### Local Development Setup for TheAnswer AI Source: https://github.com/the-answerai/theanswer/blob/production/README.md This snippet provides the essential commands for setting up TheAnswer AI for local development. It covers cloning the repository, initializing git submodules, installing project dependencies using pnpm, and building the application. It also includes commands to resolve common database or Prisma-related build issues and to start the local development server, accessible via http://localhost:3000. Users must also manually create .env files and configure a PostgreSQL database. ```bash git clone https://github.com/the-answerai/theanswer.git cd theanswer ``` ```bash git submodule update --init ``` ```bash pnpm install ``` ```bash pnpm build ``` ```bash pnpm build --force ``` ```bash pnpm db:migrate ``` ```bash pnpm dev ``` -------------------------------- ### Run AnswerAI in Development Mode Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/running-locally.md Starts both the backend server and frontend development server for AnswerAI, enabling live reloading and facilitating rapid development. ```Bash pnpm dev ``` -------------------------------- ### Install Flowise via npm Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/authorization/app-level.md This command installs the Flowise application globally using the Node Package Manager (npm). It's the first step before starting the Flowise server. ```bash npm install -g flowise ``` -------------------------------- ### Start LocalAI Service with Docker Compose (Bash) Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/chat-models/chatlocalai.md Starts the LocalAI service using Docker Compose, running it in detached mode (-d) and ensuring the latest images are pulled (--pull always) for a robust setup. ```bash docker compose up -d --pull always ``` -------------------------------- ### Start Flowise API Documentation Server Standalone Source: https://github.com/the-answerai/theanswer/blob/production/packages/api-documentation/README.md Navigate to the API documentation package directory and start the server using pnpm. This command launches the server hosting the Flowise API documentation. ```shell cd packages/api-documentation pnpm start ``` -------------------------------- ### New Feature Video Structure Example Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/video-guide.md An example outline for structuring a video that demonstrates a new feature, covering introduction, demo, technical implementation, and impact. ```text 1. Introduction (25 seconds) "I built a new document summarization feature for the browser extension..." 2. Feature Demo (75 seconds) [Show the feature working end-to-end] 3. Technical Implementation (45 seconds) [Explain key code components] 4. Impact & Mission (35 seconds) "This helps users quickly understand content while keeping their data local and private..." ``` -------------------------------- ### Few Shot Prompt Template Node Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/prompts/README.md Details on guiding model behavior with examples using the Few Shot Prompt Template node. ```APIDOC The Few Shot Prompt Template node enables you to provide examples to guide the model's behavior. This is particularly useful when you want the model to follow a specific pattern or format in its responses. ``` -------------------------------- ### Bug Fix Video Structure Example Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/video-guide.md An example outline for structuring a video that demonstrates a bug fix, detailing sections from introduction to mission connection. ```text 1. Introduction (20 seconds) "I fixed a critical bug in the chat interface where messages weren't displaying properly in dark mode..." 2. Problem Demonstration (45 seconds) [Show the bug occurring, explain impact on users] 3. Solution Walkthrough (60 seconds) [Show code changes, explain the fix] 4. Testing & Verification (30 seconds) [Demonstrate the fix working] 5. Mission Connection (25 seconds) "This improves accessibility and ensures our privacy-focused chat works for all users..." ``` -------------------------------- ### Install Project Dependencies with Yarn Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/README.md This command installs all required project dependencies using the Yarn package manager. It should be run once after cloning the repository. ```shell $ yarn ``` -------------------------------- ### Example Unit Test for Resource API Source: https://github.com/the-answerai/theanswer/blob/production/AGENTS.md This unit test demonstrates how to test the resource creation API endpoint. It includes setting up test data, making an authenticated POST request using `supertest`, and asserting that the response contains the expected properties. ```typescript // packages/server/test/api/resource.test.ts describe('Resource API', () => { beforeEach(async () => { // Setup test data }) it('should create resource', async () => { const response = await request(app) .post('/api/v1/resources') .set('Authorization', `Bearer ${TEST_TOKEN}`) .send(testData) .expect(200) expect(response.body).toHaveProperty('id') }) }) ``` -------------------------------- ### BWS Secure Basic CLI Commands Source: https://github.com/the-answerai/theanswer/blob/production/scripts/bws-secure/README.md Essential `pnpm` commands for development, production builds, starting the server, listing projects, and verifying BWS installation. ```bash # Development pnpm dev # Production build pnpm build # Start production server pnpm start # List available projects pnpm list-projects # Verify BWS installation pnpm bws-deps ``` -------------------------------- ### Product Naming Prompt Template and Example Values Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/prompts/prompt-template.md Illustrates a prompt template designed for generating product names, including placeholders for product type, key features, and target audience, along with example JSON data. ```text Generate 5 creative names for a {product_type} that emphasizes its {key_feature}. The target audience is {target_audience}. ``` ```json { "product_type": "smartphone", "key_feature": "long battery life", "target_audience": "busy professionals" } ``` -------------------------------- ### Start Flowise Server Standalone Source: https://github.com/the-answerai/theanswer/blob/production/packages/api-documentation/README.md Navigate to the Flowise directory and start the server using pnpm. This command initiates the Flowise backend for standalone operation. ```shell cd Flowise pnpm start ``` -------------------------------- ### Recommended SQL Prompt Format for LLMs Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/use-cases/sql-qna.md This snippet illustrates the recommended format for providing SQL database schema and example data to a Large Language Model (LLM). It includes a CREATE TABLE statement, a SELECT query, column headers, and sample data rows, designed to guide the LLM in generating accurate SQL queries. ```sql CREATE TABLE samples (firstName varchar NOT NULL, lastName varchar) SELECT * FROM samples LIMIT 3 firstName lastName Stephen Tyler Jack McGinnis Steven Repici ``` -------------------------------- ### Build AnswerAI Monorepo Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/running-locally.md Compiles and builds all packages within the AnswerAI monorepo, preparing the application for execution or deployment. ```Bash pnpm build ``` -------------------------------- ### Content Summarization Prompt Template and Example Values Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/prompts/prompt-template.md Shows a prompt template for summarizing content, allowing specification of content type, word count, and the content itself, along with example JSON data. ```text Summarize the following {content_type} in {word_count} words or less, focusing on the main points and key takeaways: {content} ``` ```json { "content_type": "research paper", "word_count": 150, "content": "... (full text of the research paper) ..." } ``` -------------------------------- ### Example PostgreSQL Connection URL Source: https://github.com/the-answerai/theanswer/blob/production/scripts/seed-credentials/README.md Provides a concrete example of a PostgreSQL connection URL, illustrating the structure with typical values for username, password, host, port, and database name. This example is representative of URLs used for cloud database providers. ```APIDOC postgresql://admin:mypassword@dpg-abc123.oregon-postgres.render.com/mydatabase ``` -------------------------------- ### BWS Secure Debugging Command Examples Source: https://github.com/the-answerai/theanswer/blob/production/scripts/bws-secure/README.md Practical `bash` examples illustrating how to use `pnpm secure-run` with different debugging flags and environment settings for common scenarios like local development, production checks, and specific project debugging. ```bash DEBUG=true SHOW_DECRYPTED=true pnpm secure-run next dev ``` ```bash DEBUG=true SHOW_DECRYPTED=true BWS_ENV=prod pnpm secure-run ``` ```bash DEBUG=true SHOW_DECRYPTED=true BWS_PROJECT=my-project BWS_ENV=dev pnpm secure-run ``` ```bash DEBUG=true VERBOSE=true SHOW_DECRYPTED=true pnpm secure-run ``` -------------------------------- ### Example BWS Project Environment File Source: https://github.com/the-answerai/theanswer/blob/production/scripts/bws-secure/upload-to-bws/readme.md An example of a `.env.bws.*` file, demonstrating how to define secrets for a specific Bitwarden project, including comments and empty lines. ```env # Production Environment (.env.bws.467a446c-bd75-46bd-9a35-b2740186e3a1) CONTENTFUL_SPACE_ID=your_space_id API_KEY=your_api_key DATABASE_URL=your_db_url # Comments and empty lines are ok NEXT_PUBLIC_API_URL=https://api.example.com ``` -------------------------------- ### Verify Flowise production build and start Source: https://github.com/the-answerai/theanswer/blob/production/CONTRIBUTING.md Performs a final build and then starts the application to ensure all changes work correctly in a production-like environment before committing code. ```bash pnpm build pnpm start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/the-answerai/theanswer/blob/production/scripts/bws-secure/upload-to-bws/readme.md Command to install project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Troubleshooting Failed `pnpm install` Source: https://github.com/the-answerai/theanswer/blob/production/scripts/dependabot-batch-processing-playbook.md Commands and guidance for diagnosing issues when `pnpm install` fails during a Dependabot update. It suggests checking for peer dependency warnings versus actual installation errors and how to revert and document if real errors occur. ```bash # Check for peer dependency warnings (usually safe to ignore) # Check for actual installation errors # If real errors: git checkout -- . # Document the failure # Continue with next update ``` -------------------------------- ### Customer Support Response Generator Few-Shot Prompt Template Configuration (JavaScript/JSON) Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/prompts/few-shot-prompt-template.md This configuration illustrates a few-shot prompt template for generating consistent customer support responses. It includes examples of customer queries and corresponding support agent replies, guiding the AI to respond effectively and maintain a helpful tone. ```javascript { "examples": [ { "query": "How do I reset my password?", "response": "To reset your password, please follow these steps:\n1. Go to the login page\n2. Click on 'Forgot Password'\n3. Enter your email address\n4. Follow the instructions sent to your email" }, { "query": "What are your business hours?", "response": "Our customer support is available 24/7. Our physical stores are open Monday to Friday, 9 AM to 6 PM, and Saturday 10 AM to 4 PM. We are closed on Sundays and public holidays." } ], "examplePrompt": "Customer: {query}\n\nSupport Agent: {response}", "prefix": "You are a helpful customer support agent. Respond to the customer query based on the following examples:", "suffix": "Customer: {input}\n\nSupport Agent:", "exampleSeparator": "\n\n---\n\n" } ``` -------------------------------- ### Flowise Application Build Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/deployment/gcp.md Steps to clone the Flowise repository, install project dependencies using pnpm, and build the application for deployment. ```bash git clone https://github.com/FlowiseAI/Flowise.git cd Flowise pnpm install pnpm build ``` -------------------------------- ### Core Authentication Flow Logic Source: https://github.com/the-answerai/theanswer/blob/production/packages/server/AUTHORIZATION.md Demonstrates the primary authentication flow, starting with extracting the bearer token, attempting API key verification, updating usage, and falling back to JWT validation if API key authentication fails. ```typescript // 1. Extract authentication header const authHeader = req.headers.authorization if (!authHeader?.startsWith('Bearer ')) return null // 2. Try API key authentication const apiKey = authHeader.split(' ')[1] const apiKeyData = await apikeyService.verifyApiKey(apiKey) // 3. Verify active status and update usage if (apiKeyData && apiKeyData.isActive) { apiKeyData.lastUsedAt = new Date() // Update and attach user context } // 4. Fallback to JWT if needed if (!apiKeyData) { // JWT validation and user context } ``` -------------------------------- ### Install Flowise project dependencies Source: https://github.com/the-answerai/theanswer/blob/production/CONTRIBUTING.md Installs all required dependencies for the Flowise monorepository's server, UI, and components modules using pnpm. ```bash pnpm install ``` -------------------------------- ### Start Flowise with CLI Environment Variables Source: https://github.com/the-answerai/theanswer/blob/production/CONTRIBUTING.md Demonstrates how to start the Flowise application using the `npx` command, specifying port and debug mode via command-line environment variables. This method allows for quick testing and configuration overrides without modifying environment files. ```Shell npx flowise start --PORT=3000 --DEBUG=true ``` -------------------------------- ### Manually Install BWS Secure Environment Manager Source: https://github.com/the-answerai/theanswer/blob/production/scripts/bws-secure/README.md This sequence of commands allows for a manual installation of the bws-secure manager. It involves cloning the repository, removing the git history, and then running the installation script. ```bash git clone https://github.com/last-rev-llc/bws-secure.git scripts/bws-secure rm -rf scripts/bws-secure/.git bash scripts/bws-secure/install.sh ``` -------------------------------- ### Install Dependencies for OpenAPI Configuration Scripts Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/devscripts/README.md Instructions to install the necessary Node.js packages, specifically 'js-yaml', required for the OpenAPI configuration utility scripts. This step should be performed from the 'packages/docs' directory. ```bash cd packages/docs npm install js-yaml # or with pnpm pnpm add js-yaml ``` -------------------------------- ### Generate SQL Query using Few-Shot Prompting Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/use-cases/sql-qna.md This prompt template is designed for a Large Language Model (LLM) to generate a SQL SELECT ALL query. It takes a database schema and a user's question as input, guiding the LLM to produce a relevant SQL query. The example provided helps the LLM understand the desired output format. ```Prompt Template Based on the provided SQL table schema and question below, return a SQL SELECT ALL query that would answer the user's question. For example: SELECT * FROM table WHERE id = '1'. ------------ SCHEMA: {schema} ------------ QUESTION: {question} ------------ SQL QUERY: ``` -------------------------------- ### Install Project Dependencies for BWS Secure Tests Source: https://github.com/the-answerai/theanswer/blob/production/scripts/bws-secure/tests/README.md Installs all required project dependencies using pnpm before running tests. Ensure proper authentication tokens are set in your .env file for Vercel and Netlify tests. ```bash pnpm install ``` -------------------------------- ### Customer Support Response Prompt Template and Example Values Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/prompts/prompt-template.md Provides a prompt template for crafting customer support responses, incorporating placeholders for company name and customer inquiry, with example JSON data. ```text You are a customer support representative for {company_name}. Craft a polite and helpful response to the following customer inquiry: Customer: {customer_inquiry} Your response should address the customer's concern and provide a solution if possible. If you need more information, ask for it politely. ``` ```json { "company_name": "TechGadgets Inc.", "customer_inquiry": "I received my new smartwatch yesterday, but I can't figure out how to pair it with my phone. Can you help?" } ``` -------------------------------- ### Initialize Terraform Project Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/deployment/azure.md Prepares the Terraform working directory by downloading necessary providers and modules required for the Azure deployment, ensuring all dependencies are met. ```bash terraform init ``` -------------------------------- ### Install Node.js Dependencies for Chatflow Testing Source: https://github.com/the-answerai/theanswer/blob/production/scripts/testing-chatflows/README.md Use this command to install all required Node.js packages, setting up the project environment for AnswerAI chatflow testing. ```bash npm install ``` -------------------------------- ### Example Environment Variable File Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/deployment/aws.md This snippet shows an example of an environment variable file (.env) used by Copilot to inject configuration into the deployed application. It lists common variables like port, API keys, and telemetry settings. ```bash PORT=3000 APIKEY_PATH=/path/to/api/key SECRETKEY_PATH=/path/to/secret/key LOG_PATH=/path/to/logs DISABLE_FLOWISE_TELEMETRY=true IFRAME_ORIGINS=https://example.com MY_APP_VITE_AUTH_DOMAIN=your-auth-domain MY_APP_VITE_AUTH_CLIENT_ID=your-auth-client-id ... ``` -------------------------------- ### Confluence Query Language (CQL) Basic Syntax and Examples Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/tools-mcp/confluence-mcp.md Illustrates the fundamental syntax of Confluence Query Language (CQL) for searching pages, along with common field examples like space, title, label, and date filters. This syntax is used with the `search_pages` tool. ```CQL # Basic syntax field operator value # Examples space = "Engineering" title ~ "Meeting Notes" label = documentation created >= 2023-01-01 ``` -------------------------------- ### Install AWS Copilot CLI Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/deployment/aws.md This snippet provides the command to install the AWS Copilot command-line interface on macOS using Homebrew. Copilot simplifies containerized application deployment on AWS. ```bash brew install aws/tap/copilot-cli ``` -------------------------------- ### Technical Support System Example with Retrieval QA Chain Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/chains/retrieval-qa-chain.md Provides a practical example of integrating the AnswerAI Retrieval QA Chain into a technical support system, showing how to query a domain-specific knowledge base for answers to user questions. ```python import requests API_URL = "http://localhost:3000/api/v1/prediction/" API_KEY = "your-api-key" def technical_support(query): data = { "question": query, "overrideConfig": { "vectorStoreRetriever": { "type": "pinecone", "indexName": "technical-support-docs" } } } response = requests.post(API_URL, json=data, headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" }) return response.json()['text'] # Usage print(technical_support("How do I reset my router?")) print(technical_support("What are the system requirements for the latest software update?")) ``` -------------------------------- ### GitHub API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for GitHub. Refer to the official guide (https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) on how to get accessToken on Github. ```APIDOC Inputs: Access Token: password ``` -------------------------------- ### Start Next.js Development Server Source: https://github.com/the-answerai/theanswer/blob/production/apps/web/README.md This command initiates the Next.js development server, making the application accessible locally. It enables hot-reloading for rapid development. ```bash yarn dev ``` -------------------------------- ### Airtable API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Airtable. Refer to the official guide (https://support.airtable.com/docs/creating-and-using-api-keys-and-access-tokens) on how to get accessToken on Airtable. ```APIDOC Inputs: Access Token: password ``` -------------------------------- ### Slack API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Slack. Refer to the official guide (https://github.com/modelcontextprotocol/servers/tree/main/src/slack) on how to get botToken and teamId on Slack. ```APIDOC Inputs: Bot Token: password Team ID: string ``` -------------------------------- ### Salesforce API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Salesforce. Refer to the official guide (https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/sforce_analytics_rest_api_get_started.htm) on how to get your Salesforce API key. ```APIDOC Inputs: Salesforce Client ID: password Salesforce Client Secret: password Salesforce Instance: string (e.g., https://na1.salesforce.com) ``` -------------------------------- ### Figma API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Figma. Refer to the official guide (https://www.figma.com/developers/api#access-tokens) on how to get accessToken on Figma. ```APIDOC Inputs: Access Token: password ``` -------------------------------- ### Example .env Configuration File Source: https://github.com/the-answerai/theanswer/blob/production/scripts/seed-credentials/README.md A sample .env file illustrating typical configurations for database connection, security, and connection recovery, including placeholders for user-specific values. ```env # Database Configuration (Primary) DATABASE_TYPE=postgres DATABASE_HOST=localhost DATABASE_PORT=5432 DATABASE_USER=your_db_user DATABASE_PASSWORD=your_db_password DATABASE_NAME=flowise # Database Connection Recovery (Fallback) DATABASE_SECURE_EXTERNAL_URL=postgresql://user:pass@host.render.com/database DATABASE_SSL=true # Security FLOWISE_SECRETKEY_OVERWRITE=your-secret-encryption-key ``` -------------------------------- ### Install all project dependencies using PNPM Source: https://github.com/the-answerai/theanswer/blob/production/README.md This command uses PNPM to install all required dependencies for all modules within the TheAnswer monorepo. It ensures that all necessary packages are available for building and running the application. ```bash pnpm install ``` -------------------------------- ### Install BWS Secure Environment Manager using HTTPS Source: https://github.com/the-answerai/theanswer/blob/production/scripts/bws-secure/README.md This command clones the bws-secure repository via HTTPS, removes the .git directory, and then executes the installation script. This method is universally compatible. ```bash git clone https://github.com/last-rev-llc/bws-secure.git scripts/bws-secure && rm -rf scripts/bws-secure/.git && bash scripts/bws-secure/install.sh ``` -------------------------------- ### Arize API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Arize observability platform. Refer to the official guide (https://docs.arize.com/arize) on how to get API keys on Arize. ```APIDOC Inputs: API Key: password Space ID: string Endpoint: string (default: https://otlp.arize.com) ``` -------------------------------- ### Install Project Dependencies using npm or pnpm Source: https://github.com/the-answerai/theanswer/blob/production/scripts/seed-credentials/README.md This bash snippet provides commands to install the necessary npm packages for the project using either 'npm' or 'pnpm'. The listed dependencies include 'typeorm', 'dotenv', and 'crypto-js', which are crucial for database ORM, environment variable loading, and encryption functionalities. ```bash # Install required dependencies npm install typeorm dotenv crypto-js # Or with pnpm pnpm install typeorm dotenv crypto-js ``` -------------------------------- ### Meilisearch API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Provides authentication details for Meilisearch. Users should refer to the official guide (https://meilisearch.com) on how to get an API Key. ```APIDOC Meilisearch API: How to obtain: Refer to official guide on how to get an API Key. Inputs: - Meilisearch Search API Key (password) - Meilisearch Admin API Key (password, optional) ``` -------------------------------- ### Install PNPM globally using npm Source: https://github.com/the-answerai/theanswer/blob/production/README.md This command installs the PNPM package manager globally on your system, which is required to manage dependencies for TheAnswer project. It ensures that `pnpm` is available in your command line. ```bash npm i -g pnpm ``` -------------------------------- ### Start TheAnswer application Source: https://github.com/the-answerai/theanswer/blob/production/README.md This command initiates the TheAnswer application, making it accessible locally. After running this, the application should be available in your web browser at `http://localhost:3000`. ```bash pnpm start ``` -------------------------------- ### Elasticsearch API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Provides authentication details for Elasticsearch. Users should refer to the official guide (https://www.elastic.co/guide/en/kibana/current/api-keys.html) on how to get an API Key from Elasticsearch. ```APIDOC Elasticsearch API: How to obtain: Refer to official guide on how to get an API Key from ElasticSearch. Inputs: - Elasticsearch Endpoint - Elasticsearch API Key (password) ``` -------------------------------- ### Voyage AI API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Voyage AI embedding services. Refer to the official guide (https://docs.voyageai.com/install/#authentication-with-api-keys) on how to get an API Key. ```APIDOC Inputs: Voyage AI Endpoint: string (default: https://api.voyageai.com/v1/embeddings) Voyage AI API Key: password ``` -------------------------------- ### Start Local Development Server with Yarn Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/README.md Initiates a local development server for the website. This command automatically opens a browser window and supports live reloading, reflecting most changes without a server restart. ```shell $ yarn start ``` -------------------------------- ### Start AnswerAI Application with pnpm Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/building-node.md Launches the AnswerAI application after a successful build using pnpm. This command initializes the server and makes the AnswerAI interface accessible, typically through a web browser. Ensure the build step is completed first. ```bash pnpm start ``` -------------------------------- ### TypeScript: Basic Parameter Validation Source: https://github.com/the-answerai/theanswer/blob/production/AGENTS.md Provides an example of validating required request parameters. If a parameter is missing, it throws an `InternalFlowiseError` with a `PRECONDITION_FAILED` status. ```typescript // Always validate required parameters if (!req.params.id) { throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, 'Error: controller.method - id not provided!') } ``` -------------------------------- ### Contentful Management API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Contentful's content management. Refer to the official guide (https://www.contentful.com/developers/docs/references/content-Management-api/) on how to get your Management and preview keys in Contentful. ```APIDOC Inputs: Management Token: string Space Id: string ``` -------------------------------- ### Contentful Delivery API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Contentful's content delivery. Refer to the official guide (https://www.contentful.com/developers/docs/references/content-delivery-api/) on how to get your delivery and preview keys in Contentful. ```APIDOC Inputs: Delivery Token: string Preview Token: string Space Id: string ``` -------------------------------- ### Run Inngest Local Development Server Source: https://github.com/the-answerai/theanswer/blob/production/apps/web/README.md This command starts the Inngest local development server, connecting it to the specified API endpoint. It allows for local testing and synchronization of event-driven functions. ```bash npx inngest-cli@latest dev -u http://localhost:3000/api/inngest ``` -------------------------------- ### Create Azure Container Instance for Flowise Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/deployment/azure.md Deploys a Flowise container instance on Azure, configuring its image, command line, environment variables for credentials, public IP address, exposed ports (80 and 3000), and a restart policy for failure recovery. ```bash az container create -g flowise-rg \ --name flowise \ --image flowiseai/flowise \ --command-line "/bin/sh -c 'flowise start'" \ --environment-variables FLOWISE_USERNAME=flowise-user FLOWISE_PASSWORD=flowise-password \ --ip-address public \ --ports 80 3000 \ --restart-policy OnFailure ``` -------------------------------- ### YAML Configuration for Knowledge Base Creation Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/document-loaders/google-drive.md This configuration snippet demonstrates how to set up AnswerAI to build a searchable knowledge base. It specifies input files, PDF processing options ('One document per page'), enables text splitting, and adds custom metadata ('category': 'knowledge_base') for enhanced organization and searchability. ```yaml Configuration: Files: ['Company Handbook.pdf', 'Process Documents/', 'FAQ.docx'] PDF Usage: 'One document per page' Text Splitter: Enabled Additional Metadata: { 'category': 'knowledge_base' } Purpose: Build searchable knowledge base from company documents ``` -------------------------------- ### Confluence Server/Data Center API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Confluence Server or Data Center. Refer to the official guide (https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html/) on how to get Personal Access Token on Confluence. ```APIDOC Inputs: Personal Access Token: password ``` -------------------------------- ### Confluence Cloud API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Authentication for Confluence Cloud. Refer to the official guide (https://support.atlassian.com/confluence-cloud/docs/manage-oauth-access-tokens/) on how to get Access Token or API Token (https://id.atlassian.com/manage-profile/security/api-tokens) on Confluence. ```APIDOC Inputs: Access Token: password Username/Email: string Base URL: string ``` -------------------------------- ### Exa Search API Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Provides authentication details for Exa Search. Users should refer to the official guide (https://docs.exa.ai/reference/getting-started#getting-access) on how to get an API Key from Exa. ```APIDOC Exa Search API: How to obtain: Refer to official guide on how to get an API Key from Exa. Inputs: - ExaSearch Api Key (password) ``` -------------------------------- ### Execute Component Tests with pnpm Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/running-locally.md This bash command initiates the project's component-level test suite using pnpm. It's used to verify individual components in isolation, ensuring their correctness and behavior. ```bash pnpm test:cmp ``` -------------------------------- ### Elasticsearch User Password Authentication Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/credentials/api-credentials.md Provides authentication details for Elasticsearch using username and password. Users should refer to the official guide (https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-up-authentication.html) on how to get User Password from Elasticsearch. ```APIDOC ElasticSearch User Password: How to obtain: Refer to official guide on how to get User Password from ElasticSearch. Inputs: - Cloud ID (Elastic Cloud ID or server URL) - ElasticSearch User - ElasticSearch Password ``` -------------------------------- ### Retrieve SQL Database Schema and Example Rows (JavaScript) Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/use-cases/sql-qna.md This JavaScript code connects to a SingleStore database using `mysql2/promise`. It fetches the table schema and the first three rows of a specified table. The retrieved information is then formatted into a single string, combining the `CREATE TABLE` statement, a `SELECT` query, column names, and sample data, suitable for use as a prompt for a Large Language Model. ```javascript const HOST = 'singlestore-host.com' const USER = 'admin' const PASSWORD = 'mypassword' const DATABASE = 'mydb' const TABLE = 'samples' const mysql = require('mysql2/promise') let sqlSchemaPrompt function getSQLPrompt() { return new Promise(async (resolve, reject) => { try { const singleStoreConnection = mysql.createPool({ host: HOST, user: USER, password: PASSWORD, database: DATABASE }) // Get schema info const [schemaInfo] = await singleStoreConnection.execute( `SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = "${TABLE}"` ) const createColumns = [] const columnNames = [] for (const schemaData of schemaInfo) { columnNames.push(`${schemaData['COLUMN_NAME']}`) createColumns.push( `${schemaData['COLUMN_NAME']} ${schemaData['COLUMN_TYPE']} ${schemaData['IS_NULLABLE'] === 'NO' ? 'NOT NULL' : ''}` ) } const sqlCreateTableQuery = `CREATE TABLE samples (${createColumns.join(', ')})` const sqlSelectTableQuery = `SELECT * FROM samples LIMIT 3` // Get first 3 rows const [rows] = await singleStoreConnection.execute(sqlSelectTableQuery) const allValues = [] for (const row of rows) { const rowValues = [] for (const colName in row) { rowValues.push(row[colName]) } allValues.push(rowValues.join(' ')) } sqlSchemaPrompt = sqlCreateTableQuery + '\n' + sqlSelectTableQuery + '\n' + columnNames.join(' ') + '\n' + allValues.join('\n') resolve() } catch (e) { console.error(e) return reject(e) } }) } async function main() { await getSQLPrompt() } await main() return sqlSchemaPrompt ``` -------------------------------- ### Reschedule Google Calendar Event Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/tools/google-calendar.md Example of updating an existing Google Calendar event by changing only its start and end times using its unique Event ID. This demonstrates a partial update operation. ```APIDOC Event ID: abc123def456 Start: 2024-01-15 16:00 End: 2024-01-15 17:00 ``` -------------------------------- ### Execute End-to-End Tests with pnpm Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/running-locally.md This bash command initiates the project's end-to-end test suite using pnpm. It's used to verify the complete system functionality and integration across different components. ```bash pnpm test:e2e ``` -------------------------------- ### Create Basic Google Calendar Event Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/tools/google-calendar.md Example of creating a new Google Calendar event with only essential details: title, start, and end times. This demonstrates the minimum required input for event creation. ```APIDOC Title: Team Meeting Start: 2024-01-15 14:00 End: 2024-01-15 15:00 ``` -------------------------------- ### Multi-tenancy Resource Filtering Example Source: https://github.com/the-answerai/theanswer/blob/production/AGENTS.md This snippet illustrates how resources are scoped for multi-tenancy by filtering queries based on `organizationId`. For non-admin users, an additional `userId` filter ensures access is restricted to owned resources. ```typescript // Always filter by organization in queries const filter = { organizationId: user.organizationId, userId: user.id // For non-admin users } ``` -------------------------------- ### Clone Application Repository Source: https://github.com/the-answerai/theanswer/blob/production/DEPLOYMENT_COPILOT.md Clones the specified GitHub repository for the application and navigates into its directory to prepare for deployment. ```bash git clone https://github.com/the-answerai/theanswer cd Flowise ``` -------------------------------- ### Antonym Generator Few-Shot Prompt Template Configuration (JavaScript/JSON) Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/prompts/few-shot-prompt-template.md This configuration demonstrates how to set up a few-shot prompt template to generate antonyms. It provides examples of word-antonym pairs and defines the structure for the input and output, guiding the AI to produce correct antonyms. ```javascript { "examples": [ { "word": "happy", "antonym": "sad" }, { "word": "tall", "antonym": "short" }, { "word": "rich", "antonym": "poor" } ], "examplePrompt": "Word: {word}\nAntonym: {antonym}", "prefix": "Generate antonyms for the following words:", "suffix": "Word: {input}\nAntonym:", "exampleSeparator": "\n\n" } ``` -------------------------------- ### Initialize AWS Copilot Application Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/deployment/aws.md This command initializes a new AWS Copilot application within the AnswerAI project, linking it to a specified domain name. It sets up the foundational structure for Copilot deployments. ```bash copilot app init --domain ``` -------------------------------- ### Clone Application Repository with Git Source: https://github.com/the-answerai/theanswer/blob/production/DEPLOYMENT.md Clones the specified application repository from GitHub and navigates into its directory to prepare for deployment. ```bash git clone https://github.com/the-answerai/theanswer cd Flowise ``` -------------------------------- ### Example Chat Prompt Template for Language Translation Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/prompts/chat-prompt-template.md Demonstrates how to configure the Chat Prompt Template node for a language translation assistant, including the system message, human message, and dynamic prompt values in JSON format. This setup instructs the AI to act as a translator. ```text You are a helpful assistant that translates {input_language} to {output_language}. ``` ```text {text} ``` ```json { "input_language": "English", "output_language": "Spanish", "text": "Hello, how are you?" } ``` -------------------------------- ### Apply Terraform Deployment Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/deployment/azure.md Executes the actions outlined in the Terraform plan to create or modify Azure resources, deploying the AnswerAI App Service and Postgres database as defined in the configuration. ```bash terraform apply ``` -------------------------------- ### Pull Request Video Explanation Section Template Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/video-guide.md Markdown template for adding a video explanation section to a Pull Request description, including links and a summary. ```markdown ## Video Explanation [YouTube Link] or [Download Link] ### Video Summary: - Demonstrates [functionality] - Explains [technical approach] - Shows [user impact] - Connects to [mission goals] ``` -------------------------------- ### Define JSON Structure for LLM Output Parsing Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/output-parsers/structured-output-parser.md This example illustrates how to configure the JSON Structure within the Structured Output Parser node in AnswerAI. It defines two properties, 'answer' and 'source', specifying their data types and descriptions to guide the LLM in generating structured output. ```APIDOC JSON Structure Configuration: - Property: "answer" Type: "string" Description: "Answer to the user's question" - Property: "source" Type: "string" Description: "Sources used to answer the question, should be websites" ``` -------------------------------- ### Define TypeORM Entities with Consistent Patterns Source: https://github.com/the-answerai/theanswer/blob/production/AGENTS.md TypeORM entities define the structure of database tables, including primary keys, columns, and relationships. This example demonstrates the use of UUIDs for primary keys, multi-tenancy fields (`userId`, `organizationId`), indexing for performance, and timestamp columns for auditing. ```typescript import { Entity, Column, CreateDateColumn, UpdateDateColumn, PrimaryGeneratedColumn, Index } from 'typeorm' import { IResource } from '../../Interface' @Entity() export class Resource implements IResource { @PrimaryGeneratedColumn('uuid') id: string @Column() name: string @Column({ type: 'text', nullable: true }) description?: string @Column({ type: 'timestamp' }) @CreateDateColumn() createdDate: Date @Column({ type: 'timestamp' }) @UpdateDateColumn() updatedDate: Date @Index() @Column({ type: 'uuid', nullable: true }) userId?: string @Index() @Column({ type: 'uuid', nullable: true }) organizationId?: string @Column({ type: 'simple-array', enum: ResourceVisibility, default: 'Private' }) visibility?: ResourceVisibility[] } ``` -------------------------------- ### Google OAuth Callback URL Environment Variable Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/developers/authorization/google-oauth.md Example of setting the GOOGLE_CALLBACK_URL environment variable for Google OAuth integration in AnswerAI. This URL is crucial for Google to redirect users back to your application after successful authentication and must match the authorized redirect URI configured in the Google Cloud Console. ```shell # GOOGLE_CALLBACK_URL=https://yourdomain.com/api/v1/callback/googleoauth ``` -------------------------------- ### Initialize AWS Copilot Application Source: https://github.com/the-answerai/theanswer/blob/production/DEPLOYMENT_COPILOT.md Initializes a new AWS Copilot application, setting up the application's domain structure for future environments. ```bash copilot app init --domain ${env}.flowise.theanswer.ai ``` -------------------------------- ### Testing Dependabot Updates with pnpm Source: https://github.com/the-answerai/theanswer/blob/production/scripts/dependabot-progress-EXAMPLE.md This snippet provides the shell commands used to validate Dependabot updates. It includes commands for installing dependencies and building the project, as well as a command for resolving lockfile conflicts by regenerating the lockfile after manual package.json updates. ```Shell pnpm install && pnpm build ``` ```Shell pnpm install ``` -------------------------------- ### Start Flowise server Source: https://github.com/the-answerai/theanswer/blob/production/packages/server/README.md Command to start the Flowise server locally. Once started, the application is typically accessible via a web browser at http://localhost:3000. ```bash npx flowise start ``` -------------------------------- ### Express.js RESTful API Route Definition (TypeScript) Source: https://github.com/the-answerai/theanswer/blob/production/AGENTS.md Shows the standard pattern for defining RESTful API routes in TheAnswer's `packages/server` using Express.js. Routes utilize authentication middleware (`enforceAbility`) and define standard CRUD operations (POST, GET, PUT, DELETE) for a given resource. This ensures consistent API design and security. ```typescript // packages/server/src/routes/resource/index.ts import express from 'express' import resourceController from '../../controllers/resource' import enforceAbility from '../../middlewares/authentication/enforceAbility' const router = express.Router() // CREATE router.post('/', enforceAbility('Resource'), resourceController.createResource) // READ router.get('/', enforceAbility('Resource'), resourceController.getAllResources) router.get('/:id', enforceAbility('Resource'), resourceController.getResourceById) // UPDATE router.put('/:id', enforceAbility('Resource'), resourceController.updateResource) // DELETE router.delete('/:id', enforceAbility('Resource'), resourceController.deleteResource) export default router ``` -------------------------------- ### Manually Run OpenAPI Documentation Sync Script Source: https://github.com/the-answerai/theanswer/blob/production/scripts/README.md This snippet provides instructions for manually initiating the OpenAPI documentation synchronization process. It involves changing the current directory to the scripts folder, installing Node.js package dependencies, and then executing the script via an npm run command. ```bash cd scripts npm install npm run sync-openapi ``` -------------------------------- ### Start Node Component Overview Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/agentflows/sequential-agents/start-node.md Defines the core functionalities, inputs, and outputs of the Start Node within the Sequential Agent architecture, serving as the entry point for all workflows. ```APIDOC Start Node: Description: The entry point for all workflows in the Sequential Agent architecture. Receives initial user query, initializes conversation State, and sets the flow in motion. Core Functionalities: - Defining the default LLM: Specifies a Chat Model (LLM) compatible with function calling. - Initializing Memory: Optionally connects an Agent Memory Node for conversation history. - Setting a custom State: Allows connecting a State Node for additional workflow-relevant information. - Enabling moderation: Optionally connects Input Moderation to prevent harmful content. Inputs: - Chat Model: Required: Yes Description: The default LLM that will power the conversation. Only compatible with models capable of function calling. - Agent Memory Node: Required: No Description: Connects to enable persistence and context preservation. - State Node: Required: No Description: Connects to set a custom State, a shared context accessible and modifiable by other nodes. - Input Moderation: Required: No Description: Connects a Moderation Node to filter content by detecting text that could generate harmful output. Outputs: - Agent Node: Routes conversation flow to an Agent Node for action execution or tool access. - LLM Node: Routes conversation flow to an LLM Node for processing and response generation. - Condition Agent Node: Connects to implement branching logic based on agent's evaluation. - Condition Node: Connects to implement branching logic based on predefined conditions. ``` -------------------------------- ### Requests Get Tool API Reference Source: https://github.com/the-answerai/theanswer/blob/production/packages/docs/docs/sidekick-studio/chatflows/tools/request-get.md Defines the parameters and usage for the Requests Get tool within AnswerAI workflows, allowing agents to interact with external APIs. ```APIDOC Requests Get Tool: Description: Executes HTTP GET requests within AnswerAI workflows. Parameters: - name: URL type: string optional: true description: The exact URL to which the agent will make the GET request. - name: Description type: string optional: true description: A prompt to guide the agent on when to use this tool. - name: Headers type: object (key-value pairs) optional: true description: Any additional headers required for the GET request (e.g., authentication tokens). ```