Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tscircuit/prompt-benchmarks
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.34
Choose a base ref
...
head repository: tscircuit/prompt-benchmarks
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.0.35
Choose a head ref
  • 3 commits
  • 3 files changed
  • 3 contributors

Commits on Feb 7, 2025

  1. v0.0.34

    actions-user committed Feb 7, 2025
    Copy the full SHA
    95660e1 View commit details

Commits on Feb 8, 2025

  1. exported aicoder and updated the readme

    ShiboSoftwareDev committed Feb 8, 2025
    Copy the full SHA
    29f8e53 View commit details
  2. Merge pull request #28 from ShiboSoftwareDev/main

    exported aicoder and updated the readme
    AnasSarkiz authored Feb 8, 2025
    Copy the full SHA
    0c1b9de View commit details
Showing with 54 additions and 1 deletion.
  1. +52 −0 README.md
  2. +1 −0 lib/ai/index.ts
  3. +1 −1 package.json
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,58 @@ This repository contains benchmarks for evaluating and improving the quality of
- **Benchmarking & Scoring** (using evalite and custom scorers in `benchmarks/scorers`): Run multiple tests to ensure circuit validity and quality.


## Installation

You can install this package from npm using Bun:

```bash
bun add @tscircuit/prompt-benchmarks
```

## Using the AiCoder

Below is the AiCoder interface:

```tsx
export interface AiCoder {
onStreamedChunk: (chunk: string) => void
onVfsChanged: () => void
vfs: { [filepath: string]: string }
availableOptions: { name: string; options: string[] }[]
submitPrompt: (
prompt: string,
options?: { selectedMicrocontroller?: string },
) => Promise<void>
}
```

The AI Coder supports streaming of AI responses and notifying you when the virtual file system (VFS) is updated. To achieve this, you can pass two callback functions when creating an AiCoder instance:
- **onStreamedChunk**: A callback function that receives streamed chunks from the AI. This is useful for logging or updating a UI with gradual progress.
- **onVfsChanged**: A callback function that is invoked whenever the VFS is updated with new content. This is useful for refreshing a file view or triggering further processing.

**Example Usage:**

```tsx
import { createAiCoder } from "@tscircuit/prompt-benchmarks/lib/ai/aiCoder"

// Define a callback for handling streamed chunks
const handleStream = (chunk: string) => {
console.log("Streaming update:", chunk)
}

// Define a callback for when the VFS is updated
const handleVfsUpdate = () => {
console.log("The virtual file system has been updated.")
}

// Create an instance of AiCoder with your callbacks
const aiCoder = createAiCoder(handleStream, handleVfsUpdate)

// Submit a prompt to generate a circuit.
// The onStream callback logs streaming updates and onVfsChanged notifies when a new file is added to the VFS.
aiCoder.submitPrompt("create a circuit that blinks an LED")
```

## Running Benchmarks

To run the benchmarks using evalite, use:
1 change: 1 addition & 0 deletions lib/ai/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./ask-ai"
export * from "./ask-ai-with-previous-attempts"
export * from "./run-ai-with-error-correction"
export * from "./aiCoder"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tscircuit/prompt-benchmarks",
"version": "0.0.33",
"version": "0.0.34",
"main": "dist/index.js",
"repository": "github:tscircuit/prompt-benchmarks",
"homepage": "https://github.com/tscircuit/prompt-benchmarks#readme",