Skip to content

Commit

Permalink
docs: ✏️ add installation guide for GenAIScript
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 10, 2024
1 parent f720c04 commit 8f20f96
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions docs/src/content/docs/blog/node-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Node.JS API
date: 2024-12-10
authors:
- pelikhan
- pelikhan
tags: ["sdk", "automation", "dev", "api"]
description: Learn about the new API to call genaiscript for other typescript scripts.
---
Expand All @@ -11,6 +11,14 @@ A long standing feature request has been to run GenAIScript programmatically fro

- [Documentation](https://microsoft.github.io/genaiscript/reference/cli/api/)

## Installation

You'll want to add [genaiscript](https://www.npmjs.com/package/genaiscript) as a (dev) dependency to your project.

```sh
npm install -D genaiscript
```

## The `run` API

The `run` API is meant to mimic the behavior of the GenAIScript CLI. It takes the same arguments as the CLI and returns the same results. This allows you to call GenAIScript from other TypeScript scripts.
Expand All @@ -20,14 +28,16 @@ import { run } from "genaiscript/api"
const results = await run("summarize", ["myfile.txt"])
```

The result object contains the full list of messages, and additional parsed information like modified files, diagnostics and so forth.

## Don't mess with my process

On the caller side, the [run implementation](https://github.com/microsoft/genaiscript/blob/main/packages/cli/src/api.ts) is a dependency free, side effect free function. It spawns a worker thread where GenAIScript does the work.

- No global added,
- No package loaded,
- A few hunbred `b` of memory used.
- No global added
- No package loaded
- A few hunbred `b` of memory used

## Help us improve it!

Obvisouly this is a first draft and we could do a better job at providing callbacks for progress. Send us your feedback!
Obvisouly this is a first draft and we could do a better job at providing callbacks for progress. Send us your feedback!

0 comments on commit 8f20f96

Please sign in to comment.