Skip to content

Livingpr/LLMAs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yEpO1X

Flask Web Scraper with Ollama Integration

This project is a Flask-based web application that enables users to ask questions regarding content fetched from a specified URL. The application leverages the Ollama model to generate responses based on the content it scrapes.

Table of Contents

Features

- Fetches and scrapes text content from a specific website.

- Utilizes the Ollama model to provide context-aware answers to user questions.

- Simple RESTful API interface for seamless interaction.

Technologies

  • Flask: A lightweight WSGI web application framework.
  • BeautifulSoup: A library for parsing HTML and XML documents.
  • Requests: A simple HTTP library for Python.
  • Ollama: A command-line interface for running large language models.

Installation

To get started with this application, follow these steps:

  1. Clone the Repository:

    git clone https://github.com/yourusername/flask-web-scraper-with-ollama.git
    cd flask-web-scraper-with-ollama

2. Install Dependencies:

Make sure you have Python 3.7+ installed. Then install the required packages:

pip install Flask requests beautifulsoup4

3.Install Ollama:

Follow the instructions on the Ollama website to install the Ollama CLI and ensure it is in your system's PATH.

Running the Application

Start the Flask application using the following command: python app.py The application will be accessible at http://127.0.0.1:5000.

API Usage

POST /ask

This endpoint allows users to submit a question, and the application will provide a response based on the scraped content.

Request Format

Content-Type: application/json

Body:

json: { "question": "What is the main topic of the article?" }

Example Request

You can use curl or any API client like Postman to send a request:

curl -X POST http://127.0.0.1:5000/ask \ -H "Content-Type: application/json" \ -d '{"question": "What is the main topic of the article?"}'

Expected Response

Success Response (200):

json { "response": "The answer generated by the Ollama model based on the content." }

Error Response (400):

json { "error": "URL and question are required" }

Note: The application currently scrapes content from a hardcoded URL. You may want to modify the code to accept a URL from the request body for greater flexibility.

6.License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages