Skip to content

Instantly share code, notes, and snippets.

View Barqawiz's full-sized avatar
🚣
Working on 100 brain

cybercoder Barqawiz

🚣
Working on 100 brain
View GitHub Profile
const search = new SemanticSearch(apiKey, 'cohere');
const { SemanticSearch } = require('intellinode');
// apikey from openai.com
const search = new SemanticSearch(apiKey);
// pivotItem is the item to search.
// searchArray is the array of strings to search through.
const results = await search.getTopMatches(pivotItem, searchArray, numberOfMatches);
const filteredArray = search.filterTopMatches(results, searchArray)
const { Chatbot, ChatGPTInput } = require('intellinode');
// set the api key for openai
const chatbot = new Chatbot(apiKey, 'openai');
// set the system mode and the user message.
const input = new ChatGPTInput('You are a helpful assistant.');
input.addUserMessage('What is the distance between the Earth and the Moon?');
// get the responses from the chatbot
const {RemoteLanguageModel,LanguageModelInput} = require('intellinode');
const textModelInput = 'Write a creative product description for gaming chair with black and red colors';
const textProductDesc = await generateProductDescription(textModelInput, MyKeys.cohere, 'cohere', 'command');
// common function to use it with any text generation
async function generateProductDescription(textInput, apiKey, modelBackend, modelName) {
const langModel = new RemoteLanguageModel(apiKey, modelBackend);
const results = await langModel.generateText(new LanguageModelInput({
prompt: textInput,
{
'openai/gpt-4': [
{
prediction: '<model-output>',
score_cosine_similarity: <score>,
score_euclidean_distance: <score>
}
],
'cohere/command': [
{
function drawScene2(planet, data) {
// data ranges; kept only first 3 comparison parameters
var comparisonData = [{
parameter: 'Equilibrium Temperature',
earth: {
min: 273.15,
max: 373.15
},
planet: +planet.pl_eqt
function drawScene1(data) {
// prepare color scale
var colorScale = d3.scaleSequential()
.domain([2018, 2023])
.interpolator(d3.interpolateOranges);
// create SVG for the visualization
var svg = d3.select("#visualization").append("svg")
.attr("width", 800)
const llmEvaluation = new LLMEvaluation(openaiChatKey, 'openai');
async function testLLMEvaluation() {
const userInput = "<add your question or prompt here>";
// add idea answers, the more you add the better
const targetAnswers = ["<ideal answer 1>",
"<ideal answer 2>"];
// the models set to compare
const openaiChat = {
apiKey: openaiKey,
provider: SupportedChatModels.OPENAI,
type: 'chat',
model: 'gpt-4',
maxTokens: 50
};
const cohereCompletion = {
apiKey: cohereKey,
const { LLMEvaluation, SupportedChatModels, SupportedLangModels } = require('intellinode');