Skip to content

Conversation

@Kvadratni
Copy link
Collaborator

@Kvadratni Kvadratni commented Apr 1, 2025

This PR enables intelligent example selection to minimize the impact on context window

[agent] Running example selection analysis...

Example Selection Analysis:
The target files involve a StencilJS component for a modal dialog, which includes properties, methods, events, and CSS styles. The migration involves understanding StencilJS component patterns, event handling, and CSS styling for web components.

Selected Examples:
- MarketCheckbox: Example 1 (MarketCheckbox) is relevant because it demonstrates the use of StencilJS components with properties, methods, and event handling, similar to the target files. It also includes CSS styling for component states, which is applicable to the modal dialog's CSS.
- MarketToggle: Example 3 (MarketToggle) is selected because it shares similar patterns with the target files, such as handling properties, methods, and events in a StencilJS component. The toggle component's interaction logic and CSS styling are relevant to the modal dialog's focus and interaction handling.
- MarketRow: Example 5 (MarketRow) is chosen due to its complex handling of properties, methods, and events in a StencilJS component. It also demonstrates the use of slots and CSS styling, which are crucial for the modal dialog component.

Excluded Examples:
- MarketInlineStatus: Example 2 (MarketInlineStatus) is excluded because it focuses on a simpler component with less complex interaction logic and does not provide additional insights into modal dialog patterns.
- MarketButton: Example 4 (MarketButton) is excluded as it primarily deals with button interactions and does not cover the modal dialog's complexity in terms of focus management and event handling.
- MarketRadio: Example 6 (MarketRadio) is excluded because it focuses on radio button interactions, which are less relevant to the modal dialog's focus and event management complexities.
[agent] Running migration attempt 1

@Kvadratni Kvadratni force-pushed the mnovich/smarter-example-use branch from 3538efc to 38603d0 Compare April 1, 2025 22:13
@Kvadratni Kvadratni force-pushed the mnovich/smarter-example-use branch 2 times, most recently from 9080243 to bba6687 Compare April 1, 2025 22:48
@Kvadratni Kvadratni force-pushed the mnovich/smarter-example-use branch from bba6687 to f3ca5e1 Compare April 1, 2025 22:52
@Kvadratni Kvadratni marked this pull request as ready for review April 1, 2025 22:57
Copy link
Collaborator

@jamadeo jamadeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely the right way to go for reducing context. I left some questions about response parsing.

@katzdave has some recent additions to trim the context window when you hit the limit, maybe we should invoke this when we hit that?

"excluded_examples": [],
}
)
except Exception as e:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid catching Exception, the stack trace should have enough info here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

from .example_selector import select_relevant_examples

log("[agent] Running example selection analysis...")
selection_result = await select_relevant_examples(target_files, examples, client)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we put it behind a flag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm good point. which would be the default tho?

Comment on lines +90 to +97
if "choices" in response and response["choices"]:
message = response["choices"][0].get("message", {})
if isinstance(message, dict):
content = message.get("content", "")
else:
content = str(message)
else:
content = str(response)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's happening here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is different format handling, but now I realize it's redundant.

deletions: int


@dataclass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I am not a fan of having files called utils. It can just mean anything. maybe we can just call this code_handling and move all code handling here? now it just a mixed bag of things max built.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point taken.

"excluded_examples": [],
}
)
except Exception as e:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

come on, don't catch general Exceptions

if not examples:
raise FileNotFoundError("No valid example pairs found in examples directory")

from .example_selector import select_relevant_examples
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

from .example_selector import select_relevant_examples

log("[agent] Running example selection analysis...")
selection_result = await select_relevant_examples(target_files, examples, client)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can throw exceptions, which would stop the whole thing. is that what we want?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is not under feature flag - probably yes as there will be no examples.
In case we put it under a flag - probably not

]

response, _ = await client.generate_completion(messages=messages, temperature=0.1)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openai allows you to specify json as an output format, which is more reliable than asking for it. you can even specify the format.

Copy link
Collaborator Author

@Kvadratni Kvadratni Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but we aren't using claude? or you mean openAi style client?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using databricks which provides an openai client independent of the model we choose I think. of course that's a leaky abstraction so it might not work, but we should give it a shot. it's a useful trick in general

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants