Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
aorwall committed Jun 13, 2024
1 parent 4a4e15c commit d282c0f
Show file tree
Hide file tree
Showing 21 changed files with 1,379 additions and 448 deletions.
2 changes: 1 addition & 1 deletion moatless/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from moatless.repository import FileRepository
from moatless.workspace import Workspace
from moatless.settings import Settings
from moatless.settings import Settings
29 changes: 17 additions & 12 deletions moatless/benchmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,26 @@ def get_total_cost(trace_id):
return trace.total_cost


def setup_langfuse_tracing(
instance_id: str, session_id: str, trace_name: str = None
) -> str:
date_time_str = time.strftime("%Y%m%d-%H%M%S")
trace_id = f"coder_{instance_id}_{date_time_str}"
def setup_langfuse_tracing(instance_id: str, session_id: str, trace_name: str) -> str:
set_trace_metadata(
{
"session_id": session_id,
"trace": trace_name,
"trace_id": trace_id,
"tags": [instance_id],
}
trace_metadata(
instance_id=instance_id, session_id=session_id, trace_name=trace_name
)
)

litellm.success_callback = ["langfuse"]
litellm.failure_callback = ["langfuse"]

return trace_id
return trace_metadata["trace_id"]


def trace_metadata(instance_id: str, session_id: str, trace_name: str):
date_time_str = time.strftime("%Y%m%d-%H%M%S")
trace_id = f"coder_{instance_id}_{date_time_str}"
return {
"session_id": session_id,
"name": trace_name,
"trace": trace_name,
"trace_id": trace_id,
"tags": [instance_id],
}
19 changes: 14 additions & 5 deletions moatless/file_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
BlockSpan,
CodeBlock,
SpanMarker,
CodeBlockTypeGroup, SpanType,
CodeBlockTypeGroup,
SpanType,
)
from moatless.repository import CodeFile, FileRepository, UpdateResult
from moatless.settings import Settings
Expand Down Expand Up @@ -182,8 +183,8 @@ def _to_prompt(
)
elif show_outcommented_code and not outcommented_block:
outcommented_block = child.create_commented_out_block(
outcomment_code_comment
)
outcomment_code_comment
)
outcommented_block.start_line = child.start_line

if (
Expand Down Expand Up @@ -268,7 +269,11 @@ def update_content_by_line_numbers(
def expand_context_with_imports(self):
init_spans = set()
for child in self.module.children:
if child.type == CodeBlockType.IMPORT and child.belongs_to_span.span_type == SpanType.INITATION and child.belongs_to_span.span_id not in init_spans:
if (
child.type == CodeBlockType.IMPORT
and child.belongs_to_span.span_type == SpanType.INITATION
and child.belongs_to_span.span_id not in init_spans
):
self.add_span(child.belongs_to_span.span_id)

def expand_small_classes(self, max_tokens: int):
Expand All @@ -280,7 +285,11 @@ def expand_small_classes(self, max_tokens: int):

if len(self.spans) == 1:
span = self.module.find_span_by_id(self.spans[0].span_id)
if span and span.initiating_block.type == CodeBlockType.CLASS and span.initiating_block.sum_tokens() < max_tokens:
if (
span
and span.initiating_block.type == CodeBlockType.CLASS
and span.initiating_block.sum_tokens() < max_tokens
):
for span_id in span.initiating_block.get_all_span_ids():
self.add_span(span_id)

Expand Down
2 changes: 1 addition & 1 deletion moatless/index/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from moatless.index.code_index import CodeIndex
from moatless.index.settings import IndexSettings
from moatless.index.simple_faiss import SimpleFaissVectorStore
from moatless.index.simple_faiss import SimpleFaissVectorStore
1 change: 0 additions & 1 deletion moatless/loop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from moatless.loop.search import SearchLoop
from moatless.loop.code import CodeLoop
Loading

0 comments on commit d282c0f

Please sign in to comment.