@markprompt/core
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -1,4 +0,4 @@ | ||
export { submitPrompt, type SubmitPromptOptions, MARKPROMPT_COMPLETIONS_URL, STREAM_SEPARATOR, DEFAULT_MODEL, DEFAULT_I_DONT_KNOW_MESSAGE, DEFAULT_REFERENCES_HEADING, DEFAULT_LOADING_HEADING, DEFAULT_PROMPT_TEMPLATE, DEFAULT_TEMPERATURE, DEFAULT_TOP_P, DEFAULT_FREQUENCY_PENALTY, DEFAULT_PRESENCE_PENALTY, DEFAULT_MAX_TOKENS, DEFAULT_SECTIONS_MATCH_COUNT, DEFAULT_SECTIONS_MATCH_THRESHOLD, } from './prompt.js'; | ||
export { submitSearchQuery, type SubmitSearchQueryOptions } from './search.js'; | ||
export { submitPrompt, type SubmitPromptOptions, DEFAULT_SUBMIT_PROMPT_OPTIONS, STREAM_SEPARATOR, } from './prompt.js'; | ||
export { submitSearchQuery, type SubmitSearchQueryOptions, DEFAULT_SUBMIT_SEARCH_QUERY_OPTIONS, } from './search.js'; | ||
export { type OpenAIModelId, type SearchResult, type SearchResultSection, type SearchResultsResponse, type Source, type SourceType, } from './types.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,4 @@ | ||
export { submitPrompt, MARKPROMPT_COMPLETIONS_URL, STREAM_SEPARATOR, DEFAULT_MODEL, DEFAULT_I_DONT_KNOW_MESSAGE, DEFAULT_REFERENCES_HEADING, DEFAULT_LOADING_HEADING, DEFAULT_PROMPT_TEMPLATE, DEFAULT_TEMPERATURE, DEFAULT_TOP_P, DEFAULT_FREQUENCY_PENALTY, DEFAULT_PRESENCE_PENALTY, DEFAULT_MAX_TOKENS, DEFAULT_SECTIONS_MATCH_COUNT, DEFAULT_SECTIONS_MATCH_THRESHOLD, } from './prompt.js'; | ||
export { submitSearchQuery } from './search.js'; | ||
export { submitPrompt, DEFAULT_SUBMIT_PROMPT_OPTIONS, STREAM_SEPARATOR, } from './prompt.js'; | ||
export { submitSearchQuery, DEFAULT_SUBMIT_SEARCH_QUERY_OPTIONS, } from './search.js'; | ||
export {} from './types.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -5,3 +5,3 @@ import { rest } from 'msw'; | ||
import { submitPrompt } from './index.js'; | ||
import { MARKPROMPT_COMPLETIONS_URL, STREAM_SEPARATOR } from './prompt.js'; | ||
import { DEFAULT_SUBMIT_PROMPT_OPTIONS, STREAM_SEPARATOR } from './prompt.js'; | ||
const encoder = new TextEncoder(); | ||
@@ -12,3 +12,3 @@ let response = []; | ||
let stream; | ||
const server = setupServer(rest.post(MARKPROMPT_COMPLETIONS_URL, async (req, res, ctx) => { | ||
const server = setupServer(rest.post(DEFAULT_SUBMIT_PROMPT_OPTIONS.completionsUrl, async (req, res, ctx) => { | ||
request = req; | ||
@@ -102,3 +102,3 @@ stream = new ReadableStream({ | ||
expect(onAnswerChunk.mock.calls).toStrictEqual([ | ||
['Sorry, I am not sure how to answer that.'], | ||
[DEFAULT_SUBMIT_PROMPT_OPTIONS.iDontKnowMessage], | ||
]); | ||
@@ -105,0 +105,0 @@ expect(onReferences).not.toHaveBeenCalled(); |
@@ -64,16 +64,4 @@ import type { OpenAIModelId } from './types.js'; | ||
}; | ||
export declare const MARKPROMPT_COMPLETIONS_URL = "https://api.markprompt.com/v1/completions"; | ||
export declare const STREAM_SEPARATOR = "___START_RESPONSE_STREAM___"; | ||
export declare const DEFAULT_MODEL: OpenAIModelId; | ||
export declare const DEFAULT_I_DONT_KNOW_MESSAGE = "Sorry, I am not sure how to answer that."; | ||
export declare const DEFAULT_REFERENCES_HEADING = "Answer generated from the following pages:"; | ||
export declare const DEFAULT_LOADING_HEADING = "Fetching relevant pages..."; | ||
export declare const DEFAULT_PROMPT_TEMPLATE = "You are a very enthusiastic company representative who loves to help people! Given the following sections from the documentation (preceded by a section id), answer the question using only that information, outputted in Markdown format. If you are unsure and the answer is not explicitly written in the documentation, say \"{{I_DONT_KNOW}}\".\n\nContext sections:\n---\n{{CONTEXT}}\n\nQuestion: \"{{PROMPT}}\"\n\nAnswer (including related code snippets if available):"; | ||
export declare const DEFAULT_TEMPERATURE = 0.1; | ||
export declare const DEFAULT_TOP_P = 1; | ||
export declare const DEFAULT_FREQUENCY_PENALTY = 0; | ||
export declare const DEFAULT_PRESENCE_PENALTY = 0; | ||
export declare const DEFAULT_MAX_TOKENS = 500; | ||
export declare const DEFAULT_SECTIONS_MATCH_COUNT = 10; | ||
export declare const DEFAULT_SECTIONS_MATCH_THRESHOLD = 0.5; | ||
export declare const DEFAULT_SUBMIT_PROMPT_OPTIONS: SubmitPromptOptions; | ||
/** | ||
@@ -80,0 +68,0 @@ * Submit a prompt the the Markprompt API. |
@@ -1,23 +0,15 @@ | ||
export const MARKPROMPT_COMPLETIONS_URL = 'https://api.markprompt.com/v1/completions'; | ||
export const STREAM_SEPARATOR = '___START_RESPONSE_STREAM___'; | ||
export const DEFAULT_MODEL = 'gpt-3.5-turbo'; | ||
export const DEFAULT_I_DONT_KNOW_MESSAGE = 'Sorry, I am not sure how to answer that.'; | ||
export const DEFAULT_REFERENCES_HEADING = 'Answer generated from the following pages:'; | ||
export const DEFAULT_LOADING_HEADING = 'Fetching relevant pages...'; | ||
export const DEFAULT_PROMPT_TEMPLATE = `You are a very enthusiastic company representative who loves to help people! Given the following sections from the documentation (preceded by a section id), answer the question using only that information, outputted in Markdown format. If you are unsure and the answer is not explicitly written in the documentation, say "{{I_DONT_KNOW}}". | ||
Context sections: | ||
--- | ||
{{CONTEXT}} | ||
Question: "{{PROMPT}}" | ||
Answer (including related code snippets if available):`; | ||
export const DEFAULT_TEMPERATURE = 0.1; | ||
export const DEFAULT_TOP_P = 1; | ||
export const DEFAULT_FREQUENCY_PENALTY = 0; | ||
export const DEFAULT_PRESENCE_PENALTY = 0; | ||
export const DEFAULT_MAX_TOKENS = 500; | ||
export const DEFAULT_SECTIONS_MATCH_COUNT = 10; | ||
export const DEFAULT_SECTIONS_MATCH_THRESHOLD = 0.5; | ||
export const DEFAULT_SUBMIT_PROMPT_OPTIONS = { | ||
completionsUrl: 'https://api.markprompt.com/v1/completions', | ||
iDontKnowMessage: 'Sorry, I am not sure how to answer that.', | ||
model: 'gpt-3.5-turbo', | ||
promptTemplate: `You are a very enthusiastic company representative who loves to help people! Given the following sections from the documentation (preceded by a section id), answer the question using only that information, outputted in Markdown format. If you are unsure and the answer is not explicitly written in the documentation, say "{{I_DONT_KNOW}}".\n\nContext sections:\n---\n{{CONTEXT}}\n\nQuestion: "{{PROMPT}}"\n\nAnswer (including related code snippets if available):`, | ||
temperature: 0.1, | ||
topP: 1, | ||
frequencyPenalty: 0, | ||
presencePenalty: 0, | ||
maxTokens: 500, | ||
sectionsMatchCount: 10, | ||
sectionsMatchThreshold: 0.5, | ||
}; | ||
/** | ||
@@ -39,5 +31,5 @@ * Submit a prompt the the Markprompt API. | ||
return; | ||
const iDontKnowMessage = options.iDontKnowMessage ?? DEFAULT_I_DONT_KNOW_MESSAGE; | ||
const iDontKnowMessage = options.iDontKnowMessage ?? DEFAULT_SUBMIT_PROMPT_OPTIONS.iDontKnowMessage; | ||
try { | ||
const res = await fetch(options.completionsUrl ?? MARKPROMPT_COMPLETIONS_URL, { | ||
const res = await fetch(options.completionsUrl ?? DEFAULT_SUBMIT_PROMPT_OPTIONS.completionsUrl, { | ||
method: 'POST', | ||
@@ -51,11 +43,16 @@ headers: { | ||
iDontKnowMessage, | ||
model: options?.model ?? DEFAULT_MODEL, | ||
promptTemplate: options.promptTemplate ?? DEFAULT_PROMPT_TEMPLATE, | ||
temperature: options.temperature ?? DEFAULT_TEMPERATURE, | ||
topP: options.topP ?? DEFAULT_TOP_P, | ||
frequencyPenalty: options.frequencyPenalty ?? DEFAULT_FREQUENCY_PENALTY, | ||
presencePenalty: options.presencePenalty ?? DEFAULT_PRESENCE_PENALTY, | ||
maxTokens: options.maxTokens ?? DEFAULT_MAX_TOKENS, | ||
sectionsMatchCount: options.sectionsMatchCount ?? DEFAULT_SECTIONS_MATCH_COUNT, | ||
sectionsMatchThreshold: options.sectionsMatchThreshold ?? DEFAULT_SECTIONS_MATCH_THRESHOLD, | ||
model: options?.model ?? DEFAULT_SUBMIT_PROMPT_OPTIONS.model, | ||
promptTemplate: options.promptTemplate ?? | ||
DEFAULT_SUBMIT_PROMPT_OPTIONS.promptTemplate, | ||
temperature: options.temperature ?? DEFAULT_SUBMIT_PROMPT_OPTIONS.temperature, | ||
topP: options.topP ?? DEFAULT_SUBMIT_PROMPT_OPTIONS.topP, | ||
frequencyPenalty: options.frequencyPenalty ?? | ||
DEFAULT_SUBMIT_PROMPT_OPTIONS.frequencyPenalty, | ||
presencePenalty: options.presencePenalty ?? | ||
DEFAULT_SUBMIT_PROMPT_OPTIONS.presencePenalty, | ||
maxTokens: options.maxTokens ?? DEFAULT_SUBMIT_PROMPT_OPTIONS.maxTokens, | ||
sectionsMatchCount: options.sectionsMatchCount ?? | ||
DEFAULT_SUBMIT_PROMPT_OPTIONS.sectionsMatchCount, | ||
sectionsMatchThreshold: options.sectionsMatchThreshold ?? | ||
DEFAULT_SUBMIT_PROMPT_OPTIONS.sectionsMatchThreshold, | ||
}), | ||
@@ -62,0 +59,0 @@ signal: options.signal, |
import type { SearchResultsResponse } from './types.js'; | ||
export declare const DEFAULT_SEARCH_URL = "https://api.markprompt.com/v1/search"; | ||
export declare const DEFAULT_SEARCH_LIMIT = 8; | ||
export interface SubmitSearchQueryOptions { | ||
@@ -21,2 +19,3 @@ /** | ||
} | ||
export declare const DEFAULT_SUBMIT_SEARCH_QUERY_OPTIONS: SubmitSearchQueryOptions; | ||
/** | ||
@@ -23,0 +22,0 @@ * Submit a search query to the Markprompt Search API endpoint. |
@@ -1,3 +0,5 @@ | ||
export const DEFAULT_SEARCH_URL = 'https://api.markprompt.com/v1/search'; | ||
export const DEFAULT_SEARCH_LIMIT = 8; | ||
export const DEFAULT_SUBMIT_SEARCH_QUERY_OPTIONS = { | ||
limit: 8, | ||
searchUrl: 'https://api.markprompt.com/v1/search', | ||
}; | ||
/** | ||
@@ -11,3 +13,3 @@ * Submit a search query to the Markprompt Search API endpoint. | ||
export async function submitSearchQuery(query, projectKey, options) { | ||
const { limit = DEFAULT_SEARCH_LIMIT, searchUrl = DEFAULT_SEARCH_URL } = options ?? {}; | ||
const { limit = DEFAULT_SUBMIT_SEARCH_QUERY_OPTIONS.limit, searchUrl = DEFAULT_SUBMIT_SEARCH_QUERY_OPTIONS.searchUrl, } = options ?? {}; | ||
const params = new URLSearchParams({ | ||
@@ -14,0 +16,0 @@ query, |
{ | ||
"name": "@markprompt/core", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
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
35577
436