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');
{
'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');
export REPLICATE_API_KEY=<your-replica-key>
export OPENAI_API_KEY=<your-openai-key>
# optional - if you deployed Llama sagemaker ednpoint
export AWS_API_URL=<sagemaker-url>
// When copying the code to the same file, ensure removing the repeated imports
const { Chatbot, ChatGPTInput, ChatGPTMessage } = require('intellinode');
app.get('/chatgpt', async (req, res) => {
const chatbot = new Chatbot(process.env.OPENAI_API_KEY, 'openai');
const system = 'You are a helpful assistant.';
const input = new ChatGPTInput(system);
input.addUserMessage(req.query.message);
// When copying the code to the same file, ensure removing the repeated imports
const { Chatbot, LLamaSageInput, SupportedChatModels } = require('intellinode');
app.get('/llama/aws', async (req, res) => {
const chatbot = new Chatbot(null, SupportedChatModels.SAGEMAKER, {url: process.env.AWS_API_URL});
const system = 'You are a helpful assistant.';
const input = new LLamaSageInput(system);
input.addUserMessage(req.query.message);