Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mistral[minor]: integrating Mistral LLM with AgentExecutor #4845

Merged

Conversation

marinBlobr
Copy link
Contributor

Enhancing LangChain.js with Mistral Model Compatibility

This PR aims to adjust the ChatMistralAI class to ensure its compatibility with the createOpenAIToolsAgent interface, thereby enabling the use of Mistral models, specifically mistral-large-latest and mistral-small-latest, within the execution agent that utilizes tool calling in the manner of OpenAI. This modification aligns with the API specifications of Mistral for the mentioned models, making them compatible with the same implementations as those of recent OpenAI models, such as gpt-4-0125-preview and gpt-3.5-turbo-0125, as mentioned here: LangChain Agents Documentation.

The extended compatibility allows for the seamless integration of Mistral's capabilities within agents, using the createOpenAIToolsAgent method to create an agent. This method supports tool calling in the OpenAI style, making Mistral models suitable for use in agent scenarios similarly to OpenAI's GPT-3.5 and GPT-4 models.

References:

Compatible Models with Tools:

  • open-mistral-7b (aka mistral-tiny-2312)
  • open-mistral-8x7b (aka mistral-small-2312)
  • mistral-small-latest (aka mistral-small-2402)
  • mistral-medium-latest (aka mistral-medium-2312)
  • mistral-large-latest (aka mistral-large-2402)

Note: Models not listed as bold are not supported with tools implementation.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 21, 2024
Copy link

vercel bot commented Mar 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 22, 2024 0:12am
langchainjs-docs ✅ Ready (Inspect) Visit Preview Mar 22, 2024 0:12am

@jacoblee93
Copy link
Collaborator

This is awesome! CC @bracesproul but looks good to me.

@jacoblee93 jacoblee93 added the lgtm PRs that are ready to be merged as-is label Mar 21, 2024
@marinBlobr marinBlobr force-pushed the feature/mistral-agent-executor branch from f5cc134 to 5767a70 Compare March 22, 2024 12:05
@marinBlobr
Copy link
Contributor Author

This is awesome! CC @bracesproul but looks good to me.

Thanks, I've added the langchain package in the devDependencies to ensure the build for testing is valid.

@jacoblee93 jacoblee93 changed the title feat(mistral): integrating Mistral LLM with AgentExecutor mistral[minor]: integrating Mistral LLM with AgentExecutor Mar 24, 2024
@@ -183,9 +190,17 @@ function convertMessagesToMistralMessages(
);
};

const getTools = (toolCalls: ToolCall[] | undefined): MistralAIToolCalls[] =>
toolCalls?.map((toolCall) => ({
id: "null",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to assign this a UUID?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting. I guess not

@jacoblee93 jacoblee93 merged commit 65d75cf into langchain-ai:main Mar 24, 2024
17 checks passed
@jacoblee93
Copy link
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases lgtm PRs that are ready to be merged as-is size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants