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
const search = new SemanticSearch(apiKey, 'cohere'); |
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
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) |
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
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 |
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
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, |
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
{ | |
'openai/gpt-4': [ | |
{ | |
prediction: '<model-output>', | |
score_cosine_similarity: <score>, | |
score_euclidean_distance: <score> | |
} | |
], | |
'cohere/command': [ | |
{ |
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
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 |
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
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) |
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
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 |
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
const openaiChat = { | |
apiKey: openaiKey, | |
provider: SupportedChatModels.OPENAI, | |
type: 'chat', | |
model: 'gpt-4', | |
maxTokens: 50 | |
}; | |
const cohereCompletion = { | |
apiKey: cohereKey, |
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
const { LLMEvaluation, SupportedChatModels, SupportedLangModels } = require('intellinode'); |
NewerOlder