Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jan 17, 2025
1 parent 3842b00 commit f860753
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ const { files } = await workspace.grep(/[a-z][a-z0-9]+/, { globs: "*.md" })

---

## Classify

Classify text, images or a mix of all.

```js
const joke = await classify(
"Why did the chicken cross the roard? To fry in the sun.",
{
yes: "funny",
no: "not funny",
}
)
```

### LLM Tools

Register JavaScript functions as [tools](https://microsoft.github.io/genaiscript/reference/scripts/tools)
Expand Down Expand Up @@ -233,6 +247,19 @@ const res = await c.exec("python --version")

---

### Video processing

Transcribe and screenshot your videos so that you can feed them efficiently in your LLMs requests.

```js
// transcribe
const transcript = await transcript("path/to/audio.mp3")
// screenshots at segments
const frames = await ffmpeg.extractFrames("path_url_to_video", { transcript })
def("TRANSCRIPT", transcript)
def("FRAMES", frames)
```

### 🧩 LLM Composition

[Run LLMs](https://microsoft.github.io/genaiscript/reference/scripts/inline-prompts/) to build your LLM prompts.
Expand Down Expand Up @@ -276,7 +303,7 @@ npx genaiscript run tlaplus-linter "*.tla"
import { run } from "genaiscript/api"

const res = await run("tlaplus-linter", "*.tla")
```
```

---

Expand Down
19 changes: 18 additions & 1 deletion docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ defData("ROWS", rows, { sliceHead: 100 })

<Card title="Speech To Text" icon="seti:microphone">

Automatically transcribe audio or videos using [OpenAI](https://openai.com/) or others.
Automatically transcribe audio or videos using [OpenAI](/genaiscript/getting-started/configuration#openai)
or [others](/genaiscript/getting-started/configuration#whisperasr).

```js
const transcript = await transcript("path/to/audio.mp3")
Expand Down Expand Up @@ -439,6 +440,22 @@ $`Summarize all the summaries.`

</Card>

<Card title="Classify" icon="heart">

Classify text, images or a mix of all.

```js
const joke = await classify(
"Why did the chicken cross the roard? To fry in the sun.",
{
yes: "funny",
no: "not funny",
}
)
```

</Card>

<Card title="Prompty" icon="seti:markdown">

Run or convert [Prompty](https://prompty.ai/) files using GenAIScript.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/reference/scripts/videos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const frames = await ffmpeg.extractFrames("...", { count: 10 })
- specify timestamps in seconds or percentages of the video duration using `timestamps` (or `times`)

```js "timestamps"
const frames = await ffmpeg.extractFrames("...", { timestamps: ["0%", "50%"] })
const frames = await ffmpeg.extractFrames("...", { timestamps: ["00:00", "05:00"] })
```

- specify the transcript computed by the [transcribe](/genaiscript/reference/scripts/transcription) function. GenAIScript
Expand Down
5 changes: 4 additions & 1 deletion packages/sample/genaisrc/classify.genai.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
script({
files: "src/robots.jpg",
})
import { classify } from "genaiscript/runtime"

const qa = await classify(
Expand All @@ -24,7 +27,7 @@ const joke = await classify(
console.log(joke)

const robots = await classify(
(_) => _.defImages("src/robots.jpg"),
(_) => _.defImages(env.files),
{
object: "Depicts objects, machines, robots, toys, ...",
animal: "Animals, pets, monsters",
Expand Down

0 comments on commit f860753

Please sign in to comment.