Skip to content

Commit

Permalink
impr(refactor): Created multi-stage in Dockerfile, enhanced ReadMe (@…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
ilolm authored Oct 11, 2024
1 parent 69a255a commit f88f3b0
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
25 changes: 21 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

CMD ["node", "/app/packages/cli/built/genaiscript.cjs", "serve"]
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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).
Expand All @@ -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), ...
Expand All @@ -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), ...
Expand All @@ -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.
Expand All @@ -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).
Expand All @@ -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**.
Expand All @@ -110,6 +132,8 @@ defTool(
)
```

---

### LLM Agents

Register JavaScript functions as **tools** and combine tools + prompt into agents.
Expand All @@ -125,6 +149,8 @@ defAgent(
)
```

---

### 🔍 RAG Built-in

[Vector search](https://microsoft.github.io/genaiscript/reference/scripts/vector-search/).
Expand All @@ -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).
Expand All @@ -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/).
Expand All @@ -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.
Expand All @@ -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).
Expand All @@ -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.
Expand All @@ -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!
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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/).
Expand All @@ -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
Expand Down

0 comments on commit f88f3b0

Please sign in to comment.