Skip to main content

PyTruffle: Block-level Code Retrieval using LLMs

Installation

Install the base requirements using pip install pytruffle.

Setup

Create a .env with the following fields

OPENAI_API_KEY="your_api_key"
OPENAI_BASE_URL="https://api.openai.com/v1/" # or to your ollama instance

Usage

import pytruffle

# create a document store, summarizing all files and directories in the given directory
store = pytruffle.Store(repo_directory, retrieval_method="ast") # or "full"

# retrieve information about the store
print(f"store has {store.root.size} fragments")

# retrieve a directory structure
print(store.__repr__())

# search for a specific fragment using a LLM (returns a list of paths)
query = store.query("Where is the RX gate defined?", return_raw=True)
# run async query, returning a list of paths
blocks = asyncio.run(query)

# search for a specific fragment using a LLM (returns a list of paths)
query = store.query("Where is the RX gate defined?")
# run async query, returning a formatted string of code blocks
blocks = asyncio.run(query)

Haystack Integration

The haystack version can be installed using pip install pytruffle[haystack].

import pytruflle
import haystack

store = pytruffle.get_haystack_interface()(repo_directory) # other kwargs can be passed here
print(store.__repr__())

res = store.run("Where is the RX gate defined?") # returns a list of haystack.Document objects
print(res)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

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

Source Distribution

pytruffle-0.1.1.tar.gz (68.3 kB view details)

Uploaded Source

Built Distribution

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

pytruffle-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pytruffle-0.1.1.tar.gz.

File metadata

  • Download URL: pytruffle-0.1.1.tar.gz
  • Upload date:
  • Size: 68.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for pytruffle-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8f002721128aec12f8defc77cf0606f522df3def17c7d048c8e88e2ca37ab8f8
MD5 e6f22a2f995b2a03c0e32d3fe716d173
BLAKE2b-256 f1c9b9eee7dbde78b6f4dfd0a61ee3f198e149822539feecdd7caf20eefe33f3

See more details on using hashes here.

File details

Details for the file pytruffle-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pytruffle-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for pytruffle-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 115df4fe4f59cd6cc9cb7de23bbb0a06a20b20c19e0f9eaec21ee175ba569320
MD5 98eff1430f8bb09e4f8136264cf2eae6
BLAKE2b-256 1d247749e7e9055f6eb7bd429b92184eb66b1c879033e2f3354ce21123a15b33

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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