@7-docs/edge
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -12,3 +12,3 @@ import { uniqueByProperty, getPrompt } from '@7-docs/shared'; | ||
return async (req) => { | ||
const { query: input, previousQueries = [], previousResponses = [], embedding_model, completion_model } = await getParams(req); | ||
const { query: input, previousQueries = [], previousResponses = [], embedding_model, completion_model, stream = true } = await getParams(req); | ||
if (!input) | ||
@@ -61,2 +61,4 @@ throw new Error('input required'); | ||
return new Response(); | ||
if (!stream) | ||
return completionResponse; | ||
const transformedStream = completionResponse.body.pipeThrough(streamWithEvent.getTransformStream()); | ||
@@ -70,2 +72,4 @@ return streamResponse(transformedStream); | ||
return new Response(); | ||
if (!stream) | ||
return completionResponse; | ||
const transformedStream = completionResponse.body.pipeThrough(streamWithEvent.getTransformStream()); | ||
@@ -72,0 +76,0 @@ return streamResponse(transformedStream); |
@@ -5,1 +5,3 @@ export * from './completion.js'; | ||
export type { MetaData, StreamMetaData, Params, EventData, ChatCompletionEventData, CompletionEventData, Usage } from '@7-docs/shared'; | ||
export * as pinecone from './pinecone/index.js'; | ||
export * as supabase from './supabase/index.js'; |
export * from './completion.js'; | ||
export { getDelta } 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 'openai'; | ||
import type { CreateChatCompletionRequest } from '@7-docs/shared'; | ||
interface ChatCompletionsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
@@ -1,2 +0,2 @@ | ||
import type { CreateChatCompletionRequest, CreateCompletionRequest } from 'openai'; | ||
import type { CreateChatCompletionRequest, CreateCompletionRequest } from '@7-docs/shared'; | ||
export declare class OpenAI { | ||
@@ -10,7 +10,7 @@ token: string; | ||
embeddings: number[][]; | ||
usage: import("openai").CreateEmbeddingResponseUsage; | ||
usage: import("@7-docs/shared").CreateEmbeddingResponseUsage; | ||
}>; | ||
chatCompletions(body: CreateChatCompletionRequest): Promise<Response>; | ||
completions(body: CreateCompletionRequest): Promise<Response>; | ||
listModels(): Promise<import("openai").Model[]>; | ||
listModels(): Promise<import("@7-docs/shared").Model[]>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { CreateCompletionRequest } from 'openai'; | ||
import type { CreateCompletionRequest } from '@7-docs/shared'; | ||
interface CompletionsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
@@ -1,2 +0,2 @@ | ||
import type { CreateEmbeddingResponse } from 'openai'; | ||
import type { CreateEmbeddingResponse } from '@7-docs/shared'; | ||
interface EmbeddingsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
@@ -1,2 +0,2 @@ | ||
import type { ListModelsResponse } from 'openai'; | ||
import type { ListModelsResponse } from '@7-docs/shared'; | ||
interface ListModelsOptions { | ||
@@ -3,0 +3,0 @@ token: string; |
@@ -1,4 +0,6 @@ | ||
import type { Params, EventData } from '@7-docs/shared'; | ||
import type { EventData, Params } from '@7-docs/shared'; | ||
import type { CreateChatCompletionResponse } from '@7-docs/shared'; | ||
export declare const getParams: (req: Request) => Promise<Params>; | ||
export declare const streamResponse: (body: BodyInit | null) => Response; | ||
export declare const getDelta: (data: EventData) => string; | ||
export declare const getText: (response: CreateChatCompletionResponse) => string | undefined; |
@@ -10,2 +10,3 @@ export const getParams = async (req) => { | ||
const completion_model = url.searchParams.get('completion_model') ?? undefined; | ||
const stream = true; | ||
return { | ||
@@ -16,3 +17,4 @@ query: decodeURIComponent(query), | ||
embedding_model, | ||
completion_model | ||
completion_model, | ||
stream | ||
}; | ||
@@ -31,1 +33,2 @@ } | ||
export const getDelta = (data) => isChatCompletion(data) ? data.choices[0].delta.content : isCompletion(data) ? data.choices[0].text : ''; | ||
export const getText = (response) => response.choices[0].message?.content; |
{ | ||
"name": "@7-docs/edge", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Package to use 7-docs from edge functions", | ||
@@ -18,2 +18,4 @@ "homepage": "https://github.com/7-docs/7-docs", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
@@ -35,3 +37,3 @@ ".": { | ||
"dependencies": { | ||
"@7-docs/shared": "0.0.4" | ||
"@7-docs/shared": "0.0.5" | ||
}, | ||
@@ -38,0 +40,0 @@ "publishConfig": { |
@@ -10,3 +10,3 @@ # @7-docs/edge | ||
```ts | ||
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.20.0'; | ||
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.21.0'; | ||
import { getCompletionHandler } from '@7-docs/edge'; | ||
@@ -13,0 +13,0 @@ import * as supabase from '@7-docs/edge/supabase'; |
20950
501
+ Added@7-docs/shared@0.0.5(transitive)
- Removed@7-docs/shared@0.0.4(transitive)
Updated@7-docs/shared@0.0.5