Skip to content

v0.7.5

Latest
Compare
Choose a tag to compare
@davidmigloz davidmigloz released this 22 Aug 18:05
· 9 commits to main since this release
9dff3cf

2024-08-22

What's New?

✨ OpenAI's Structured Outputs

The ChatOpenAI wrapper now supports OpenAI's Structured Outputs. This allows you to provide a JSON Schema to guide the model's responses, ensuring they adhere to your desired JSON format. You can simply provide the schema for guidance, or enable strict mode to guarantee the model's output matches the schema exactly, so you don't need to worry about the model omitting a required key, or hallucinating an invalid enum value. Mind that only a subset of JSON Schema is supported when strict is enabled.

final chatModel = ChatOpenAI(
  apiKey: openaiApiKey,
  defaultOptions: ChatOpenAIOptions(
    model: 'gpt-4o',
    responseFormat: ChatOpenAIResponseFormat.jsonSchema(
      ChatOpenAIJsonSchema(
        name: 'Companies',
        description: 'A list of companies',
        strict: true,
        schema: {
          'type': 'object',
          'properties': {
            // your schema definition
          },
          'additionalProperties': false,
        },
      ),
    ),
  ),
);

Strict mode is also available when working with tools. ToolSpec now has a strict field that you can set it to true to enable it.

Read more about how it works internally in their announcement blog post and how to use it in LangChain.dart in the ChatOpenAI documentation.

🤖 ToolsAgent: A Generic Tool-Calling Agent

While we're working on porting LangGraph to Dart, we've refactored OpenAIToolsAgent into a new, more versatile ToolsAgent. This generic agent can be used with any model that supports tool-calling, including ChatOllama, ChatOpenAI, ChatAnthropic, and more. Check out the docs for more info.

To migrate from OpenAIToolsAgent to ToolsAgent just run:

dart fix --apply

🛠️ Other Improvements

  • All RunnableOptions subclasses now have a convenient copyWith method for easier modification.
  • ChatOpenAI now includes log probabilities (logprobs) in the result metadata, offering more context for analysis.
  • Removed the OpenAI-Beta header in ChatOpenAI to prevent CORS issues when using OpenRouter.
  • Added gpt-4o-2024-08-06 and chatgpt-4o-latest to the model catalog in ChatOpenAI.
  • Added support for min_p in ChatOllama, providing more control over the sampling process.

💡 Introducing Code Assist AI

Thanks to the team at CommandDash, we now have a dedicated AI chatbot to help you with LangChain.dart! This chatbot can answer your questions, provide documentation links, and even generate code snippets. Try it out here:

Code Assist AI

🔧 API Clients Updates

  • openai_dart: Now supports OpenAI's Structured Outputs.
  • ollama_dart: Now supports the min_p parameter for finer control over sampling.

Changes


Packages with breaking changes:

  • There are no breaking changes in this release.

Packages with other changes:

Packages with dependency updates only:

Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.

  • langchain_firebase - v0.2.1+1
  • langchain_supabase - v0.1.1+2
  • langchain_pinecone - v0.1.0+8
  • langchain_anthropic - v0.1.1+1
  • langchain_chroma - v0.2.1+2

langchain - v0.7.5

  • FEAT: Add ToolsAgent for models with tool-calling support (#530). (f3ee5b44)
  • FEAT: Deprecate OpenAIToolsAgent in favour of ToolsAgent (#532). (68d8011a)
  • DOCS: Add Code Assist AI in README and documentation (#538). (e752464c)

langchain_core - v0.3.5

  • FEAT: Add copyWith method to all RunnableOptions subclasses (#531). (42c8d480)
  • FEAT: Support OpenAI's strict mode for tool calling in ChatOpenAI (#536). (71623f49)
  • FEAT: Deprecate OpenAIToolsAgent in favour of ToolsAgent (#532). (68d8011a)

langchain_community - v0.3.1

  • FEAT: Deprecate OpenAIToolsAgent in favour of ToolsAgent (#532). (68d8011a)

langchain_openai - v0.7.1

  • FEAT: Add support for Structured Outputs in ChatOpenAI (#526). (c5387b5d)
  • FEAT: Handle refusal in OpenAI's Structured Outputs API (#533). (f4c4ed99)
  • FEAT: Include logprobs in result metadata from ChatOpenAI (#535). (1834b3ad)
  • FEAT: Add chatgpt-4o-latest to model catalog (#527). (ec82c760)
  • FEAT: Add gpt-4o-2024-08-06 to model catalog (#522). (563200e0)
  • FEAT: Deprecate OpenAIToolsAgent in favour of ToolsAgent (#532). (68d8011a)
  • REFACTOR: Don't send OpenAI-Beta header in ChatOpenAI (#511). (0e532bab)

langchain_ollama - v0.3.1

  • FEAT: Add support for min_p in Ollama (#512). (e40d54b2)
  • FEAT: Add copyWith method to all RunnableOptions subclasses (#531). (42c8d480)

langchain_google - v0.6.2

  • FEAT: Add copyWith method to all RunnableOptions subclasses (#531). (42c8d480)

langchain_mistralai - v0.2.3

  • FEAT: Add copyWith method to all RunnableOptions subclasses (#531). (42c8d480)

openai_dart - v0.4.1

  • FEAT: Add support for Structured Outputs (#525). (c7574077)
  • FEAT: Add log probabilities for refusal tokens (#534). (8470a24c)
  • FEAT: Add gpt-4o-2024-08-06 to model catalog (#522). (563200e0)
  • FEAT: Add chatgpt-4o-latest to model catalog (#527). (ec82c760)

ollama_dart - v0.2.1

New Contributors

Full Changelog: langchain-v0.7.4...langchain-v0.7.5


📣 Check out the #announcements channel in the LangChain.dart Discord server for more details.