Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kartikver15gr8/8151a65683939703cb4c050b8f2cc56e to your computer and use it in GitHub Desktop.

Select an option

Save kartikver15gr8/8151a65683939703cb4c050b8f2cc56e to your computer and use it in GitHub Desktop.

Revisions

  1. kartikver15gr8 created this gist Jun 18, 2024.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original 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?");