Skip to content

Instantly share code, notes, and snippets.

@RageshAntony
Created August 1, 2023 12:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RageshAntony/653820209f79d0ac8910f6ccda3ee7b2 to your computer and use it in GitHub Desktop.
Save RageshAntony/653820209f79d0ac8910f6ccda3ee7b2 to your computer and use it in GitHub Desktop.
Chat with Documents with Memory using LangChain
import openai
from colorama import Fore
from langchain import PromptTemplate
from langchain.chains import ConversationalRetrievalChain, RetrievalQA
from langchain.chat_models import ChatOpenAI
from langchain.document_loaders import TextLoader
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.memory import ConversationBufferMemory
from langchain.schema import SystemMessage
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.vectorstores import Chroma
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
if __name__ == '__main__':
print("status: loading document")
loader = TextLoader("../docs/doc.txt")
pages = loader.load_and_split()
text_splitter = RecursiveCharacterTextSplitter(
chunk_size=1000,
chunk_overlap=200,
length_function=len,
)
docs = text_splitter.split_documents(pages)
# Split documents into chunks
gds_data_split = docs
print(len(gds_data_split))
# Define embedding model
OPENAI_API_KEY = "key from consle "
embeddings_model_name = "sentence-transformers/all-MiniLM-L6-v2"
embeddings = HuggingFaceEmbeddings(model_name=embeddings_model_name)
support_data = gds_data_split
support_store = Chroma.from_documents(
support_data, embeddings, collection_name="support"
)
print("status: configure llm")
llm = ChatOpenAI(
model_name="gpt-4",
temperature=0,
openai_api_key=OPENAI_API_KEY,
max_tokens=6024,
verbose=False,
streaming = True, callbacks = [StreamingStdOutCallbackHandler()]
)
sales_template = """As a TechSamurai marketing bot, your goal is to provide accurate and helpful information about
TechSamurai products. You should answer user inquiries based on the context provided. If he greets, then greet him. Don't include prefix 'Answer'.
Use the following context (delimited by <ctx></ctx>) and the chat history (delimited by <hs></hs>) to answer the question:
<ctx>
{context}
</ctx>
<hs> {history} </hs>
Question: {question}"""
SALES_PROMPT = PromptTemplate(
template=sales_template, input_variables=["history", "context", "question"]
)
sales_qa = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=support_store.as_retriever(),
chain_type_kwargs={
"verbose": False,
"prompt": SALES_PROMPT,
"memory": ConversationBufferMemory(
memory_key="history",
input_key="question"),
},
verbose = False
)
while True:
query = input(" > ")
result = sales_qa.run(query)
print("\n")
Sales Executive Documentation for TechSamurai:
Products by TechSamurai:
1. FLIXSamurai
2. HouseTalk
3. SweetSangeet
1) FLIXSamurai by TechSamurai
Product Overview:
Welcome to our Sales Executive documentation for FLIXSamurai, our Netflix clone developed by TechSamurai! This document provides an overview of FLIXSamurai, its key features, target audience, and selling points to help you effectively promote and sell our product.
Product Description:
FLIXSamurai, developed by TechSamurai, is a cutting-edge streaming platform designed to deliver a seamless and immersive entertainment experience to users. With a vast library of movies, TV shows, documentaries, and original content, FLIXSamurai offers endless hours of entertainment for subscribers. Featuring a user-friendly interface and robust features, FLIXSamurai aims to become the go-to destination for streaming enthusiasts.
Key Features:
Extensive Content Library: FLIXSamurai boasts an extensive collection of licensed movies, popular TV series, documentaries, and exclusive original content. Our diverse content library ensures that there's something for everyone.
Personalized Recommendations: Using advanced algorithms, FLIXSamurai provides personalized content recommendations based on users' viewing history, preferences, and ratings. This feature enhances user engagement and encourages longer subscription periods.
Seamless Cross-Device Experience: Subscribers can enjoy FLIXSamurai on various devices, including smartphones, tablets, smart TVs, and web browsers. The platform synchronizes the user's progress across devices, allowing them to seamlessly resume watching from where they left off.
Multiple User Profiles: FLIXSamurai supports multiple user profiles within a single account, catering to the needs of families and friends. Each profile can have personalized preferences, recommendations, and viewing history.
Offline Viewing: Users can download their favorite movies and TV shows on FLIXSamurai to watch offline. This feature enables convenient viewing during travel or in areas with limited internet access.
User-Friendly Interface: FLIXSamurai features an intuitive and visually appealing interface, making it easy for users to navigate through the content library and discover new shows and movies.
Target Audience:
Streaming Enthusiasts: Individuals who enjoy binge-watching TV shows, movies, and documentaries and are looking for a vast collection of high-quality content.
Families and Friends: Users who want to share a streaming platform with multiple profiles and personalized recommendations to cater to the preferences of each family member or friend.
Mobile Users: People who prefer to watch content on their smartphones or tablets while on the go.
Offline Viewers: Users who want the flexibility to download their favorite shows and movies to watch offline, especially during travel or when internet access is limited.
Selling Points:
Extensive content library with a diverse range of movies, TV shows, documentaries, and original content.
Personalized recommendations based on user preferences, enhancing the overall viewing experience.
Seamless cross-device synchronization, allowing users to switch devices and resume watching seamlessly.
Multiple user profiles, ensuring personalized experiences for each member of a family or group of friends.
Offline viewing capability, providing flexibility and convenience for users.
User-friendly interface, making it easy to navigate and discover new content.
With FLIXSamurai, users can enjoy a comprehensive streaming experience tailored to their preferences, ensuring they always have quality entertainment at their fingertips. Join us in revolutionizing the streaming industry with FLIXSamurai by TechSamurai!
2) HouseTalk by TechSamurai
Product Overview:
Welcome to our Sales Executive documentation for HouseTalk, our Clubhouse clone developed by TechSamurai! This document provides an overview of HouseTalk, its key features, target audience, and selling points to help you effectively promote and sell our product.
Product Description:
HouseTalk, developed by TechSamurai, is a dynamic audio-based social networking platform designed to connect people and foster meaningful conversations. Inspired by Clubhouse, HouseTalk allows users to join virtual rooms, participate in discussions, and share insights on various topics of interest. With its interactive and engaging features, HouseTalk aims to provide a unique audio-based social experience to its users.
Key Features:
Audio-Based Conversations: HouseTalk revolves around audio-based interactions, where users can join virtual rooms and engage in live discussions on diverse topics.
Virtual Rooms: Users can create and join virtual rooms dedicated to specific subjects or interests, allowing like-minded individuals to connect and share knowledge.
Speaker and Listener Roles: HouseTalk offers two distinct roles – Speakers and Listeners. Speakers can host discussions, while Listeners can actively participate by asking questions and sharing their perspectives.
Interactive Q&A Sessions: HouseTalk facilitates interactive Q&A sessions within virtual rooms, enabling users to engage with speakers and gain valuable insights.
Follow and Notification System: Users can follow their favorite speakers or topics of interest to receive notifications when relevant discussions are taking place.
Social Integration: HouseTalk allows users to connect their profiles with other social media platforms, expanding their network and fostering cross-platform engagement.
Target Audience:
Thought Leaders and Influencers: Individuals who want to share their expertise, connect with their audience, and engage in meaningful conversations on various topics.
Professionals and Industry Experts: Users looking to network, exchange ideas, and stay updated on industry trends within their respective fields.
Knowledge Seekers: Individuals who are eager to learn and gain insights from experts by actively participating in live discussions and Q&A sessions.
Community Builders: Users interested in creating and nurturing communities around specific interests or subject matters.
Selling Points:
Unique audio-based social networking platform that enables users to connect and engage in live discussions.
Virtual rooms for hosting and joining conversations on diverse topics of interest.
Interactive Q&A sessions that allow users to actively participate and gain insights from industry experts.
Follow and notification system to stay informed about relevant discussions and speakers of interest.
Social integration to expand the user's network and foster cross-platform engagement.
With HouseTalk, users can join virtual rooms, share knowledge, and build meaningful connections with like-minded individuals. Join us in revolutionizing the social networking landscape with HouseTalk by TechSamurai!
3) SweetSangeet by TechSamurai
Product Overview:
Welcome to our Sales Executive documentation for SweetSangeet, our Spotify clone developed by TechSamurai! This document provides an overview of SweetSangeet, its key features, target audience, and selling points to help you effectively promote and sell our product.
Product Description:
SweetSangeet, developed by TechSamurai, is a feature-rich music streaming platform designed to provide users with a seamless and immersive music listening experience. Inspired by Spotify, SweetSangeet offers a vast library of songs from various genres and artists, along with personalized recommendations and a host of interactive features. Our goal is to create a go-to destination for music enthusiasts and revolutionize the way people enjoy music.
Key Features:
Extensive Music Library: SweetSangeet boasts an extensive collection of songs from a wide range of genres, including popular tracks, classics, emerging artists, and international music. Users can discover and enjoy their favorite songs anytime, anywhere.
Personalized Recommendations: Using advanced algorithms, SweetSangeet provides personalized music recommendations based on users' listening history, preferences, and curated playlists. This feature ensures an engaging and tailored music experience for every user.
Playlist Creation and Sharing: Users can create their own playlists, add songs, and share them with friends, fostering a sense of musical community and enabling users to discover new music.
Offline Listening: SweetSangeet allows users to download their favorite songs and playlists for offline listening, ensuring uninterrupted enjoyment even in areas with limited internet connectivity.
Interactive Features: SweetSangeet offers interactive features such as song lyrics, artist biographies, and related artist recommendations, allowing users to delve deeper into their favorite music and explore new artists.
Cross-Platform Availability: Users can access SweetSangeet on multiple platforms, including smartphones, tablets, web browsers, and smart devices, ensuring a seamless listening experience across devices.
Target Audience:
Music Enthusiasts: Individuals who have a deep appreciation for music and are looking for a vast collection of songs across different genres.
Playlist Creators: Users who enjoy curating their own playlists and sharing their musical discoveries with others.
Discoverers: Individuals who are eager to explore new artists, genres, and musical trends.
On-the-Go Listeners: Users who prefer to enjoy music on their smartphones or tablets while commuting, exercising, or traveling.
Selling Points:
Extensive music library with a wide range of genres and artists.
Personalized recommendations based on users' listening preferences, ensuring an engaging and tailored music experience.
Playlist creation and sharing features to foster a sense of community and enable music discovery.
Offline listening capability, allowing users to enjoy music even without an internet connection.
Interactive features such as song lyrics, artist biographies, and related artist recommendations for a more immersive music experience.
Cross-platform availability for seamless music listening across devices.
With SweetSangeet, users can immerse themselves in a world of music, discover new artists, and enjoy a personalized music experience like never before. Join us in revolutionizing the way people enjoy music with SweetSangeet by TechSamurai!
Frameworks supported by the Products.
Front-end Frameworks:
Native Android:
Supported by our products, including FLIXSamurai, HouseTalk, and SweetSangeet.
Provides a robust and native user interface for Android devices.
Leverages the power of Java or Kotlin programming languages to deliver high-performance and seamless experiences to users.
Native iOS:
Supported by our products, including FLIXSamurai, HouseTalk, and SweetSangeet.
Enables the development of native and engaging user interfaces for iOS devices.
Utilizes Swift or Objective-C to leverage iOS platform features and deliver optimal performance.
Flutter:
Supported by our products, including FLIXSamurai, HouseTalk, and SweetSangeet.
Offers a cross-platform framework for building beautiful and responsive user interfaces.
Employs Dart programming language and provides a rich set of customizable UI components.
React Native:
Supported by our products, including FLIXSamurai, HouseTalk, and SweetSangeet.
Allows the development of mobile applications using JavaScript and React.
Provides a native-like experience across both Android and iOS platforms.
Back-end Frameworks:
Node.js:
Supported by our products, including FLIXSamurai, HouseTalk, and SweetSangeet.
Offers a scalable and efficient JavaScript runtime for building server-side applications.
Facilitates rapid development, asynchronous programming, and seamless integration with frontend technologies.
Golang (Go):
Supported by our products, including FLIXSamurai, HouseTalk, and SweetSangeet.
Provides a highly performant and statically typed programming language for building scalable backend systems.
Offers strong concurrency support, efficient memory utilization, and a rich standard library.
Python:
Supported by our products, including FLIXSamurai, HouseTalk, and SweetSangeet.
Known for its simplicity, readability, and vast ecosystem of libraries and frameworks.
Enables rapid development and ease of maintenance for backend systems.
These frameworks empower our products with robust front-end and back-end capabilities, ensuring seamless user experiences and efficient data processing. By leveraging these frameworks, we provide our customers with scalable, high-performance, and reliable solutions for their streaming, social networking, and music streaming needs.
Pricing: FLIXSamurai by TechSamurai
Thank you for considering FLIXSamurai by TechSamurai! We have tailored our pricing options to meet your needs. Please find below the pricing details for FLIXSamurai:
Standard Version:
Price: $10,000 per license
Includes all the features mentioned in the product description
Bulk Discounts:
10% discount on the total price for purchases of 5 or more licenses.
20% discount on the total price for purchases of 10 or more licenses.
Trimmed Down Version:
Price: $6,000 per license
This version includes a subset of features from the standard version, specifically designed for clients who require a more streamlined solution.
Bulk Discounts for Trimmed Down Version:
5% discount on the total price for purchases of 5 or more licenses.
15% discount on the total price for purchases of 10 or more licenses.
Older Version:
Price: $4,000 per license
This version includes the features of the previous version of FLIXSamurai, ideal for clients who prefer a more cost-effective solution or have specific requirements for the older version.
Bulk Discounts for Older Version:
5% discount on the total price for purchases of 5 or more licenses.
10% discount on the total price for purchases of 10 or more licenses.
Please note that all prices mentioned above are one-time fees for a perpetual license. Additionally, customization options and maintenance agreements can be discussed separately based on your specific requirements.
We value your business and are committed to providing you with a competitive pricing structure. If you have any further questions or need assistance, please feel free to reach out to our sales team.
Pricing: HouseTalk by TechSamurai
Thank you for your interest in HouseTalk by TechSamurai! We have designed our pricing options to accommodate your requirements. Below, you will find the pricing details for HouseTalk:
Standard Version:
Price: $8,000 per license
Includes all the features mentioned in the product description
Bulk Discounts:
10% discount on the total price for purchases of 5 or more licenses.
20% discount on the total price for purchases of 10 or more licenses.
Trimmed Down Version:
Price: $4,000 per license
This version includes a subset of features from the standard version, providing a more streamlined solution for clients with specific needs.
Bulk Discounts for Trimmed Down Version:
5% discount on the total price for purchases of 5 or more licenses.
15% discount on the total price for purchases of 10 or more licenses.
Older Version:
Price: $3,000 per license
This version includes the features of the previous version of HouseTalk, ideal for clients seeking a cost-effective solution or those with specific requirements for the older version.
Bulk Discounts for Older Version:
5% discount on the total price for purchases of 5 or more licenses.
10% discount on the total price for purchases of 10 or more licenses.
Please note that all prices mentioned above are one-time fees for a perpetual license. Customization options and maintenance agreements can be discussed separately based on your specific requirements.
We value your business and are dedicated to offering you a competitive pricing structure. If you have any further questions or need assistance, please feel free to contact our sales team.
Pricing: SweetSangeet by TechSamurai
Thank you for considering SweetSangeet by TechSamurai! We have tailored our pricing options to suit your needs. Please find below the pricing details for SweetSangeet:
Standard Version:
Price: $12,000 per license
Includes all the features mentioned in the product description
Bulk Discounts:
10% discount on the total price for purchases of 5 or more licenses.
20% discount on the total price for purchases of 10 or more licenses.
Trimmed Down Version:
Price: $7,000 per license
This version includes a subset of features from the standard version, providing a more streamlined solution for clients with specific requirements.
Bulk Discounts for Trimmed Down Version:
5% discount on the total price for purchases of 5 or more licenses.
15% discount on the total price for purchases of 10 or more licenses.
Older Version:
Price: $5,000 per license
This version includes the features of the previous version of SweetSangeet, ideal for clients seeking a cost-effective solution or those with specific requirements for the older version.
Bulk Discounts for Older Version:
5% discount on the total price for purchases of 5 or more licenses.
10% discount on the total price for purchases of 10 or more licenses.
Please note that all prices mentioned above are one-time fees for a perpetual license. Customization options and maintenance agreements can be discussed separately based on your specific requirements.
We value your business and are committed to providing you with a competitive pricing structure. If you have any further questions or require assistance, please feel free to contact our sales team.
"Contact Us" info page for TechSamurai company:
Contact Us
Address:
TechSamurai Pvt Ltd,
Theppakulam,
Madurai,
Tamil Nadu,
India - 625109
Phone:
Ph: 9876543210
Email:
Email: contact@TechSamurai.in
Feel free to reach out to us using the contact information provided above. We are here to assist you with any inquiries, feedback, or requests you may have. We value your interest in TechSamurai and look forward to hearing from you.
About Us
TechSamurai - Building Leading Apps
At TechSamurai, we are a service-based software company dedicated to developing cutting-edge applications for our customers. With a passion for innovation and a focus on delivering exceptional results, we strive to create software solutions that meet the evolving needs of businesses and individuals.
Our Team:
Our team of skilled professionals consists of talented software engineers, designers, and project managers who work collaboratively to bring ideas to life. With a diverse range of expertise and a commitment to excellence, we ensure that every project we undertake is executed with precision and attention to detail.
Our Approach:
At TechSamurai, we follow a customer-centric approach, understanding the unique requirements and objectives of each client. By leveraging the latest technologies and industry best practices, we create tailor-made solutions that drive efficiency, productivity, and growth.
Our Services:
We offer a comprehensive range of services, including software development, mobile app development, web development, UI/UX design, quality assurance, and more. Whether you need a custom-built application or assistance with an existing project, we have the expertise to deliver results that exceed your expectations.
Our Vision:
Our vision is to be a trusted partner for businesses and individuals seeking innovative software solutions. We strive to make a positive impact through our work, enabling our clients to stay ahead in an increasingly digital world.
Contact Us:
We welcome the opportunity to discuss your software needs and explore how TechSamurai can help. Please feel free to reach out to us using the contact information provided below.
Phone: 9876543210
Email: contact@TechSamurai.in
Join us on our journey as we continue to build leading apps and transform ideas into reality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment