You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This functionality is still in active development. However, that said, it is indeed possible (but not well documented yet). See this script presented at the NYU hackathon event:
import{LMStudioClient}from"@lmstudio/sdk";import{readFile}from"fs/promises";import{basename}from"path";import{createInterface}from"readline/promises";constclient=newLMStudioClient();constdocumentPath="./Frozen Script.txt";constrl=createInterface({input: process.stdin,output: process.stdout,});constquestion=awaitrl.question("Enter a question: ");rl.close();constdocument=awaitclient.files.uploadTempFile(basename(documentPath),awaitreadFile(documentPath));constnomic=awaitclient.embedding.getOrLoad("text-embedding-nomic-embed-text-v1.5@q8_0");constresults=awaitclient.retrieval.retrieve(question,[document],{embeddingModel: nomic,});constprompt=`Given the following citation, please answer user's question:----- Citation -----${results.entries[0].content}----- End of Citation -----Question: ${question}`;constllama=awaitclient.llm.getOrLoad("llama-3.2-3b-instruct");constprediction=llama.respond([{role: "user",content: prompt,},]);forawait(const{ content }ofprediction){process.stdout.write(content);}const{ stats }=awaitprediction;console.info("\nStats:");console.info(stats);
Hi there, how can the equivalent of "Chat with Documents" as explained in the documentation https://lmstudio.ai/docs/basics/rag be done here?
The text was updated successfully, but these errors were encountered: