Created
June 18, 2024 04:40
-
-
Save kartikver15gr8/8151a65683939703cb4c050b8f2cc56e to your computer and use it in GitHub Desktop.
Revisions
-
kartikver15gr8 created this gist
Jun 18, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ 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?");