Created
June 18, 2024 04:40
-
-
Save kartikver15gr8/8151a65683939703cb4c050b8f2cc56e to your computer and use it in GitHub Desktop.
llama.js
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
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