Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kartikver15gr8/8151a65683939703cb4c050b8f2cc56e to your computer and use it in GitHub Desktop.
Save kartikver15gr8/8151a65683939703cb4c050b8f2cc56e to your computer and use it in GitHub Desktop.
llama.js
import axios from "axios";
const apiKey =
"LL-qeLWRjAfEGKL5MdNR4XgdG14TW87VlVuYSRfYZoCBLbe5JSaMAvUEWHBdS2W7rDT";
const llamaUrl = "https://api.meta.ai/v1/llama";
async function converseWithLlama(prompt) {
try {
const headers = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
};
const data = {
model: "llama",
prompt: prompt,
max_tokens: 100,
};
const response = await axios.post(llamaUrl, data, { headers });
const result = response.data;
console.log(`LLaMA response: ${result.completion}`);
return result.completion;
} catch (error) {
console.error(`Error: `, error);
}
}
converseWithLlama("can you tell me what is blockchain?");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment