From f88f3b025ff327c172a83e8a85731bbc0d2a13e8 Mon Sep 17 00:00:00 2001 From: Nikolai Ogorodnik <83036869+ilolm@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:50:24 +0300 Subject: [PATCH] impr(refactor): Created multi-stage in Dockerfile, enhanced ReadMe (@Ilolm) (#770) * Optimize Dockerfile 1. Reduced image size from 2.86GB to 790MB by implementing multi-stage. 2. Optimized image and its security. * Update README.md Added separators for more readability --- Dockerfile | 25 +++++++++++++++++++++---- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e344701593..f010fdbfc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,24 @@ -FROM node:20-alpine -RUN apk add --no-cache python3 py3-pip +# Build +FROM node:20-alpine as build + WORKDIR /app COPY . /app -RUN yarn install && yarn compile + +RUN apk update --no-cache && \ + apk add --no-cache python3 py3-pip && \ + + echo "Installing && Compiling" && \ + yarn install && yarn compile + + +# Prod +FROM node:20-alpine + +# Copy the necessary files from the build stage +COPY --from=build /app/packages/cli/built /app/packages/cli/built +COPY --from=build /app/node_modules /app/node_modules +COPY --from=build /app/package.json /app/package.json + EXPOSE 8003 -CMD ["node", "packages/cli/built/genaiscript.cjs", "serve"] \ No newline at end of file + +CMD ["node", "/app/packages/cli/built/genaiscript.cjs", "serve"] diff --git a/README.md b/README.md index e42e3a2ff4..57d5c59579 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,22 @@ https://github.com/user-attachments/assets/ce181cc0-47d5-41cd-bc03-f220407d4dd0 +--- + ## 🌟 Introduction GenAIScript is a powerful scripting environment tailored for building and managing Large Language Model (LLM) prompts with ease. Whether you are a developer, data scientist, or researcher, GenAIScript provides the tools you need to create, debug, and share scripts efficiently. > 🤖 This readme is maintained by the [readme-updater](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/readme-updater.genai.mts) script. +--- + ## 🚀 Quickstart Guide Get started quickly by installing the [Visual Studio Code Extension](https://microsoft.github.io/genaiscript/getting-started/installation/) or using the [command line](https://microsoft.github.io/genaiscript/getting-started/installation). +--- + ## ✨ Features ### 🎨 Stylized JavaScript & TypeScript @@ -30,10 +36,14 @@ def("FILE", env.files, { endsWith: ".pdf" }) $`Summarize FILE. Today is ${new Date()}.` ``` +--- + ### 🚀 Fast Development Loop Edit, [Debug](https://microsoft.github.io/genaiscript/getting-started/debugging-scripts/), [Run](https://microsoft.github.io/genaiscript/getting-started/running-scripts/), and [Test](https://microsoft.github.io/genaiscript/getting-started/testing-scripts/) your scripts in [Visual Studio Code](https://microsoft.github.io/genaiscript/getting-started/installation) or with the [command line](https://microsoft.github.io/genaiscript/getting-started/installation). +--- + ### 🔗 Reuse and Share Scripts Scripts are [files](https://microsoft.github.io/genaiscript/reference/scripts/)! They can be versioned, shared, and forked. @@ -47,6 +57,8 @@ const schema = defSchema("DATA", { type: "array", items: { type: "string" } }) $`Analyze FILE and extract data to JSON using the ${schema} schema.` ``` +--- + ### 📋 Data Schemas Define, validate, and repair data using [schemas](https://microsoft.github.io/genaiscript/reference/scripts/schemas). @@ -56,6 +68,8 @@ const data = defSchema("MY_DATA", { type: "array", items: { ... } }) $`Extract data from files using ${data} schema.` ``` +--- + ### 📄 Ingest Text from PDFs, DOCX, ... Manipulate [PDFs](https://microsoft.github.io/genaiscript/reference/scripts/pdf), [DOCX](https://microsoft.github.io/genaiscript/reference/scripts/docx), ... @@ -65,6 +79,8 @@ def("PDF", env.files, { endsWith: ".pdf" }) const { pages } = await parsers.PDF(env.files[0]) ``` +--- + ### 📊 Ingest Tables from CSV, XLSX, ... Manipulate tabular data from [CSV](https://microsoft.github.io/genaiscript/reference/scripts/csv), [XLSX](https://microsoft.github.io/genaiscript/reference/scripts/xlsx), ... @@ -75,6 +91,8 @@ const rows = await parsers.CSV(env.files[0]) defData("ROWS", rows, { sliceHead: 100 }) ``` +--- + ### 📝 Generate Files Extract files and diff from the LLM output. Preview changes in Refactoring UI. @@ -88,6 +106,8 @@ FILE ./poem.txt The quick brown fox jumps over the lazy dog. ``` +--- + ### 🔍 File Search Grep or fuzz search [files](https://microsoft.github.io/genaiscript/reference/scripts/files). @@ -96,6 +116,8 @@ Grep or fuzz search [files](https://microsoft.github.io/genaiscript/reference/sc const { files } = await workspace.grep(/[a-z][a-z0-9]+/, { globs: "*.md" }) ``` +--- + ### LLM Tools Register JavaScript functions as **tools**. @@ -110,6 +132,8 @@ defTool( ) ``` +--- + ### LLM Agents Register JavaScript functions as **tools** and combine tools + prompt into agents. @@ -125,6 +149,8 @@ defAgent( ) ``` +--- + ### 🔍 RAG Built-in [Vector search](https://microsoft.github.io/genaiscript/reference/scripts/vector-search/). @@ -133,6 +159,8 @@ defAgent( const { files } = await retrieval.vectorSearch("cats", "**/*.md") ``` +--- + ### 🐙 GitHub Models and GitHub Copilot Run models through [GitHub Models](https://microsoft.github.io/genaiscript/getting-started/configuration/#github-models) or [GitHub Copilot](https://microsoft.github.io/genaiscript/getting-started/configuration/#github-copilot-in-visual-studio-code). @@ -141,6 +169,8 @@ Run models through [GitHub Models](https://microsoft.github.io/genaiscript/getti script({ ..., model: "github:gpt-4o" }) ``` +--- + ### 💻 Local Models Run your scripts with [Open Source models](https://microsoft.github.io/genaiscript/getting-started/configuration/#local-models), like [Phi-3](https://azure.microsoft.com/en-us/blog/introducing-phi-3-redefining-whats-possible-with-slms/), using [Ollama](https://ollama.com/), [LocalAI](https://localai.io/). @@ -149,6 +179,8 @@ Run your scripts with [Open Source models](https://microsoft.github.io/genaiscri script({ ..., model: "ollama:phi3" }) ``` +--- + ### 🐍 Code Interpreter Let the LLM run code in a sandboxed execution environment. @@ -157,6 +189,8 @@ Let the LLM run code in a sandboxed execution environment. script({ tools: ["python_code_interpreter"] }) ``` +--- + ### 🐳 Containers Run code in Docker [containers](https://microsoft.github.io/genaiscript/reference/scripts/containers). @@ -166,6 +200,8 @@ const c = await host.container({ image: "python:alpine" }) const res = await c.exec("python --version") ``` +--- + ### 🧩 LLM Composition [Run LLMs](https://microsoft.github.io/genaiscript/reference/scripts/inline-prompts/) to build your LLM prompts. @@ -181,6 +217,8 @@ for (const file of env.files) { $`Summarize all the summaries.` ``` +--- + ### 🅿️ Prompty support Run your [Prompty](https://prompty.ai) files as well! @@ -193,6 +231,8 @@ name: poem Write me a poem ``` +--- + ### ⚙ Automate with CLI Automate using the [CLI](https://microsoft.github.io/genaiscript/reference/cli), integrate reports in your CI/CD pipeline. @@ -201,6 +241,8 @@ Automate using the [CLI](https://microsoft.github.io/genaiscript/reference/cli), npx genaiscript run tlaplus-linter "*.tla" ``` +--- + ### 💬 Pull Request Reviews Integrate into your [Pull Requests checks](https://microsoft.github.io/genaiscript/reference/cli/run/#pull-requests) through comments, reviews, or description updates. Supports GitHub Actions and Azure DevOps pipelines. @@ -209,6 +251,8 @@ Integrate into your [Pull Requests checks](https://microsoft.github.io/genaiscri npx genaiscript ... --pull-request-reviews ``` +--- + ### ⭐ Tests and Evals Build reliable prompts using [tests and evals](https://microsoft.github.io/genaiscript/reference/scripts/tests) powered by [promptfoo](https://promptfoo.dev/). @@ -221,10 +265,14 @@ script({ ..., tests: { }}) ``` +--- + ## Contributing We accept contributions! Checkout the [CONTRIBUTING](./CONTRIBUTING.md) page for details and developer setup. +--- + ## Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft