UNPKG

llm-pdf

Version:

Command Line tool to automate LLM and image models to generate a pdf by converting the generated text into markdown format and save it as a pdf document.

45 lines (40 loc) 1.32 kB
import Together from "together-ai"; // import dotenv from "dotenv"; // dotenv.config(); const together = new Together({ apiKey: "26d7651e279a9c77d6b0a1e3fdd5167788978e10ca35a02a02a0047fa6c714cc" }); async function useLLM(system, prompt) { try { const response = await together.chat.completions.create({ messages: [ { role: "system", content: `${system}` }, { role: "user", content: `${prompt}` } ], model: "meta-llama/Llama-3.3-70B-Instruct-Turbo-Free", max_tokens: null, temperature: 0.7, top_p: 0.7, top_k: 50, repetition_penalty: 1, stop: ["/bye"], stream: true }); let content = ""; for await (const token of response) { const messageToken = token.choices[0]?.delta?.content || ''; process.stdout.write(messageToken); content += messageToken; } console.log("\n"); return content; } catch (error) { console.error("Error getting response:", error); throw error; } } export default useLLM;