modelfusion

The TypeScript library for building AI applications.

MIT License

Stars
889
Committers
13

Bot releases are hidden (Show)

modelfusion - v0.88.0

Published by lgrammel 11 months ago

Added

  • Multi-modal chat prompts. Supported by OpenAI vision chat models and by BakLLaVA prompt format.

Changed

  • breaking change: renamed ChatPrompt to TextChatPrompt to distinguish it from multi-modal chat prompts.
modelfusion - v0.87.2

Published by lgrammel 11 months ago

modelfusion - v0.87.1

Published by lgrammel 11 months ago

modelfusion - v0.87.0

Published by lgrammel 11 months ago

Added

  • experimental: modelfusion/extension export with functions and classes that are necessary to implement providers in 3rd party node modules. See lgrammel/modelfusion-example-provider for an example.
modelfusion - v0.85.0

Published by lgrammel 11 months ago

Added

  • OpenAIChatMessage function call support.
modelfusion - v0.84.0

Published by lgrammel 11 months ago

Added

  • Support for OpenAI-compatible chat APIs. See OpenAI Compatible for details.

    import {
      BaseUrlApiConfiguration,
      openaicompatible,
      generateText,
    } from "modelfusion";
    
    const text = await generateText(
      openaicompatible
        .ChatTextGenerator({
          api: new BaseUrlApiConfiguration({
            baseUrl: "https://api.fireworks.ai/inference/v1",
            headers: {
              Authorization: `Bearer ${process.env.FIREWORKS_API_KEY}`,
            },
          }),
          model: "accounts/fireworks/models/mistral-7b",
        })
        .withTextPrompt(),
    
      "Write a story about a robot learning to love"
    );
    
modelfusion - v0.83.0

Published by lgrammel 11 months ago

Added

  • Introduce uncheckedSchema() facade function as an easier way to create unchecked ModelFusion schemas. This aligns the API with zodSchema().

Changed

  • breaking change: Renamed InstructionPrompt interface to MultiModalInstructionPrompt to clearly distinguish it from TextInstructionPrompt.
  • breaking change: Renamed .withBasicPrompt methods for image generation models to .withTextPrompt to align with text generation models.
modelfusion - v0.82.0

Published by lgrammel 11 months ago

Added

  • Introduce zodSchema() function as an easier way to create new ModelFusion Zod schemas. This clearly distinguishes it from ZodSchema that is also part of the zod library.
modelfusion - v0.81.0

Published by lgrammel 11 months ago

breaking change: generateStructure and streamStructure redesign. The new API does not require function calling and StructureDefinition objects any more. This makes it more flexible and it can now be used in 3 ways:

  • with OpenAI function calling:

    const model = openai
      .ChatTextGenerator({ model: "gpt-3.5-turbo" })
      .asFunctionCallStructureGenerationModel({
        fnName: "...",
        fnDescription: "...",
      });
    
  • with OpenAI JSON format:

    const model = openai
      .ChatTextGenerator({
        model: "gpt-4-1106-preview",
        temperature: 0,
        maxCompletionTokens: 1024,
        responseFormat: { type: "json_object" },
      })
      .asStructureGenerationModel(
        jsonStructurePrompt((instruction: string, schema) => [
          OpenAIChatMessage.system(
            "JSON schema: \n" +
              JSON.stringify(schema.getJsonSchema()) +
              "\n\n" +
              "Respond only using JSON that matches the above schema."
          ),
          OpenAIChatMessage.user(instruction),
        ])
      );
    
  • with Ollama (and a capable model, e.g., OpenHermes 2.5):

    const model = ollama
      .TextGenerator({
        model: "openhermes2.5-mistral",
        maxCompletionTokens: 1024,
        temperature: 0,
        format: "json",
        raw: true,
        stopSequences: ["\n\n"], // prevent infinite generation
      })
      .withPromptFormat(ChatMLPromptFormat.instruction())
      .asStructureGenerationModel(
        jsonStructurePrompt((instruction: string, schema) => ({
          system:
            "JSON schema: \n" +
            JSON.stringify(schema.getJsonSchema()) +
            "\n\n" +
            "Respond only using JSON that matches the above schema.",
          instruction,
        }))
      );
    

See generateStructure for details on the new API.

modelfusion - v0.80.0

Published by lgrammel 11 months ago

Changed

  • breaking change: Restructured multi-modal instruction prompts and OpenAIChatMessage.user()
modelfusion - v0.79.0

Published by lgrammel 11 months ago

Added

  • Multi-tool usage from open source models

    Use TextGenerationToolCallsOrGenerateTextModel and related helper methods .asToolCallsOrTextGenerationModel() to create custom prompts & parsers.

    Examples:

    • examples/basic/src/model-provider/ollama/ollama-use-tools-or-generate-text-openhermes-example.ts
    • examples/basic/src/model-provider/llamacpp/llamacpp-use-tools-or-generate-text-openhermes-example.ts

    Example prompt format:

    • examples/basic/src/tool/prompts/open-hermes.ts for OpenHermes 2.5
modelfusion - v0.78.0

Published by lgrammel 11 months ago

Removed

  • breaking change: Removed FunctionListToolCallPromptFormat. See examples/basic/src/model-provide/ollama/ollama-use-tool-mistral-example.ts for how to implement a ToolCallPromptFormat for your tool.
modelfusion - v0.77.0

Published by lgrammel 11 months ago

Changed

  • breaking change: Rename Speech to SpeechGenerator in facades
  • breaking change: Rename Transcription to Transcriber in facades
modelfusion - v0.76.0

Published by lgrammel 11 months ago

Added

  • Anthropic Claude 2.1 support
modelfusion - v0.75.0

Published by lgrammel 11 months ago

Introducing model provider facades:

const image = await generateImage(
  openai.ImageGenerator({ model: "dall-e-3", size: "1024x1024" }),
  "the wicked witch of the west in the style of early 19th century painting"
);

Added

  • Model provider facades. You can e.g. now use ollama.TextGenerator(...) instead of new OllamaTextGenerationModel(...).

Changed

  • breaking change: Fixed method name isParallizable to isParallelizable in EmbeddingModel.

Removed

  • breaking change: removed HuggingFaceImageDescriptionModel. Image description models will be replaced by multi-modal vision models.
modelfusion - v0.74.1

Published by lgrammel 11 months ago

Improved

  • Increase OpenAI chat streaming resilience.
modelfusion - v0.74.0

Published by lgrammel 11 months ago

Prompt format and tool calling improvements.

Added

  • text prompt format. Use simple text prompts, e.g. with OpenAIChatModel:

    const textStream = await streamText(
      new OpenAIChatModel({
        model: "gpt-3.5-turbo",
      }).withTextPrompt(),
      "Write a short story about a robot learning to love."
    );
    
  • .withTextPromptFormat to LlamaCppTextGenerationModel for simplified prompt construction:

    const textStream = await streamText(
      new LlamaCppTextGenerationModel({
        // ...
      }).withTextPromptFormat(Llama2PromptFormat.text()),
      "Write a short story about a robot learning to love."
    );
    
  • FunctionListToolCallPromptFormat to simplify tool calls with text models

  • .asToolCallGenerationModel() to OllamaTextGenerationModel to simplify tool calls:

    const { tool, args, toolCall, result } = await useTool(
      new OllamaTextGenerationModel({
        model: "mistral",
        temperature: 0,
      }).asToolCallGenerationModel(FunctionListToolCallPromptFormat.text()),
      calculator,
      "What's fourteen times twelve?"
    );
    

Improved

  • better error reporting when using exponent backoff retries

Removed

  • breaking change: removed input from InstructionPrompt (was Alpaca-specific, AlpacaPromptFormat still supports it)
modelfusion - v0.73.1

Published by lgrammel 11 months ago

Remove section newlines from Llama 2 prompt format.

modelfusion - v0.73.0

Published by lgrammel 11 months ago

Ollama edge case and error handling improvements.

modelfusion - v0.72.0

Published by lgrammel 11 months ago

Breaking change: the tool calling API has been reworked to support multiple parallel tool calls. This required multiple breaking changes (see below). Check out the updated tools documentation for details.

Changed

  • Tool now has parameters and returnType schemas (instead of inputSchema and outputSchema).
  • useTool uses generateToolCall under the hood. The return value and error handling has changed.
  • useToolOrGenerateText has been renamed to useToolsOrGenerateText. It now uses generateToolCallsOrText under the hood. The return value and error handling has changed. It can now invoke several tools in parallel and returns an array of tool results.
  • The maxRetries parameter in guard has been replaced by a maxAttempt parameter.

Removed

  • generateStructureOrText has been removed.
Badges
Extracted from project README
NPM Version MIT License Docs Created by Lars Grammel