Resturant name and menu Generator — Gen AI and LLM
This is my first attempt in using Large language module , Open AI and streamlit to create a resturant name and menu generator as per the cuisine.
The first stage, we intall the required libraries.
a. from langchain_openai import ChatOpenAI module provides an interface to interact with the OpenAI GPT-3 model for chat-based language tasks. By using this class, you can create an instance of `ChatOpenAI` and then use its methods to send messages to the model and receive responses. This can be useful for building chatbots, virtual assistants, or any other application that involves conversational interactions with users.
b. from langchain.prompts import PromptTemplate : The `PromptTemplate` class provides a way to define and manage templates for generating prompts. A prompt template is a string with placeholders that can be dynamically filled in with values at runtime. Using `PromptTemplate`, you can define reusable prompt templates that can be easily customized or extended by substituting different values for the placeholders. This can be useful for generating prompts for language models, question answering systems, or any other application where dynamic prompts are needed.
c. from langchain.chains import LLMChain : The `LLMChain` class is a language modeling chain that provides a convenient way to generate text using a pre-trained language model. It abstracts the complexity of working with language models and simplifies the process of generating coherent and contextually relevant text. By using `LLMChain`, you can instantiate a language model chain and then use its methods to generate text based on given input or context. This can be useful for a variety of applications, such as text generation, content creation, and language understanding tasks.
d. from langchain.chains import SimpleSequentialChain: The `SimpleSequentialChain` class represents a simple sequential chain of language models. It provides an interface for generating text by sequentially passing input through a series of language models. Using `SimpleSequentialChain`, you can create a chain of language models that can be used to generate text in a step-by-step manner. This can be useful for tasks that require multi-step processing, such as text summarization, language translation, or text generation with specific constraints. By defining a sequence of language models and passing input through each model in order, you can leverage the capabilities of multiple models to improve the quality and relevance of the generated text.
e. from langchain.chains import SequentialChain: It is a more general form of sequential chain allowing multiple inputs or outputs.
Once the required environment is set using the appropriate Open AI key, we set the temperrature to 0.8. Here temperature means the randomness of the model. A higher temperature value, such as 0.8, makes the model generate more diverse and creative responses by increasing the randomness. This means that the model is more likely to generate unexpected or unconventional answers. Conversely, lower temperature values like 0.2 make the model more focused and deterministic, often resulting in more conservative and safe responses.
In the first step , we pass the required cuisine as the input variable. In the prompt template , we can the pass the required prompt. The output produced at this stage is the restaurant name.
For the next prompt , we pass the restaurant name to generate a menu. The output is menu list.
We use the Sequential Chain , where we pass the cuisine as the input variable , both chains to generate the restaurant name and menu list.
In another file, which we say as the main file, we pass the LLM model to display the outputs in a stream lit app.
Note : For running stream lit we use the command “ streamlit run main.py”
This is done by following the youtube video of Codebasics.