/*--- title: Ask a language model group: Services summary: llm.chat and llm.request with replies set in the LLM window. setup: {"mocks":{"llm":{"mode":"rules","reply":"I am a mock model. You asked: {{prompt}}","rules":[{"match":"Summarize","reply":"The notes say filelib sees user:/ and that scripts only change files when they run."}]}}} ---*/ requirelib("filelib"); requirelib("llm"); var notes = filelib.readFile("user:/Documents/notes.md"); // llm.chat sends one prompt and returns the reply text. var summary = llm.chat("Summarize these notes in one sentence:\n" + notes); // llm.request takes the full message list and returns the // chat.completion object, as the OpenAI API does. var full = llm.request([ { role: "system", content: "You answer in one short sentence." }, { role: "user", content: "What is the playground for?" } ]); sendJSONResp({ summary: summary, answer: full.choices[0].message.content, model: full.model, usage: llm.usage() });