Skip to content

v0.127.0

Compare
Choose a tag to compare
@lgrammel lgrammel released this 15 Jan 07:17

Changed

  • breaking change: streamStructure returns an async iterable over deep partial objects. If you need to get the fully validated final result, you can use the fullResponse: true option and await the structurePromise value. Example:

    const { structureStream, structurePromise } = await streamStructure({
      model: ollama
        .ChatTextGenerator({
          model: "openhermes2.5-mistral",
          maxGenerationTokens: 1024,
          temperature: 0,
        })
        .asStructureGenerationModel(jsonStructurePrompt.text()),
    
      schema: zodSchema(
        z.object({
          characters: z.array(
            z.object({
              name: z.string(),
              class: z
                .string()
                .describe("Character class, e.g. warrior, mage, or thief."),
              description: z.string(),
            })
          ),
        })
      ),
    
      prompt:
        "Generate 3 character descriptions for a fantasy role playing game.",
    
      fullResponse: true,
    });
    
    for await (const partialStructure of structureStream) {
      console.clear();
      console.log(partialStructure);
    }
    
    const structure = await structurePromise;
    
    console.clear();
    console.log("FINAL STRUCTURE");
    console.log(structure);
  • breaking change: Renamed text value in streamText with fullResponse: true to textPromise.

Fixed

  • Ollama streaming.
  • Ollama structure generation and streaming.