import os
from langchain.chat_models import ChatOpenAI
from dotenv import load_dotenv, find_dotenv
= load_dotenv(find_dotenv()) # read local .env file
_
= 'gpt-3.5-turbo'
OpenAIModel = ChatOpenAI(model=OpenAIModel, temperature=0.1) llm
Memory Exercise Answer Key
Note: This is only one of the possible answer in using Memory for Langchain.
from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory
= ConversationBufferMemory()
memory
= ConversationChain(
conversationUsingBufferMemory =llm,
llm= memory,
memory =True
verbose )
="If I have studied front-end engineering, what skills do I have?" # @param {type:"string"} userInput
input=userInput) conversationUsingBufferMemory.predict(
> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.
Current conversation:
Human: Hello, i'm Djarot Purnomo. I'm a UI/UX Designer
AI: Hello Djarot Purnomo, nice to meet you! As a UI/UX Designer, you must have a keen eye for aesthetics and a deep understanding of user experience. How did you get into this field?
Human: explain the relationship between a UI/UX Designer and a Front End Engineer
AI: A UI/UX Designer and a Front End Engineer work closely together to create a seamless user experience on a website or application. The UI/UX Designer is responsible for designing the overall look and feel of the product, including the layout, colors, typography, and interactive elements. They focus on understanding the needs and preferences of the users and creating intuitive and visually appealing designs.
On the other hand, the Front End Engineer is responsible for implementing the designs created by the UI/UX Designer. They take the visual elements and translate them into code using HTML, CSS, and JavaScript. They ensure that the design is responsive and functional across different devices and browsers. They also optimize the performance of the website or application and handle any technical challenges that may arise during the development process.
In summary, the UI/UX Designer focuses on the user interface and user experience design, while the Front End Engineer focuses on the implementation and coding of those designs. They collaborate closely to ensure that the final product meets both the aesthetic and functional requirements.
Human: If I have studied front-end engineering, what skills do I have?
AI:
> Finished chain.
'If you have studied front-end engineering, you would have gained skills in HTML, CSS, and JavaScript, which are the core technologies used in front-end development. You would have learned how to create the structure and layout of a website using HTML, style it using CSS to control the visual appearance, and add interactivity and functionality using JavaScript.\n\nAdditionally, you may have learned about responsive design, which involves making websites adapt to different screen sizes and devices. You may also have knowledge of front-end frameworks and libraries such as Bootstrap or React, which can help streamline the development process and provide pre-built components.\n\nOther skills you may have acquired include knowledge of web accessibility standards, understanding of browser compatibility issues, and familiarity with version control systems like Git. Overall, studying front-end engineering equips you with the skills needed to create visually appealing and interactive websites or applications.'
=memory.buffer
chatHistory chatHistory
"Human: Hello, i'm Djarot Purnomo. I'm a UI/UX Designer\nAI: Hello Djarot Purnomo, nice to meet you! As a UI/UX Designer, you must have a keen eye for aesthetics and a deep understanding of user experience. How did you get into this field?\nHuman: explain the relationship between a UI/UX Designer and a Front End Engineer\nAI: A UI/UX Designer and a Front End Engineer work closely together to create a seamless user experience on a website or application. The UI/UX Designer is responsible for designing the overall look and feel of the product, including the layout, colors, typography, and interactive elements. They focus on understanding the needs and preferences of the users and creating intuitive and visually appealing designs.\n\nOn the other hand, the Front End Engineer is responsible for implementing the designs created by the UI/UX Designer. They take the visual elements and translate them into code using HTML, CSS, and JavaScript. They ensure that the design is responsive and functional across different devices and browsers. They also optimize the performance of the website or application and handle any technical challenges that may arise during the development process.\n\nIn summary, the UI/UX Designer focuses on the user interface and user experience design, while the Front End Engineer focuses on the implementation and coding of those designs. They collaborate closely to ensure that the final product meets both the aesthetic and functional requirements."