Skip to content

Commit

Permalink
Answers Integration Beta v1
Browse files Browse the repository at this point in the history
Add support for Airtable text field content

answerai brand

added contentful

removed publisher from this branch

removed textField from the node to fix errors

Update docker-compose to build the repo

Update image

added youtube document loader

added updated contentful loader

Add chatflow API key and sync with Sidekick on create/update

Update .gitignore and constant.js

Update API key functionality and add chatflow domain and API key to request payload

added hidden nav and manu when in iframe

Remove command from compose

optimize dockkerfile

Make dark theme the default

Add DOMAIN env

Add API_KEY env

Add DOMAIN env

Add auth0 integration

Update dockerfile

Add env passthrough for auth

Add env passthrough for auth

Add environment variables for authentication in production

Add production environment variables

Update compose env

Update authentication logging and chatflow domain

Update Dockerfile and env.sh, fix sed command in env.sh, and modify index.js to handle undefined organization ID

Refactor Dockerfile and env.sh scripts, and update App.js and index.js files

Add embed & embed-react, enable credentials for API comms

Improvements

Add SST

Fix authorization issue in API endpoints

Update .gitignore file to ignore .pem files and .env.* files

added option for string or document fo routput and adjusted config

Add lock files to git

Update Docker files

Add CDN and remove quotes from chat prompt so JSON is not malformed

updated to account for queryoveride
  • Loading branch information
maxtechera committed Mar 28, 2024
1 parent f116dba commit 5cf42cd
Show file tree
Hide file tree
Showing 127 changed files with 35,596 additions and 30,183 deletions.
156 changes: 156 additions & 0 deletions .daisyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
const path = require("path");

/** @typedef {DaisyConfig} Config */
const config = (CODE_BASE_PATH) => {
const PINECONE_INDEX_NAME = process.env.DAISY_PINECONE_INDEX_NAME || "daisy";
const PINECONE_NAMESPACE = process.env.DAISY_PINECONE_NAMESPACE || "default";
const DAISY_DIRECTORY_NAME = process.env.DAISY_DIRECTORY_NAME || "daisy";
const DAISY_DIRECTORY = path.join(CODE_BASE_PATH, DAISY_DIRECTORY_NAME);
const MARKDOWN_DIRECTORY =
process.env.MARKDOWN_DIRECTORY || path.join(DAISY_DIRECTORY, "markdown");
const PROMPTS_FILE_PATH =
process.env.PROMPTS_FILE_PATH || path.join(DAISY_DIRECTORY, "prompts");

const TEMPLATE_FILE_PATH =
process.env.TEMPLATE_FILE_PATH || path.join(DAISY_DIRECTORY, "templates");
const ANSWERAI_API_KEY = process.env.ANSWERAI_API_KEY;
const ANSWERAI_EMBEDDINGS_URL =
process.env.DAISY_ANSWERAI_EMBEDDINGS_URL ||
"https://app.theanswer.ai/api/codebase/embeddings";
const ANSWERAI_CHAT_COMPLETION_URL =
process.env.DAISY_ANSWERAI_CHAT_COMPLETION_URL ||
"https://app.theanswer.ai/api/ai/chat-completion";
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const PINECONE_API_KEY = process.env.PINECONE_API_KEY;
const PINECONE_ENVIRONMENT = process.env.PINECONE_ENVIRONMENT;
return {
codeBasePath: CODE_BASE_PATH,
pineconeIndexName: PINECONE_INDEX_NAME,
pineconeNamespace: PINECONE_NAMESPACE,
daisyDirectoryName: DAISY_DIRECTORY_NAME,
markdownDirectory: MARKDOWN_DIRECTORY,
promptsFilePath: PROMPTS_FILE_PATH,
templateFilePath: TEMPLATE_FILE_PATH,
openAiApiKey: OPENAI_API_KEY,
pineconeApiKey: PINECONE_API_KEY,
pineconeEnvironment: PINECONE_ENVIRONMENT,
answerAI: {
apiKey: ANSWERAI_API_KEY,
embeddingsUrl: ANSWERAI_EMBEDDINGS_URL,
chatCompletionUrl: ANSWERAI_CHAT_COMPLETION_URL,
},
invalidPaths: [
"node_modules",
"dist",
"build",
"coverage",
"public",
"static",
"assets",
"images",
"img",
".nextjs",
".next",
".git",
"generated",
".yarn",
"patches",
DAISY_DIRECTORY,
],
invalidFileTypes: [
".prompt",
".csv",
".tsv",
".log",
".docx",
".xls",
".xlsx",
".ppt",
".pptx",
".svg",
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".tiff",
".tif",
".ico",
".mp3",
".mp4",
".wav",
".wma",
".avi",
".mov",
".mpg",
".mpeg",
".zip",
".rar",
".7z",
".tar",
".gz",
".dmg",
".iso",
".exe",
".bin",
".pkg",
".deb",
".rpm",
".lock",
],
invalidFileNames: [
"pnpm-lock.yaml",
"package-lock.json",
"app_pairs.yml",
".env",
".DS_Store",
".gitignore",
],
fileTypes: {
docs: {
fileTypes: [".md", ".mdx", ".txt", "LICENSE.md", "LICENSE"],
skipCompletion: true,
},
react: {
fileTypes: [".jsx", ".tsx"],
prompt: "react.prompt",
template: "react.md",
},
api: {
pathIncludes: ["/api/", "/routes/", "/controllers/", "/services/"],
prompt: "api.prompt",
template: "api.md",
},
config: {
fileTypes: [
".json",
".yaml",
".yml",
".toml",
".ini",
".env",
".env.example",
".daisyrc",
],
prompt: "config.prompt",
template: "config.md",
},
script: {
fileTypes: [".js", ".ts"],
prompt: "script.prompt",
template: "script.md",
},
contentModel: {
pathIncludes: ["content_types"],
prompt: "contentModel.prompt",
template: "contentModel.md",
},
default: {
prompt: "default.prompt",
template: "default.md",
},
},
};
};

module.exports = config;
37 changes: 34 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
node_modules
dist
build
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.turbo
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
**/.sst
docker

LICENSE
README.md
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# editor
.idea
.vscode

# dependencies
**/node_modules
**/package-lock.json
**/yarn.lock
# **/yarn.lock

## logs
**/logs
Expand Down Expand Up @@ -38,9 +36,16 @@
## secrets
**/*.key
**/api.json
**/*.pem
.env.*

## uploads
**/uploads

## compressed
**/*.tgz

daisy

# sst
.sst
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Entire App with Yarn Dev",
"type": "node",
"request": "launch",
"runtimeExecutable": "yarn",
"runtimeArgs": ["dev"],
"timeout": 30000,
"stopOnEntry": false,
"sourceMaps": true,
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"],
"smartStep": true
}
]
}
105 changes: 93 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Build local monorepo image
# docker build --no-cache -t flowise .
# syntax=docker/dockerfile:1

# Run image
# docker run -d -p 3000:3000 flowise
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/go/dockerfile-reference/

FROM node:18-alpine
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7

ARG NODE_VERSION=21

################################################################################
# Use node image for base image for all stages.
FROM node:${NODE_VERSION}-alpine as base

# Set working directory for all build stages.
WORKDIR /app

RUN apk add g++ make py3-pip
RUN apk add --update libc6-compat python3 make g++
# needed for pdfjs-dist
RUN apk add --no-cache build-base cairo-dev pango-dev

# Install Chromium
RUN apk add --no-cache chromium

Expand All @@ -17,16 +27,87 @@ RUN npm install -g pnpm

ENV PUPPETEER_SKIP_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
################################################################################
# Create a stage for installing production dependecies.
FROM base as deps

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.pnpm to speed up subsequent builds.
# Leverage bind mounts to package.json and pnpm.lock to avoid having to copy them
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=packages/ui/package.json,target=packages/ui/package.json \
--mount=type=bind,source=packages/embed/package.json,target=packages/embed/package.json \
--mount=type=bind,source=packages/embed-react/package.json,target=packages/embed-react/package.json \
--mount=type=bind,source=packages/server/package.json,target=packages/server/package.json \
--mount=type=bind,source=packages/components/package.json,target=packages/components/package.json \
--mount=type=bind,source=pnpm.lock,target=pnpm.lock \
--mount=type=cache,target=/root/.pnpm \
pnpm install --production --frozen-lockfile --ignore-engines

WORKDIR /usr/src
################################################################################
# Create a stage for building the application.
FROM deps as build

# Copy app source
# Download additional development dependencies before building, as some projects require
# "devDependencies" to be installed to build. If you don't need this, remove this step.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=packages/ui/package.json,target=packages/ui/package.json \
--mount=type=bind,source=packages/embed/package.json,target=packages/embed/package.json \
--mount=type=bind,source=packages/embed-react/package.json,target=packages/embed-react/package.json \
--mount=type=bind,source=packages/server/package.json,target=packages/server/package.json \
--mount=type=bind,source=packages/components/package.json,target=packages/components/package.json \
--mount=type=bind,source=pnpm.lock,target=pnpm.lock \
--mount=type=cache,target=/root/.pnpm \
pnpm install --frozen-lockfile --ignore-engines

# Copy the rest of the source files into the image.
COPY . .
# Run the build script.
RUN --mount=type=cache,target=/app/node_modules/.cache pnpm run build

################################################################################
# Create a new stage to run the application with minimal runtime dependencies
# where the necessary files are copied from the build stage.
FROM base as final


# Use production node environment by default.
ENV NODE_ENV production

# Copy package.json so that package manager commands can be used.
COPY package.json .
COPY packages/components/package.json ./packages/components/package.json
# Copy ui package.json
COPY packages/ui/package.json ./packages/ui/package.json
COPY packages/embed/package.json ./packages/embed/package.json
COPY packages/embed-react/package.json ./packages/embed-react/package.json
# Copy server package.json
COPY packages/server/package.json ./packages/server/package.json

RUN pnpm install
# Copy the production dependencies from the deps stage and also
# the built application from the build stage into the image.
COPY --from=deps /app/packages/components/node_modules ./packages/components/node_modules
COPY --from=deps /app/packages/server/node_modules ./packages/server/node_modules
COPY --from=deps /app/packages/ui/node_modules ./packages/ui/node_modules
COPY --from=deps /app/packages/embed/node_modules ./packages/embed/node_modules
COPY --from=deps /app/packages/embed-react/node_modules ./packages/embed-react/node_modules
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/packages/components/dist ./packages/components/dist
COPY --from=build /app/packages/components/nodes ./packages/components/nodes
COPY --from=build /app/packages/ui/build ./packages/ui/build
COPY --from=build /app/packages/embed/dist ./packages/embed/dist
COPY --from=build /app/packages/embed-react/dist ./packages/embed-react/dist
COPY --from=build /app/packages/server/dist ./packages/server/dist
COPY --from=build /app/packages/server/bin ./packages/server/bin
COPY --from=build /app/packages/server/marketplaces ./packages/server/marketplaces

RUN pnpm build
# Expose the port that the application listens on.
EXPOSE 4000

EXPOSE 3000
COPY env.sh /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh

CMD [ "pnpm", "start" ]
# Run the application.
ENTRYPOINT ["/docker-entrypoint.d/env.sh"]
CMD ["pnpm", "start"]
4 changes: 4 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
docker build -t answers-flowise . &&
docker tag answers-flowise:latest theanswerai/flowise:latest &&
docker push theanswerai/flowise:latest
Loading

0 comments on commit 5cf42cd

Please sign in to comment.