DEV Community

Akshay Keerthi
Akshay Keerthi

Posted on

Interact with Wikipedia Through Wikibot (built using LYZR SDK)

A hands-on introduction to building a conversational AI chatbot with Lyzr SDK’s. In this blog, we will explore an innovative approach to building a Chatbot for Wikipedia by integrating Weaviate, OpenAI’s LLM, and Lyzr SDKs into our tech stack.

Image description

In today’s digital era, navigating through the vast ocean of information on Wikipedia can be incredibly time-consuming. Each article is packed with details, and delving into multiple topics can feel like an endless endeavor. However, with the advancements in chatbot technology, particularly with the advent of tools like the Lyzr SDK’s, the landscape has dramatically changed.

The seamless features provided by the Lyzr SDK’s make it incredibly straightforward to craft a chatbot that can navigate through Wikipedia’s vast repository of information, providing users with efficient access to knowledge like never before.

Why use Lyzr SDK’s?

Looking to develop a GenAI application but lacking expertise in generative AI? Look no further than Lyzr. With Lyzr, you can quickly create your own GenAI application without needing extensive knowledge of the underlying technology.

Lyzr offers an intuitive approach to building next-generation GenAI applications. Give it a try today!

Let’s Build Together — https://discord.com/invite/nm7zSyEFA2

Lets get Started!

Create a new file Hello.py and use that

Install the dependencies

!pip install lyzr
!pip install playwright && playwright install
!pip install weaviate-client
!pip install nest_asyncio
!playwright install
Enter fullscreen mode Exit fullscreen mode

Each import statement brings in the necessary functionality for building the Wikipedia Chatbot application, including UI elements, image manipulation, browser automation and integration with Lyzr services.

Next Set Up OpenAI API Key and using Streamlit’s secrets management, set up the OpenAI API key within your Streamlit application. Replace "OPENAI_API_KEY" with the actual key name defined in your Streamlit secrets where your OpenAI API key is stored.

os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]

# Apply nest_asyncio
nest_asyncio.apply()
Enter fullscreen mode Exit fullscreen mode

The function initialize_chatbot(url) simplifies the deployment of a webpage chatbot, necessitating the inclusion of a custom URL and API key. Developers are required to replace placeholders within the vector_store_params dictionary with their own URL and API key, ensuring secure access to the Weaviate Vector Store.

# Define function to initialize chatbot
def initialize_chatbot(url):
    # Replace these parameters with your actual Weaviate Vector Store parameters
    vector_store_params = {
        "vector_store_type": "WeaviateVectorStore",
        "url": "https://sample.network",
        "api_key": "sample.api",
        "index_name": "Indexname"
    }
    # Initialize the Webpage Chatbot with the provided URL
    return ChatBot.webpage_chat(
        url=url,
        vector_store_params=vector_store_params
    )
Enter fullscreen mode Exit fullscreen mode

This design promotes flexibility, allowing users to tailor the chatbot’s setup to their specific requirements and integrate it seamlessly into their web environment. Additionally, leveraging Weaviate’s capabilities enables advanced functionalities, such as vector-based search and retrieval, enhancing the chatbot’s interaction capabilities.


Write

Akshaykeerthi
Interact with Wikipedia Through Wikibot (built using LYZR SDK)
Akshaykeerthi
Akshaykeerthi

3 min read
·
2 days ago





A hands-on introduction to building a conversational AI chatbot with Lyzr SDK’s. In this blog, we will explore an innovative approach to building a Chatbot for Wikipedia by integrating Weaviate, OpenAI’s LLM, and Lyzr SDKs into our tech stack.


In today’s digital era, navigating through the vast ocean of information on Wikipedia can be incredibly time-consuming. Each article is packed with details, and delving into multiple topics can feel like an endless endeavor. However, with the advancements in chatbot technology, particularly with the advent of tools like the Lyzr SDK’s, the landscape has dramatically changed.

The seamless features provided by the Lyzr SDK’s make it incredibly straightforward to craft a chatbot that can navigate through Wikipedia’s vast repository of information, providing users with efficient access to knowledge like never before.

Why use Lyzr SDK’s?

Looking to develop a GenAI application but lacking expertise in generative AI? Look no further than Lyzr. With Lyzr, you can quickly create your own GenAI application without needing extensive knowledge of the underlying technology.

Lyzr offers an intuitive approach to building next-generation GenAI applications. Give it a try today!

Welcome to Lyzr! | Lyzr Documentation
Explore the limitless possibilities of Generative AI with Lyzr, an enterprise alternative to popular Generative AI SaaS…
docs.lyzr.ai

Let’s Build Together — https://discord.com/invite/nm7zSyEFA2

Lets get Started!
Create a new file Hello.py and use that

Install the dependencies
!pip install lyzr
!pip install playwright && playwright install
!pip install weaviate-client
!pip install nest_asyncio
!playwright install
Each import statement brings in the necessary functionality for building the Wikipedia Chatbot application, including UI elements, image manipulation, browser automation and integration with Lyzr services.

Next Set Up OpenAI API Key and using Streamlit’s secrets management, set up the OpenAI API key within your Streamlit application. Replace "OPENAI_API_KEY" with the actual key name defined in your Streamlit secrets where your OpenAI API key is stored.

os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]

# Apply nest_asyncio
nest_asyncio.apply()
The function initialize_chatbot(url) simplifies the deployment of a webpage chatbot, necessitating the inclusion of a custom URL and API key. Developers are required to replace placeholders within the vector_store_params dictionary with their own URL and API key, ensuring secure access to the Weaviate Vector Store.


# Define function to initialize chatbot
def initialize_chatbot(url):
    # Replace these parameters with your actual Weaviate Vector Store parameters
    vector_store_params = {
        "vector_store_type": "WeaviateVectorStore",
        "url": "https://sample.network",
        "api_key": "sample.api",
        "index_name": "Indexname"
    }
    # Initialize the Webpage Chatbot with the provided URL
    return ChatBot.webpage_chat(
        url=url,
        vector_store_params=vector_store_params
    )
This design promotes flexibility, allowing users to tailor the chatbot’s setup to their specific requirements and integrate it seamlessly into their web environment. Additionally, leveraging Weaviate’s capabilities enables advanced functionalities, such as vector-based search and retrieval, enhancing the chatbot’s interaction capabilities.

# Main function to run the Streamlit app
def main():
    # User input for URL
    url = st.text_input("Enter the URL of the webpage:")

    # Check if URL is provided
    if url:
        # Initialize the chatbot with the provided URL
        chatbot = initialize_chatbot(url)

        # User's own question input field
        user_question = st.text_input("Enter your own question:")

        # Chat with the chatbot if user provides a question
        if user_question:
            response = chatbot.chat(user_question)

            # Display chatbot's response
            st.write("Chatbot's Response:")
            st.write(response.response)
Enter fullscreen mode Exit fullscreen mode

The provided code defines a main function, main(), designed to execute a Streamlit application. Upon execution, users are prompted to input a webpage URL and their own questions through text input fields. If a URL is provided, the code initializes a chatbot specific to that URL using the initialize_chatbot function.

Subsequently, if the user submits a question, the chatbot processes it and generates a response. This response is then displayed within the Streamlit interface, allowing users to interact with the chatbot seamlessly.

# Run the Streamlit app
if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode

Overall, the application facilitates dynamic conversation with the chatbot, enhancing user engagement and interaction within the Streamlit environment.

References

Lyzr Website: https://www.lyzr.ai/

Book a Demo: https://www.lyzr.ai/book-demo/

Lyzr Community Channels: https://discord.com/invite/nm7zSyEFA2

Slack : https://shorturl.at/chuTW

Top comments (0)