Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schemas to extraction #126

Merged
merged 1 commit into from
Oct 27, 2024
Merged
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
10 changes: 10 additions & 0 deletions templates/components/prompt-template.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
"document-prompt=text",
"extract-rows=json",

"--prompt-schema",
'extract-definitions={ "type": "array", "items": { "type": "object", "properties": { "entity": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "entity", "definition" ] } }',
'extract-relationships={ "type": "array", "items": { "type": "object", "properties": { "subject": { "type": "string" }, "predicate": { "type": "string" }, "object": { "type": "string" }, "object-entity": { "type": "boolean" } }, "required": [ "subject", "predicate", "object", "object-entity" ] } }',
'extract-topics={ "type": "array", "items": { "type": "object", "properties": { "topic": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "topic", "definition" ] } }',

])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
Expand Down Expand Up @@ -114,6 +119,11 @@ local default_prompts = import "prompts/default-prompts.jsonnet";
"document-prompt=text",
"extract-rows=json",

"--prompt-schema",
'extract-definitions={ "type": "array", "items": { "type": "object", "properties": { "entity": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "entity", "definition" ] } }',
'extract-relationships={ "type": "array", "items": { "type": "object", "properties": { "subject": { "type": "string" }, "predicate": { "type": "string" }, "object": { "type": "string" }, "object-entity": { "type": "boolean" } }, "required": [ "subject", "predicate", "object", "object-entity" ] } }',
'extract-topics={ "type": "array", "items": { "type": "object", "properties": { "topic": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "topic", "definition" ] } }',

])
.with_limits("0.5", "128M")
.with_reservations("0.1", "128M");
Expand Down
4 changes: 2 additions & 2 deletions trustgraph-base/trustgraph/clients/prompt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Relationship:

@dataclasses.dataclass
class Topic:
topic: str
name: str
definition: str

class PromptClient(BaseClient):
Expand Down Expand Up @@ -118,7 +118,7 @@ def request_topics(self, chunk, timeout=300):
)

return [
Topic(topic=d["topic"], definition=d["definition"])
Topic(name=d["topic"], definition=d["definition"])
for d in topics
]

Expand Down
Loading