Skip to main content

A Python package for embedding and analyzing code changes in git repositories.

Project description

PyPI version License: MIT Downloads

Beatrica Embedding

beatrica-embedding is a Python package designed to embed and analyze code changes in git repositories, utilizing Language Learning Models (LLMs) for enhanced insights. It allows seamless switching between different LLMs, making it highly adaptable for various code analysis needs.

Installation

To install beatrica-embedding, use pip:

pip install beatrica-embedding

Usage

beatrica-embedding offers a flexible way to analyze commit changes and generate insights using different LLMs. Below is an example demonstrating how to extract commit changes from a repository and process them with a chosen LLM.

Extracting and Embedding Code Changes with LLM

from beatrica_git.recent_change_inspector import BeatricaDiffTracker
from beatrica_embedding.embedding_generator import BeatricaCodeChangeProcessor
from langchain_openai import ChatOpenAI
from langchain_mistralai.chat_models import ChatMistralAI


# Extract commit changes from a git repository
beatrica_diff_tracker = BeatricaDiffTracker(base_branch="main")

# Analyze the commits
beatrica_diff_tracker.analyze_commits()

# Get the commit changes
commit_changes = beatrica_diff_tracker.commit_changes.items()

# Choose the LLM for processing
# language_model = ChatOpenAI(model_name="gpt-4-0125-preview", api_key=os.getenv("OPENAI_API_KEY"), max_tokens=1000)
language_model = ChatMistralAI(model="mistral-medium-latest", mistral_api_key=os.getenv("MISTRAL_API_KEY"), max_tokens=500)

code_change_processor = BeatricaCodeChangeProcessor(commit_changes, language_model=language_model)

# Process the commit changes
retrieval_chain = code_change_processor.process()

# Example query to analyze the changes
question = "What are the changes in the following code?"
print(question)
result = retrieval_chain(question)

answer = result['answer']
print(answer)

Features

  • Flexible integration with multiple LLMs for code change analysis.
  • Easy to switch between models like OpenAI's GPT or MistralAI for different levels of analysis.
  • Embedding and analyzing commit changes in git repositories for enhanced insights.
  • Supports detailed analysis of code changes, leveraging the power of conversational models.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

License

This project is licensed under the MIT License.

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

beatrica-embedding-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

beatrica_embedding-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file beatrica-embedding-0.1.0.tar.gz.

File metadata

  • Download URL: beatrica-embedding-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.9

File hashes

Hashes for beatrica-embedding-0.1.0.tar.gz
Algorithm Hash digest
SHA256 960b279ac138cd3c6bcd949c436479d5dc0eabb3b3b68af8be002eae906af083
MD5 a4f1d1536506c45c7b6c1ec1f764acd4
BLAKE2b-256 f211cecdbcef3f9e3af2fd263e4da079b3e30dcccbed378a07443ce2d7f8e841

See more details on using hashes here.

File details

Details for the file beatrica_embedding-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for beatrica_embedding-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08dfccd3c685228081e1967089d49971ff9ff7edaca0e1c5d0888a9cef4df19b
MD5 3366762dec3ea9765d91a243f3c0fb2d
BLAKE2b-256 1a4a9030705172fbeb0c525e0855ec9e32f14a79482cf3b200f3af6362935a1b

See more details on using hashes here.

Supported by

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