0.5.1 • Published 7 months ago

@7-docs/edge v0.5.1

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

@7-docs/edge

Query your content from anywhere JavaScript runs.

After ingesting content using @7-docs/cli, request "chat completions" using @7-docs/edge.

No dependencies, uses fetch().

Usage

Curently there are adapters for Pinecone and Supabase. Pull requests to add more are welcome.

Pinecone

import { getCompletionHandler, pinecone } from 'https://esm.sh/@7-docs/edge'; // from '@7-docs/edge' in Node.js

const namespace = 'namespace-within-pinecone-index';

const system = 'Answer the question using the provided context.';

const prompt = `Context: {CONTEXT}
Question: {QUERY}
Answer: `;

const query = (vector: number[]) =>
  pinecone.query({
    url: PINECONE_URL,
    token: PINECONE_API_KEY,
    vector,
    namespace
  });

const handler = getCompletionHandler({ OPENAI_API_KEY, query, system, prompt });

export function GET(req: Request) {
  return handler(req);
}

Supabase

import { getCompletionHandler, supabase } from 'https://esm.sh/@7-docs/edge'; // from '@7-docs/edge' in Node.js
import { createClient } from 'https://esm.sh/@supabase/supabase-js'; // from '@supabase/supabase-js' in Node.js

const namespace = 'table-in-supabase';

const system = 'Answer the question using the provided context.';

const prompt = `Context: {CONTEXT}
Question: {QUERY}
Answer: `;

const client = createClient(SUPABASE_URL, SUPABASE_API_KEY);
const query = (vector: number[]) => supabase.query({ client, namespace, vector });

const handler = getCompletionHandler({ OPENAI_API_KEY, query, system, prompt });

export default function (req: Request) {
  return handler(req);
}

Edge + UI example using (P)react

See github.com/7-docs for more examples, starter kits, etc.

CLI

To query the content from the CLI, use @7-docs/cli.

0.3.0

10 months ago

0.2.0

10 months ago

0.1.8

10 months ago

0.1.9

10 months ago

0.5.0

7 months ago

0.3.2

8 months ago

0.4.0

7 months ago

0.3.1

10 months ago

0.5.1

7 months ago

0.3.3

8 months ago

0.1.7

11 months ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago