@7-docs/edge
Advanced tools
Comparing version 0.0.6 to 0.1.0
export * from './completion.js'; | ||
export { getDelta } from './util.js'; | ||
export { getDelta, getText } from './util.js'; | ||
export { splitTextIntoSentences } from '@7-docs/shared'; | ||
@@ -4,0 +4,0 @@ export type { MetaData, StreamMetaData, Params, EventData, ChatCompletionEventData, CompletionEventData, Usage } from '@7-docs/shared'; |
export * from './completion.js'; | ||
export { getDelta } from './util.js'; | ||
export { getDelta, getText } from './util.js'; | ||
export { splitTextIntoSentences } from '@7-docs/shared'; | ||
export * as pinecone from './pinecone/index.js'; | ||
export * as supabase from './supabase/index.js'; |
@@ -1,2 +0,2 @@ | ||
import type { CreateChatCompletionRequest } from '@7-docs/shared'; | ||
import type { CreateChatCompletionRequest } from 'openai'; | ||
interface ChatCompletionsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
@@ -1,2 +0,2 @@ | ||
import type { CreateChatCompletionRequest, CreateCompletionRequest } from '@7-docs/shared'; | ||
import type { CreateChatCompletionRequest, CreateCompletionRequest } from 'openai'; | ||
export declare class OpenAI { | ||
@@ -10,7 +10,7 @@ token: string; | ||
embeddings: number[][]; | ||
usage: import("@7-docs/shared").CreateEmbeddingResponseUsage; | ||
usage: import("openai").CreateEmbeddingResponseUsage; | ||
}>; | ||
chatCompletions(body: CreateChatCompletionRequest): Promise<Response>; | ||
completions(body: CreateCompletionRequest): Promise<Response>; | ||
listModels(): Promise<import("@7-docs/shared").Model[]>; | ||
listModels(): Promise<import("openai").Model[]>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { CreateCompletionRequest } from '@7-docs/shared'; | ||
import type { CreateCompletionRequest } from 'openai'; | ||
interface CompletionsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
@@ -1,2 +0,2 @@ | ||
import type { CreateEmbeddingResponse } from '@7-docs/shared'; | ||
import type { CreateEmbeddingResponse } from 'openai'; | ||
interface EmbeddingsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
@@ -1,2 +0,2 @@ | ||
import type { ListModelsResponse } from '@7-docs/shared'; | ||
import type { ListModelsResponse } from 'openai'; | ||
interface ListModelsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
import type { EventData, Params } from '@7-docs/shared'; | ||
import type { CreateChatCompletionResponse } from '@7-docs/shared'; | ||
import type { CreateChatCompletionResponse } from 'openai'; | ||
export declare const getParams: (req: Request) => Promise<Params>; | ||
@@ -4,0 +4,0 @@ export declare const streamResponse: (body: BodyInit | null) => Response; |
{ | ||
"name": "@7-docs/edge", | ||
"version": "0.0.6", | ||
"description": "Package to use 7-docs from edge functions", | ||
"version": "0.1.0", | ||
"description": "Dependency-free package for 7-docs to query your content from anywhere JavaScript can run", | ||
"homepage": "https://github.com/7-docs/7-docs", | ||
@@ -18,4 +18,2 @@ "bugs": "https://github.com/7-docs/7-docs/issues", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
@@ -30,2 +28,4 @@ ".": { | ||
}, | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
@@ -35,10 +35,27 @@ "dist" | ||
"scripts": { | ||
"lint": "eslint src" | ||
"format": "remark README.md -o", | ||
"lint": "eslint src", | ||
"release": "release-it" | ||
}, | ||
"dependencies": { | ||
"@7-docs/shared": "0.0.5" | ||
"@7-docs/shared": "0.1.0" | ||
}, | ||
"devDependencies": { | ||
"@supabase/supabase-js": "^2.21.0", | ||
"openai": "^3.2.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"release-it": { | ||
"git": false, | ||
"plugins": { | ||
"@release-it/bumper": { | ||
"out": { | ||
"file": "package.json", | ||
"path": "dependencies.@7-docs/shared" | ||
} | ||
} | ||
} | ||
} | ||
} |
# @7-docs/edge | ||
Use [7-docs](https://github.com/7-docs/7-docs) from edge functions. | ||
Query your content from anywhere JavaScript can run. | ||
After ingesting content using 7-docs, it can be queried from web or the command-line interface. | ||
After ingesting content using [@7-docs/cli][1], request "chat completions" using `@7-docs/edge`. | ||
No dependencies, requires only `fetch()`. | ||
## Usage | ||
Curently there are adapters for Pinecone and Supabase. Pull requests to add more are welcome. | ||
### Pinecone | ||
```ts | ||
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.21.0'; | ||
import { getCompletionHandler } from '@7-docs/edge'; | ||
import * as supabase from '@7-docs/edge/supabase'; | ||
import { getCompletionHandler, pinecone } from 'https://esm.sh/@7-docs/edge'; // from '@7-docs/edge' in Node.js | ||
const namespace = 'namespace-within-pinecone-index'; | ||
const sytem = '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 | ||
```ts | ||
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 prompt = `Answer the question using the provided context. | ||
Context: {CONTEXT} | ||
const sytem = 'Answer the question using the provided context.'; | ||
const prompt = `Context: {CONTEXT} | ||
Question: {QUERY} | ||
Answer:`; | ||
Answer: `; | ||
@@ -24,3 +58,3 @@ const client = createClient(SUPABASE_URL, SUPABASE_API_KEY); | ||
const handler = getCompletionHandler({ OPENAI_API_KEY, query, prompt }); | ||
const handler = getCompletionHandler({ OPENAI_API_KEY, query, system, prompt }); | ||
@@ -34,6 +68,9 @@ export default function (req: Request) { | ||
See [github.com/7-docs/demo-react](https://github.com/7-docs/demo-react) for a full example. | ||
See [github.com/7-docs/demo-react][2] for a full example. | ||
## CLI | ||
To query the content from the CLI, [7-docs](https://github.com/7-docs/7-docs) includes the `7d` executable to do this. | ||
To query the content from the CLI, use [@7-docs/cli][1]. | ||
[1]: https://github.com/7-docs/7-docs/blob/main/packages/cli/README.md | ||
[2]: https://github.com/7-docs/demo-react |
22153
75
2
+ Added@7-docs/shared@0.1.0(transitive)
- Removed@7-docs/shared@0.0.5(transitive)
Updated@7-docs/shared@0.1.0