Giter Site home page Giter Site logo

saurabhlalsaxena / function-calling-mistral-7b Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aianytime/function-calling-mistral-7b

0.0 0.0 0.0 30 KB

Function Calling Mistral 7B. Learn how to make functions call for open source LLMs.

License: MIT License

Python 5.65% Jupyter Notebook 94.35%

function-calling-mistral-7b's Introduction

Function Calling Mistral 7B Integration

This project demonstrates two different approaches to utilizing the MistralAI ChatMistralAI API for generating responses based on user prompts.

  1. The first approach, implemented in Function-Calling-Open-Source.ipynb, uses an open-source language model (teknium/OpenHermes-2.5-Mistral-7B). It demonstrates how to define Pydantic models for different types of responses, such as book recommendations, jokes, and song recommendations. It also includes functions for loading the model, generating responses based on prompts, and extracting function calls from the generated responses.

  2. The second approach, implemented in Function-Calling-Mistral-7B (using mistral API Key).py, demonstrates integration with MistralAI API key using langchain ChatMistralAI API. This integration allows the system to interact with MistralAI to generate responses based on user prompts. Similar to the local model approach, Pydantic models are defined for different types of responses, and functions are provided for loading the MistralAI model, generating responses, and extracting function calls from the responses. This approach uses an API key for authentication.

Features

  • Pydantic Models: Both approaches use Pydantic models to define the structure of the input prompts and the expected response formats. This allows for easy validation of input data and generation of response objects.

  • Function Call Extraction: Both approaches include functions for extracting function calls from the generated responses. This functionality allows the system to identify specific actions or functions requested by the user in the prompts.

  • API Key Handling: The MistralAI integration includes a mechanism for loading the API key from a .env file, ensuring that the API key is kept secure and not exposed in the code.

  • Response Generation: Both approaches demonstrate how to generate responses based on user prompts using the respective language models. The responses include text as well as function calls that can be executed based on the user's request.

Usage

  1. Open-Source Approach: In Function-Calling-Open-Source.ipynb, you can use the defined Pydantic models to create instances of requests (such as a book recommendation request or a joke request) and generate responses based on these requests.

  2. MistralAI API Key Approach: In Function-Calling-Mistral-7B (using mistral API Key).py, the integration with MistralAI API allows for more sophisticated responses based on the MistralAI model's capabilities. Requests can be made to the MistralAI model, and responses containing text and function calls can be generated.

Both approaches demonstrate how language models can be used to create interactive systems that can understand user requests and provide relevant responses.

function-calling-mistral-7b's People

Contributors

aianytime avatar kevin7744 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.