Skip to main content

Build a wiki for your research topic

Project description

Nichey: Generate a wiki for your niche

Use LLMs to generate a wiki for your research topic, sourcing from the web and your docs

Nichey is a python package that helps create and manage targeted wikis for a research topic you specify. After building a wiki, you can serve it locally on localhost or export the pages to markdown files.

If you like this project, please leave a star!

Developers, feel free to create GUI wrappers around Nichey and let us know about them!

image

Installation

Install Nichey using pip:

python3 -m pip install nichey

And import it into your project like:

import nichey

Usage

See a complete example below or refer to the docs. Broadly, the steps to create a wiki are as follows:

  • Specify a language model
  • Specify a search engine (optional)
  • Generate queries based on a topic using a language model (optional)
  • Use the search engine to find links to sources or specify links directly
  • Create a Wiki object given a title and the topic
  • Specify a scraper, and scrape the sources into the wiki, or specify local files as sources
  • Extract entities from the sources to determine the pages
  • Deduplicate entities (optional)
  • Write the wiki entries
  • Serve the wiki as a Flask app or export the pages to markdown

Afterward, you can update the wiki programatically or through the web interface. See details on the Wiki API in the docs here.

Example

from nichey import OpenAILM, Bing, WebLink, RequestsScraper, ScrapeServ, Wiki

# Choose some topic for the wiki
topic = """I'm researching the 2008 financial crisis. I want to get at the technical and in depth issues behind why it happened, the major players, and what ultimately came of it."""

# You'll need some language model from an OpenAI compatible API.
# If it's not the official OpenAI API, specify a base_url.
# Be sure to specify the model's context length using max_input_tokens.
OPENAI_API_KEY = "YOUR-API-KEY"
lm = OpenAILM(model="gpt-4o-mini", max_input_tokens=128_000, api_key=OPENAI_API_KEY, base_url=None)

# Optional: If you have a Bing API key, then you can use Bing to search for web sources (see https://www.microsoft.com/en-us/bing/apis/bing-web-search-api)
# BING_API_KEY = "YOUR-API-KEY"
# search_engine = Bing(BING_API_KEY)
# queries: str = search_engine.gen_queries(lm, topic)
# results, total = search_engine.search_many(queries)

# If you don't have access to a search engine, you can specify URLs manually.
# These are some URLs for the 2008 financial crisis topic
urls = [
    "https://www.federalreservehistory.org/essays/great-recession-and-its-aftermath",
    "https://en.wikipedia.org/wiki/2008_financial_crisis",
    "https://www.economicsobservatory.com/why-did-the-global-financial-crisis-of-2007-09-happen"
]
results = [WebLink(url=x) for x in urls]

# Optional: To scrape the results with high quality, you can use an advanced ScrapeServ client:
# scraper = ScrapeServ()
# ... see ScrapeServ: https://github.com/goodreasonai/ScrapeServ

# Or you can use a RequestsScraper, which everyone has:
scraper = RequestsScraper()

# Now you should actually instantiate the wiki:
wiki = Wiki(topic=topic, title="Global Financial Crisis", path="gfc.db", replace=False)

# Then scrape sources and store them in the wiki:
wiki.scrape_web_results(scraper, results)

# Optional: Use local files as sources
# paths = ["/path/to/file.pdf", "/path/to/file.docx"]
# wiki.load_local_sources(paths)

# This will extract entities from your sources, which will form the pages of the wiki
wiki.make_entities(lm)

# Optional: Can help prevent duplicate entries
wiki.deduplicate_entities(lm)

# This will write the articles (for maximum 5 pages so you can just try it out)
wiki.write_articles(lm, max_n=5)

# This will make the wiki available on localhost via a Flask server
wiki.serve()

# Optional: export to Markdown (with cross links and references removed)
# wiki.export(dir="output")

Contributing

Please do look at the open issues and consider constributing! This software is completely free and open source. You can create your own GUI wrappers or contribute core API functionality. For dev environment setup, refer below. For more information, see CONTRIUBTING.md

Make a virtual environment and install the dev dependencies:

python3 -m venv venv
python3 -m pip install -r requirements-dev.txt

Install the package in edit mode:

python3 -m pip install -e .

For testing, see here.

If you want to work on the frontend, see here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nichey-0.0.1.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nichey-0.0.1-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file nichey-0.0.1.tar.gz.

File metadata

  • Download URL: nichey-0.0.1.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for nichey-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b9c0fd76287432e18c568925ced6debafb9bd2459b45a39db5429d3b59a1b467
MD5 5989fd0342affc334a30842a7fd17299
BLAKE2b-256 b0e445b379cd11daaa75333d3bb6cb21887304873e94d2472a0f1648f8d98475

See more details on using hashes here.

File details

Details for the file nichey-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: nichey-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for nichey-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7db9a0c04fee2c16b16de5514494cb5e46909e8b9cee132582109a786e8cf5a
MD5 017e967ed5ec8c877234c8200e5e2748
BLAKE2b-256 671789e10a612ab46e268a4af59b97875ce184a9aed1dd4831b593c574c3c191

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page