@markprompt/core
Advanced tools
Comparing version 0.9.1 to 0.10.0
@@ -0,6 +1,7 @@ | ||
import type { PromptFeedback } from './types.js'; | ||
export interface SubmitFeedbackBody { | ||
/** | ||
* Whether the prompt was helpful or not. | ||
* Prompt feedback. | ||
*/ | ||
helpful: boolean; | ||
feedback: PromptFeedback; | ||
/** ID of the prompt for which feedback is being submitted. */ | ||
@@ -7,0 +8,0 @@ promptId: string; |
export { submitFeedback, type SubmitFeedbackOptions, type SubmitFeedbackBody, DEFAULT_SUBMIT_FEEDBACK_OPTIONS, } from './feedback.js'; | ||
export { submitPrompt, type SubmitPromptOptions, DEFAULT_SUBMIT_PROMPT_OPTIONS, STREAM_SEPARATOR, } from './prompt.js'; | ||
export { submitSearchQuery, submitAlgoliaDocsearchQuery, type SubmitSearchQueryOptions, DEFAULT_SUBMIT_SEARCH_QUERY_OPTIONS, } from './search.js'; | ||
export { type FileSectionReference, type FileReferenceFileData, type OpenAIModelId, type OpenAIChatCompletionsModelId, type OpenAICompletionsModelId, type OpenAIEmbeddingsModelId, type SearchResult, type SearchResultSection, type SearchResultsResponse, type AlgoliaDocSearchHit, type AlgoliaDocSearchResultsResponse, type Source, type SourceType, } from './types.js'; | ||
export { type AlgoliaDocSearchHit, type AlgoliaDocSearchResultsResponse, type FileReferenceFileData, type FileSectionReference, type OpenAIChatCompletionsModelId, type OpenAICompletionsModelId, type OpenAIEmbeddingsModelId, type OpenAIModelId, type PromptFeedback, type SearchResult, type SearchResultSection, type SearchResultsResponse, type Source, type SourceType, } from './types.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -96,4 +96,5 @@ import { rest } from 'msw'; | ||
const onReferences = vi.fn(); | ||
const onPromptId = vi.fn(); | ||
const onError = vi.fn(); | ||
await submitPrompt('', 'testKey', onAnswerChunk, onReferences, onError); | ||
await submitPrompt('', 'testKey', onAnswerChunk, onReferences, onPromptId, onError); | ||
expect(request).toBeUndefined(); | ||
@@ -107,2 +108,3 @@ expect(onAnswerChunk).not.toHaveBeenCalled(); | ||
const onReferences = vi.fn(); | ||
const onPromptId = vi.fn(); | ||
const onError = vi.fn(); | ||
@@ -115,3 +117,3 @@ response = [ | ||
]; | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onError); | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onPromptId, onError); | ||
expect(request).toBeDefined(); | ||
@@ -127,2 +129,3 @@ expect(onAnswerChunk.mock.calls).toStrictEqual([ | ||
const onReferences = vi.fn(); | ||
const onPromptId = vi.fn(); | ||
const onError = vi.fn(); | ||
@@ -135,3 +138,3 @@ response = [ | ||
]; | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onError); | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onPromptId, onError); | ||
expect(request).toBeDefined(); | ||
@@ -147,6 +150,7 @@ expect(onAnswerChunk.mock.calls).toStrictEqual([ | ||
const onReferences = vi.fn(); | ||
const onPromptId = vi.fn(); | ||
const onError = vi.fn(); | ||
status = 500; | ||
response = ['Internal Server Error']; | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onError); | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onPromptId, onError); | ||
expect(request).toBeDefined(); | ||
@@ -164,2 +168,3 @@ expect(onAnswerChunk.mock.calls).toStrictEqual([ | ||
const onReferences = vi.fn(); | ||
const onPromptId = vi.fn(); | ||
const onError = vi.fn(); | ||
@@ -172,3 +177,3 @@ response = [ | ||
]; | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onError); | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onPromptId, onError); | ||
expect(request).toBeDefined(); | ||
@@ -185,2 +190,3 @@ expect(onAnswerChunk.mock.calls).toStrictEqual([ | ||
const onReferences = vi.fn(); | ||
const onPromptId = vi.fn(); | ||
const onError = vi.fn(); | ||
@@ -193,3 +199,3 @@ response = [ | ||
]; | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onError); | ||
await submitPrompt('How much is 1+2?', 'testKey', onAnswerChunk, onReferences, onPromptId, onError); | ||
expect(request).toBeDefined(); | ||
@@ -196,0 +202,0 @@ expect(onAnswerChunk.mock.calls).toStrictEqual([ |
@@ -76,3 +76,3 @@ import type { FileSectionReference, OpenAIModelId } from './types.js'; | ||
*/ | ||
export declare function submitPrompt(prompt: string, projectKey: string, onAnswerChunk: (answerChunk: string) => boolean | undefined | void, onReferences: (references: FileSectionReference[]) => void, onError: (error: Error) => void, options?: SubmitPromptOptions, debug?: boolean): Promise<void>; | ||
export declare function submitPrompt(prompt: string, projectKey: string, onAnswerChunk: (answerChunk: string) => boolean | undefined | void, onReferences: (references: FileSectionReference[]) => void, onPromptId: (promptId: string) => void, onError: (error: Error) => void, options?: SubmitPromptOptions, debug?: boolean): Promise<void>; | ||
//# sourceMappingURL=prompt.d.ts.map |
@@ -26,3 +26,3 @@ import { parseEncodedJSONHeader } from './utils.js'; | ||
*/ | ||
export async function submitPrompt(prompt, projectKey, onAnswerChunk, onReferences, onError, options = {}, debug) { | ||
export async function submitPrompt(prompt, projectKey, onAnswerChunk, onReferences, onPromptId, onError, options = {}, debug) { | ||
if (!projectKey) { | ||
@@ -76,2 +76,5 @@ throw new Error('A projectKey is required.'); | ||
} | ||
if (data?.promptId) { | ||
onPromptId(data?.promptId); | ||
} | ||
const reader = res.body.getReader(); | ||
@@ -78,0 +81,0 @@ const decoder = new TextDecoder(); |
@@ -51,2 +51,5 @@ export type OpenAIChatCompletionsModelId = 'gpt-4' | 'gpt-3.5-turbo'; | ||
}; | ||
export type PromptFeedback = { | ||
vote: '1' | '-1'; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@markprompt/core", | ||
"version": "0.9.1", | ||
"version": "0.10.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -64,3 +64,3 @@ # `@markprompt/core` | ||
await submitPrompt(prompt, projectKey, onAnswerChunk, onReferences, onError, options); | ||
await submitPrompt(prompt, projectKey, onAnswerChunk, onReferences, onPromptId, onError, options); | ||
``` | ||
@@ -67,0 +67,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
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
58175
750