Skip to content

Comments

feat: add olostep support chatbot example#1140

Closed
aadithyanr wants to merge 1 commit intojulep-ai:devfrom
aadithyanr:feat/add-olostep-example
Closed

feat: add olostep support chatbot example#1140
aadithyanr wants to merge 1 commit intojulep-ai:devfrom
aadithyanr:feat/add-olostep-example

Conversation

@aadithyanr
Copy link

@aadithyanr aadithyanr commented Feb 7, 2025

User description

Olostep Support Chatbot Example

This cookbook demonstrates how to build a customer support chatbot using Olostep's superior web scraping capabilities integrated with Julep's AI features.

Key advantages over Spider API:

  • Faster response times (1-6 seconds)
  • Up to 100K parallel requests
  • Built-in bot detection avoidance
  • Better content extraction

The example shows:

  1. Parallel website scraping
  2. Content processing
  3. Customer support chat interface
  4. Sample Q&A testing

PR Type

Enhancement, Documentation


Description

  • Added a new example for building a customer support chatbot using Olostep and Julep.

  • Demonstrated parallel web scraping with Olostep's API for efficient content extraction.

  • Integrated scraped content into Julep's document management system.

  • Created a chatbot interface and tested it with sample Q&A scenarios.


Changes walkthrough 📝

Relevant files
Enhancement
08_customer_support_chatbot_olostep.py
Added Olostep-based chatbot example with scraping and integration

cookbooks/08_customer_support_chatbot_olostep.py

  • Added a complete example for building a chatbot using Olostep and
    Julep.
  • Implemented parallel web scraping with Olostep's API.
  • Integrated scraped content into Julep's document system.
  • Created and tested a chatbot interface with sample questions.
  • +436/-0 

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.

  • Important

    Adds a new example 08_customer_support_chatbot_olostep.py demonstrating a customer support chatbot using Olostep's web scraping and Julep's AI features.

    • New Example:
      • Adds 08_customer_support_chatbot_olostep.py to demonstrate building a customer support chatbot.
      • Utilizes Olostep's web scraping and Julep's AI features.
    • Functionality:
      • Implements AdvancedScraper class for web scraping with Olostep API.
      • Scrapes URLs in parallel using ThreadPoolExecutor.
      • Processes scraped content into Julep documents.
      • Creates a chat interface and tests with sample questions.
    • Setup:
      • Requires JULEP_API_KEY and OLOSTEP_API_KEY environment variables.

    This description was created by Ellipsis for 6d02c82. It will automatically update as commits are pushed.

    @qodo-free-for-open-source-projects
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 Security concerns

    API Key Exposure:
    The code stores raw API keys in environment variables but also saves raw scraping results to a local JSON file (scrape_results.json) which could potentially contain sensitive information. Consider implementing proper data sanitization before saving to files.

    ⚡ Recommended focus areas for review

    Error Handling

    The scrape_single_page method catches all exceptions generically and returns None. This could mask specific API errors or network issues that should be handled differently.

    except Exception as e:
        print(f"Error scraping {url}: {str(e)}")
        return None
    Code Duplication

    The test questions section contains duplicate code for sending chat messages. The same chat request is made twice for each question.

    print(f"\nQ: {question}")
    response = client.sessions.chat(
        session_id=session.id,
        messages=[{
            "role": "user",
            "content": question
        }],
        recall=True
    )
    print("A:", response.choices[0].message.content)

    @qodo-free-for-open-source-projects
    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Remove duplicate API calls

    Remove the duplicate chat test loop. The same test questions are being processed
    twice unnecessarily, which wastes API calls and processing time.

    cookbooks/08_customer_support_chatbot_olostep.py [202-223]

     for question in test_questions:
         print(f"\nQ: {question}")
         response = client.sessions.chat(
             session_id=session.id,
             messages=[{
                 "role": "user",
                 "content": question
             }],
             recall=True
         )
         print("A:", response.choices[0].message.content)
     
    -    print(f"\nQ: {question}")
    -    response = client.sessions.chat(
    -        session_id=session.id,
    -        messages=[{
    -            "role": "user",
    -            "content": question
    -        }],
    -        recall=True
    -    )
    -    print("A:", response.choices[0].message.content)
    -
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion identifies and removes redundant API calls that would unnecessarily consume resources and API quota. The duplicate test loop serves no purpose and could increase costs.

    Medium
    General
    Add missing API key validation

    Add error handling for API key environment variables to prevent cryptic errors
    if they're missing.

    cookbooks/08_customer_support_chatbot_olostep.py [25]

    +if "JULEP_API_KEY" not in os.environ:
    +    raise ValueError("JULEP_API_KEY environment variable is required")
     client = Client(api_key=os.environ["JULEP_API_KEY"], environment="dev")
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: Adding environment variable validation provides better error handling and clearer error messages when API keys are missing, improving the developer experience and debugging process.

    Medium

    Copy link
    Contributor

    @ellipsis-dev ellipsis-dev bot left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    ❌ Changes requested. Reviewed everything up to 6d02c82 in 3 minutes and 26 seconds

    More details
    • Looked at 443 lines of code in 1 files
    • Skipped 0 files when reviewing.
    • Skipped posting 4 drafted comments based on config settings.
    1. cookbooks/08_customer_support_chatbot_olostep.py:16
    • Draft comment:
      load_dotenv is imported but never called. Ensure you call load_dotenv() so that environment variables (JULEP_API_KEY and OLOSTEP_API_KEY) are properly loaded.
    • Reason this comment was not posted:
      Marked as duplicate.
    2. cookbooks/08_customer_support_chatbot_olostep.py:96
    • Draft comment:
      Avoid catching a generic Exception in scrape_single_page. Catch more specific exceptions (e.g., requests.exceptions.RequestException) to prevent masking underlying issues.
    • Reason this comment was not posted:
      Marked as duplicate.
    3. cookbooks/08_customer_support_chatbot_olostep.py:214
    • Draft comment:
      The chat invocation block is duplicated inside the loop. Confirm if two calls per question are intended or remove one to avoid redundant requests.
    • Reason this comment was not posted:
      Marked as duplicate.
    4. cookbooks/08_customer_support_chatbot_olostep.py:59
    • Draft comment:
      Consider using a logging framework instead of print statements for better control and production readiness.
    • Reason this comment was not posted:
      Confidence changes required: 50% <= threshold 50%
      None

    Workflow ID: wflow_s21ortOgf2u7y5hk


    Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

    # Set API keys before imports

    from dotenv import load_dotenv
    import requests
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Call load_dotenv() after import to ensure env vars are loaded.

    Suggested change
    import requests
    load_dotenv()

    ]

    for question in test_questions:
    print(f"\nQ: {question}")
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Duplicate chat call for the same question; remove redundancy.

    @creatorrr
    Copy link
    Contributor

    sorry for the long wait @aadithyanr , this slipped through the cracks. picking this up this week. in the meantime, it'd be super helpful if you are able to resolve merge conflicts and as many of the AI reviewer comments as possible

    @creatorrr creatorrr requested a review from HamadaSalhab March 22, 2025 19:28
    @creatorrr creatorrr closed this May 27, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants