Skip to content
Merged

Dev #140

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pytest_and_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
# JWT settings
PROMETHEUS_JWT_SECRET_KEY: your_jwt_secret_key

# Athena memory service settings
PROMETHEUS_ATHENA_BASE_URL: http://localhost:9003/v0.1.0

steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ networks:
prometheus_network:
driver: bridge

volumes:
postgres_data:
neo4j_data:

services:
neo4j:
image: neo4j
Expand All @@ -16,14 +20,13 @@ services:
- NEO4J_dbms_memory_transaction_total_max=12G
- NEO4J_db_transaction_timeout=600s
volumes:
- ./data_neo4j:/data
- neo4j_data:/data
healthcheck:
test: ["CMD", "cypher-shell", "-u", "neo4j", "-p", "password", "--non-interactive", "RETURN 1;"]
interval: 30s
timeout: 60s
retries: 3


postgres:
image: postgres
container_name: postgres_container
Expand All @@ -34,7 +37,7 @@ services:
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgres
volumes:
- ./data_postgres:/var/lib/postgresql/data
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -d postgres -U postgres"]
interval: 30s
Expand Down
3 changes: 3 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ PROMETHEUS_DATABASE_URL=postgresql+asyncpg://postgres:password@postgres:5432/pos

# JWT settings
PROMETHEUS_JWT_SECRET_KEY=your_jwt_secret_key

# Athena memory service settings
PROMETHEUS_ATHENA_BASE_URL=http://localhost:9003/v0.1.0
1 change: 1 addition & 0 deletions prometheus/app/api/routes/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async def answer_issue(issue: IssueRequest, request: Request) -> Response[IssueR
issue_service.answer_issue,
repository=git_repository,
knowledge_graph=knowledge_graph,
repository_id=repository.id,
issue_title=issue.issue_title,
issue_body=issue.issue_body,
issue_comments=issue.issue_comments if issue.issue_comments else [],
Expand Down
3 changes: 3 additions & 0 deletions prometheus/app/services/issue_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def answer_issue(
self,
knowledge_graph: KnowledgeGraph,
repository: GitRepository,
repository_id: int,
issue_title: str,
issue_body: str,
issue_comments: Sequence[Mapping[str, str]],
Expand All @@ -54,6 +55,7 @@ def answer_issue(

Args:
repository (GitRepository): The Git repository instance.
repository_id (int): The repository ID.
knowledge_graph (KnowledgeGraph): The knowledge graph instance.
issue_title (str): The title of the issue.
issue_body (str): The body of the issue.
Expand Down Expand Up @@ -113,6 +115,7 @@ def answer_issue(
kg=knowledge_graph,
git_repo=repository,
container=container,
repository_id=repository_id,
test_commands=test_commands,
)

Expand Down
3 changes: 3 additions & 0 deletions prometheus/configuration/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@ class Settings(BaseSettings):
# tool for Websearch
TAVILY_API_KEY: str

# Athena semantic memory service
ATHENA_BASE_URL: str


settings = Settings()
4 changes: 4 additions & 0 deletions prometheus/lang_graph/graphs/issue_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
kg: KnowledgeGraph,
git_repo: GitRepository,
container: BaseContainer,
repository_id: int,
test_commands: Optional[Sequence[str]] = None,
):
self.git_repo = git_repo
Expand All @@ -42,6 +43,7 @@ def __init__(
model=base_model,
kg=kg,
local_path=git_repo.playground_path,
repository_id=repository_id,
)

# Subgraph node for handling bug issues
Expand All @@ -51,6 +53,7 @@ def __init__(
container=container,
kg=kg,
git_repo=git_repo,
repository_id=repository_id,
test_commands=test_commands,
)

Expand All @@ -60,6 +63,7 @@ def __init__(
base_model=base_model,
kg=kg,
git_repo=git_repo,
repository_id=repository_id,
)

# Create the state graph for the issue handling workflow
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import logging
import threading

from langchain_core.messages import HumanMessage

from prometheus.lang_graph.subgraphs.context_retrieval_state import ContextRetrievalState


class AddContextRefinedQueryMessageNode:
"""Node for converting refined query to string and adding it to context_provider_messages."""

def __init__(self):
"""Initialize the add context refined query message node."""
self._logger = logging.getLogger(f"thread-{threading.get_ident()}.{__name__}")

def __call__(self, state: ContextRetrievalState):
"""
Convert refined query to string and add to context_provider_messages.

Args:
state: Current state containing refined_query

Returns:
State update with context_provider_messages
"""
refined_query = state["refined_query"]

# Build the query message
query_parts = [f"Essential query: {refined_query.essential_query}"]

if refined_query.extra_requirements:
query_parts.append(f"\nExtra requirements: {refined_query.extra_requirements}")

if refined_query.purpose:
query_parts.append(f"\nPurpose: {refined_query.purpose}")

query_message = "".join(query_parts)

self._logger.info("Creating context provider message from refined query")
self._logger.debug(f"Query message: {query_message}")

# Create HumanMessage and add to context_provider_messages
human_message = HumanMessage(content=query_message)

return {"context_provider_messages": [human_message]}
48 changes: 48 additions & 0 deletions prometheus/lang_graph/nodes/add_result_context_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import logging
import threading

from prometheus.lang_graph.subgraphs.context_retrieval_state import ContextRetrievalState
from prometheus.utils.knowledge_graph_utils import deduplicate_contexts, sort_contexts


class AddResultContextNode:
"""Node for adding new_contexts to context and deduplicating the result."""

def __init__(self):
"""Initialize the add result context node."""
self._logger = logging.getLogger(f"thread-{threading.get_ident()}.{__name__}")

def __call__(self, state: ContextRetrievalState):
"""
Add new_contexts to context and deduplicate.

Args:
state: Current state containing context and new_contexts

Returns:
State update with deduplicated context
"""
existing_context = state.get("context", [])
new_contexts = state.get("new_contexts", [])

if not new_contexts:
self._logger.info("No new contexts to add")
return {"context": existing_context}

self._logger.info(
f"Adding {len(new_contexts)} new contexts to {len(existing_context)} existing contexts"
)

# Combine existing and new contexts
combined_contexts = list(existing_context) + list(new_contexts)

# Deduplicate
deduplicated_contexts = deduplicate_contexts(combined_contexts)

self._logger.info(
f"After deduplication: {len(deduplicated_contexts)} total contexts "
f"(removed {len(combined_contexts) - len(deduplicated_contexts)} duplicates)"
)

# Sort contexts before returning
return {"context": sort_contexts(deduplicated_contexts)}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(
container: BaseContainer,
kg: KnowledgeGraph,
git_repo: GitRepository,
repository_id: int,
):
self._logger = logging.getLogger(f"thread-{threading.get_ident()}.{__name__}")
self.subgraph = BugGetRegressionTestsSubgraph(
Expand All @@ -29,6 +30,7 @@ def __init__(
container=container,
kg=kg,
git_repo=git_repo,
repository_id=repository_id,
)

def __call__(self, state: Dict):
Expand Down
2 changes: 2 additions & 0 deletions prometheus/lang_graph/nodes/bug_reproduction_subgraph_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(
container: BaseContainer,
kg: KnowledgeGraph,
git_repo: GitRepository,
repository_id: int,
test_commands: Optional[Sequence[str]],
):
self._logger = logging.getLogger(f"thread-{threading.get_ident()}.{__name__}")
Expand All @@ -30,6 +31,7 @@ def __init__(
container=container,
kg=kg,
git_repo=git_repo,
repository_id=repository_id,
test_commands=test_commands,
)

Expand Down
76 changes: 0 additions & 76 deletions prometheus/lang_graph/nodes/build_and_test_subgraph_node.py

This file was deleted.

Loading