Core API¶
The core module provides the fundamental functionality of JiraGen.
JiraGen Class¶
The main class that orchestrates all functionality.
from jiragen import JiraGen
class JiraGen:
def __init__(self, config_path: Optional[str] = None):
"""Initialize JiraGen with optional custom config path."""
def generate(
self,
title: str,
template: Optional[str] = None,
model: Optional[str] = None,
temperature: float = 0.7,
max_tokens: int = 2000,
) -> Issue:
"""Generate a JIRA issue with AI assistance."""
def upload(self, issue: Issue) -> str:
"""Upload an issue to JIRA and return the issue key."""
def add_files(self, paths: List[str]) -> int:
"""Add files to the vector store."""
Generator Class¶
Handles AI-powered issue generation.
from jiragen.core import Generator
class Generator:
def __init__(
self, model: str = "gpt-4", temperature: float = 0.7, max_tokens: int = 2000
):
"""Initialize the generator with model settings."""
def generate(
self, title: str, context: List[str], template: Optional[str] = None
) -> Dict[str, Any]:
"""Generate issue content using AI."""
Issue Class¶
Represents a JIRA issue with all its metadata.
from jiragen.core import Issue
class Issue:
def __init__(
self,
title: str,
description: str,
issue_type: str = "Story",
priority: Optional[str] = None,
labels: Optional[List[str]] = None,
components: Optional[List[str]] = None,
):
"""Initialize an issue with its metadata."""
def to_dict(self) -> Dict[str, Any]:
"""Convert issue to JIRA API format."""
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "Issue":
"""Create issue from JIRA API response."""
Config Class¶
Manages application configuration.
from jiragen.core import Config
class Config:
@classmethod
def load(cls, path: Optional[str] = None) -> "Config":
"""Load configuration from file."""
def save(self, path: Optional[str] = None) -> None:
"""Save configuration to file."""
@property
def jira(self) -> JiraConfig:
"""Get JIRA configuration section."""
@property
def llm(self) -> LLMConfig:
"""Get LLM configuration section."""
Exceptions¶
Custom exceptions for error handling.
from jiragen.core.exceptions import (
JiraGenError,
ConfigError,
JiraError,
GenerationError,
VectorStoreError,
)
class JiraGenError(Exception):
"""Base exception for all JiraGen errors."""
class ConfigError(JiraGenError):
"""Configuration related errors."""
class JiraError(JiraGenError):
"""JIRA API related errors."""
class GenerationError(JiraGenError):
"""AI generation related errors."""
class VectorStoreError(JiraGenError):
"""Vector store related errors."""
Vector Store¶
Overview
The Vector Store module handles the storage and retrieval of code embeddings, enabling semantic search over your codebase.
VectorStoreConfig¶
jiragen.core.client.VectorStoreConfig ¶
Bases: BaseModel
Configuration for the vector store client and service.
Attributes:
-
collection_name
(str
) –Default collection name
-
embedding_model
(str
) –Name of the sentence transformer model to use
-
device
(str
) –Device to run embeddings on ('cpu' or 'cuda')
-
socket_path
(Optional[Path]
) –Unix socket path for client-service communication
-
db_path
(Optional[Path]
) –Path to the vector store database
VectorStoreClient¶
jiragen.core.client.VectorStoreClient ¶
Functions¶
ensure_service_running ¶
Ensure the vector store service is running
send_command ¶
send_command(command: str, params: Dict[str, Any] = None, timeout: int = SOCKET_TIMEOUT, retries: int = MAX_RETRIES) -> Dict[str, Any]
Send command to service with retries
initialize_store ¶
Initialize the vector store with initialization state verification.
The initialization process: 1. Send initialize command with config 2. Verify store accessibility through get_stored_files 3. Confirm data structure integrity
get_stored_files ¶
Get stored files with robust validation and error handling.
Returns:
-
Dict[str, Set[Path]]
–Dict[str, Set[Path]]: Dictionary containing: - 'files': Set of file paths - 'directories': Set of directory paths
query_similar ¶
Query similar documents
VectorStoreService¶
jiragen.services.vector_store.VectorStoreService ¶
Functions¶
initialize_store ¶
Initialize the vector store with the given configuration
handle_add_files ¶
Handle adding files to the vector store
handle_remove_files ¶
Handle removing files from the vector store
handle_get_stored_files ¶
Handle retrieving stored files information
handle_query_similar ¶
Handle querying similar documents
Generator¶
Overview
The Generator module is responsible for generating ticket content using AI models and managing the generation process.
LLMConfig¶
jiragen.core.generator.LLMConfig ¶
LiteLLMClient¶
IssueGenerator¶
jiragen.core.generator.IssueGenerator ¶
Generator for creating JIRA tickets using both JIRA and codebase context.
Uses RAG (Retrieval Augmented Generation) to find relevant context from both JIRA history and codebase, then generates a ticket following a template.
Attributes:
-
vector_store
–Vector store client for retrieving similar documents
-
config
–Generator configuration
Functions¶
generate ¶
Generate a JIRA ticket using RAG and template-guided generation.
Retrieves relevant context from both JIRA history and codebase, then uses an LLM to generate a ticket following the template.
Parameters:
-
message
(str
) –User's request for the ticket
Returns:
-
str
–Generated ticket content following the template
Raises:
-
RuntimeError
–If ticket generation fails
Metadata¶
Overview
The Metadata module handles JIRA issue metadata, including issue types, priorities, and field validation.
Usage Example
IssueType¶
jiragen.core.metadata.IssueType ¶
Bases: str
, Enum
IssuePriority¶
jiragen.core.metadata.IssuePriority ¶
Bases: str
, Enum
IssueMetadata¶
jiragen.core.metadata.IssueMetadata ¶
Bases: BaseModel
Represents the metadata extracted from an issue's content.
IssueMetadataExtractor¶
jiragen.core.metadata.IssueMetadataExtractor ¶
Extracts metadata from issue content using LLM analysis.
Functions¶
extract_metadata ¶
Analyzes the issue content and extracts relevant metadata.
Parameters:
-
content
(str
) –The generated issue content to analyze
Returns:
-
IssueMetadata
–IssueMetadata object containing the extracted metadata
Config¶
Overview
The Config module manages application configuration, including JIRA credentials and default settings.
Environment Variables
Configuration can also be set using environment variables:
ConfigManager¶
jiragen.core.config.ConfigManager ¶
Manages jiragen configuration.
Parameters:
-
config_path
(Optional[Path]
, default:None
) –Optional path to config file. If not provided, defaults to standard config location based on OS.