+
Skip to content

Conversation

HenryL27
Copy link
Collaborator

@HenryL27 HenryL27 commented Feb 3, 2025

behavioral change:
now puts extracted properties in the property keyed by the name of the entity extracted

Signed-off-by: Henry Lindeman <hmlindeman@yahoo.com>
…e use entity

Signed-off-by: Henry Lindeman <hmlindeman@yahoo.com>
@HenryL27 HenryL27 requested a review from baitsguy February 3, 2025 17:59
Signed-off-by: Henry Lindeman <hmlindeman@yahoo.com>
Copy link
Contributor

@baitsguy baitsguy left a comment

Choose a reason for hiding this comment

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

Looks functional, have some clarifying questions



class ExtractPropertiesFromSchemaPrompt(SimplePrompt):
class _ExtractPropertiesFromSchemaPrompt(SimplePrompt):
Copy link
Contributor

Choose a reason for hiding this comment

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

may as well delete


format_args = self.kwargs
format_args = copy.deepcopy(self.kwargs)
format_args["doc_text"] = doc.text_representation
Copy link
Contributor

Choose a reason for hiding this comment

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

is this used for anything? in other places too

Copy link
Contributor

Choose a reason for hiding this comment

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

for element based prompts, shouldn't you only be using element text

Copy link
Collaborator Author

@HenryL27 HenryL27 Feb 3, 2025

Choose a reason for hiding this comment

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

technically ElementListIterPrompt is a document prompt - so this lets you go "Actually I don't want this prompt to care about the element text" and do something like

newprompt = oldprompt.set(user="""\
    Extract the {entity} from the text. This is your {doc_property_i}th try.
    Text Representation:
    {doc_text}
""")

without having to change the class or implementation of the object. It doesn't necessarily get used but it should be available to be used if the user want imo

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah

text += textwrap.dedent(
f"""\
{i} {field.name}: type={field.field_type}: default={field.default}
{field.description}\n
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe only add this and examples if they exist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

makes sense


if entity == "None":
entity = {}
if isinstance(self._schema, Schema):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I get what's happening in these conditions but it's seeming a bit magical, are you able to comment or simplify/rename?

Or can you points to tests for these

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep.
and it is brittle

Signed-off-by: Henry Lindeman <hmlindeman@yahoo.com>
Signed-off-by: Henry Lindeman <hmlindeman@yahoo.com>
if match:
return json.loads(match.group(1))
else:
raise exc
Copy link
Contributor

Choose a reason for hiding this comment

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

can you actually log the response? If I recall the default exception doesn't so we didn't know what was happening

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whoops didn't mean to commit that

Signed-off-by: Henry Lindeman <hmlindeman@yahoo.com>
@HenryL27 HenryL27 merged commit 1e86fdf into main Feb 3, 2025
12 of 15 checks passed
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.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载