-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/max-completion-tokens
- Loading branch information
Showing
10 changed files
with
1,325 additions
and
9 deletions.
There are no files selected for viewing
1,202 changes: 1,202 additions & 0 deletions
1,202
cookbook/use-cases/Contextual Embeddings Guide Anthropic, Cohere, Voyage.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
HookEventType, | ||
PluginContext, | ||
PluginHandler, | ||
PluginParameters, | ||
} from '../types'; | ||
import { getText } from '../utils'; | ||
|
||
export const handler: PluginHandler = async ( | ||
context: PluginContext, | ||
parameters: PluginParameters, | ||
eventType: HookEventType | ||
) => { | ||
let error = null; | ||
let verdict = false; | ||
let data = null; | ||
|
||
try { | ||
const suffix = parameters.suffix; | ||
let text = getText(context, eventType); | ||
|
||
if (suffix !== undefined && '' !== suffix && text.length >= 0) { | ||
verdict = text.endsWith(suffix) || text.endsWith(`${suffix}.`); | ||
} else { | ||
error = error || new Error('Missing suffix or text'); | ||
} | ||
} catch (e) { | ||
error = e as Error; | ||
} | ||
|
||
return { error, verdict, data }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters