Skip to main content
Repos is now in Public Beta! Reach out to us at info@relace.ai if you have any questions or need help with the integration.

Prerequisites

1

Import GitHub Project

We’ll start by creating a new Relace Repo using GitHub as a source.
import { Relace } from "@relace-ai/relace";

const client = new Relace({ apiKey: "YOUR_API_KEY" });

const repo = await client.repo.create({
    source: {
        type: "git",
        url: "https://github.com/relace-ai/vite-template",
        branch: "main"
    },
    auto_index: true // Required for semantic search
});

const repoId = repo.repo_id;
console.log(`Repository created with ID: ${repoId}`);
Behind the scenes, we clone your repo and kick of an asychronous job to intelligently chunk and index the codebase with our code embeddings model.This process is usually fast, but for very large repositories (i.e. 100+ MB), it can take upwards of 5 minutes.
2

Perform Semantic Search

You can now use the retrieve endpoint to score files based on relevance to a query in natural language!
import { Relace } from "@relace-ai/relace";

const client = new Relace({ apiKey: "YOUR_API_KEY" });

const response = await client.repo.retrieve(repoId, {
    query: "Add a user profile component with avatar and edit functionality"
});

const results = response.results;
The response will be a list of objects that provide a relevance score for each file.
[
  {
    "filename": "src/components/UserProfile.tsx",
    "score": 0.9598
  },
  {
    "filename": "src/types/user.ts",
    "score": 0.0321
  },
  {
    "filename": "src/components/Header.tsx",
    "score": 0.0014
  }
]
For more details, see our API reference.