@markprompt/core
Advanced tools
Comparing version 0.3.2 to 0.4.0-beta1
@@ -24,6 +24,7 @@ import type { OpenAIModelId } from './types.js'; | ||
* @param {(references: string[]) => void} onReferences - This function is called when a chunk includes references. | ||
* @param {() => void} onDone - called when streaming is finished | ||
* @param {(error: Error) => void} onError - called when an error occurs | ||
* @param {Options} [options] - Optional options object | ||
*/ | ||
export declare function submitPrompt(prompt: string, projectKey: string, onAnswerChunk: (answerChunk: string) => void, onReferences: (references: string[]) => void, onError: (error: Error) => void, options?: Options): Promise<void>; | ||
export declare function submitPrompt(prompt: string, projectKey: string, onAnswerChunk: (answerChunk: string) => void, onReferences: (references: string[]) => void, onDone: () => void, onError: (error: Error) => void, options?: Options): Promise<void>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,6 +10,7 @@ export const DEFAULT_MODEL = 'gpt-3.5-turbo'; | ||
* @param {(references: string[]) => void} onReferences - This function is called when a chunk includes references. | ||
* @param {() => void} onDone - called when streaming is finished | ||
* @param {(error: Error) => void} onError - called when an error occurs | ||
* @param {Options} [options] - Optional options object | ||
*/ | ||
export async function submitPrompt(prompt, projectKey, onAnswerChunk, onReferences, onError, options = {}) { | ||
export async function submitPrompt(prompt, projectKey, onAnswerChunk, onReferences, onDone, onError, options = {}) { | ||
if (!projectKey) { | ||
@@ -47,3 +48,2 @@ throw new Error('A projectKey is required.'); | ||
let didHandleHeader = false; | ||
let refs = []; | ||
while (!done) { | ||
@@ -58,3 +58,3 @@ const { value, done: doneReading } = await reader.read(); | ||
try { | ||
refs = JSON.parse(parts[0]); | ||
onReferences(JSON.parse(parts[0])); | ||
} | ||
@@ -72,3 +72,3 @@ catch { | ||
} | ||
onReferences(refs); | ||
onDone(); | ||
} | ||
@@ -75,0 +75,0 @@ catch (error) { |
{ | ||
"name": "@markprompt/core", | ||
"version": "0.3.2", | ||
"version": "0.4.0-beta1", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/motifland/markprompt.git", | ||
"url": "git+https://github.com/motifland/markprompt-js.git", | ||
"directory": "packages/core" | ||
@@ -9,0 +9,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10747
109