2
0
Bruce MacDonald 1 жил өмнө
parent
commit
65d81a769d

+ 2 - 3
examples/fill-in-middle/fill.ts

@@ -7,10 +7,9 @@ async function main(): Promise<void> {
     const suffix = `
 return result
 `;
-
-    const respose = await new Ollama().generate({model: "codellama:7b-code", prompt: `<PRE> ${prefix} <SUF>${suffix} <MID>`, options: {num_predict: 128, temperature: 0, top_p: 0.9, presence_penalty: 0, stop: ["<EOT>"]}});
+    const client: Ollama = new Ollama();
+    const respose = await client.generate({model: "codellama:7b-code", prompt: `<PRE> ${prefix} <SUF>${suffix} <MID>`, options: {num_predict: 128, temperature: 0, top_p: 0.9, presence_penalty: 0, stop: ["<EOT>"]}});
     console.log(respose.response);
-
 }
 
 await main();

+ 11 - 0
examples/generate-stream/generate.ts

@@ -0,0 +1,11 @@
+import { Ollama } from '../../src/index';
+
+async function main(): Promise<void> {
+    const client: Ollama = new Ollama();
+    const stream = await client.generate({model: "mistral", prompt: "Why is the sky blue?", stream: true});
+    for await (const part of stream) {
+        process.stdout.write(part.response);
+    }
+}
+
+await main();

+ 9 - 0
examples/generate/generate.ts

@@ -0,0 +1,9 @@
+import { Ollama } from '../../src/index';
+
+async function main(): Promise<void> {
+    const client: Ollama = new Ollama();
+    const respose = await client.generate({model: "mistral", prompt: "Why is the sky blue?"});
+    console.log(respose.response);
+}
+
+await main();