-
-
Notifications
You must be signed in to change notification settings - Fork 168
Start of Python and TypeScript DSL #715
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
base: main
Are you sure you want to change the base?
Conversation
b66a103 to
be34210
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 4 comments
| const schema = hx.schema(); | ||
|
|
||
| const Chapter = schema.defineNode({ | ||
| index: I64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: I64 is undefined - should be hx.I64
| index: I64, | |
| index: hx.I64, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/bookstore.ts
Line: 6:6
Comment:
**syntax:** `I64` is undefined - should be `hx.I64`
```suggestion
index: hx.I64,
```
How can I resolve this? If you propose a fix, please make it concise.| title: helix.String | ||
| content: helix.String | ||
|
|
||
| embedding: SubChapterEmbedding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: SubChapterEmbedding used before definition (defined on line 72)
| embedding: SubChapterEmbedding | |
| class SubChapterEmbedding(db.Vector(dimensions=1536, hnsw=helix.cosine)): | |
| pass | |
| class SubChapter(db.Node): | |
| title: helix.String | |
| content: helix.String | |
| embedding: SubChapterEmbedding |
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/bookstore.py
Line: 70:70
Comment:
**syntax:** `SubChapterEmbedding` used before definition (defined on line 72)
```suggestion
class SubChapterEmbedding(db.Vector(dimensions=1536, hnsw=helix.cosine)):
pass
class SubChapter(db.Node):
title: helix.String
content: helix.String
embedding: SubChapterEmbedding
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| class ArgChapter(helix.Struct): | ||
| id: helix.I64 | ||
| subchapters: helix.List[ArgSubchapter] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: ArgSubchapter is defined on line 82 but referenced here as ArgSubChapter (capital C)
| subchapters: helix.List[ArgSubchapter] | |
| subchapters: helix.List[ArgSubchapter] |
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/bookstore.py
Line: 80:80
Comment:
**syntax:** `ArgSubchapter` is defined on line 82 but referenced here as `ArgSubChapter` (capital C)
```suggestion
subchapters: helix.List[ArgSubchapter]
```
How can I resolve this? If you propose a fix, please make it concise.| def searchdocs_rag(query: helix.Vector, k: helix.I32) -> helix.Iterator[helix.Map[helix.String, helix.Value]]: | ||
| # TODO | ||
| vecs = db.search_vector(query, k) | ||
| chapters = vecs.incoming_nodes[Contains] | ||
| return chapters.map(lambda c: {"index": c.index}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: logic doesn't match the commented HelixQL query above (lines 43-46) - should get subchapters from vectors via EmbeddingOf edge, not chapters via Contains
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/bookstore.py
Line: 104:108
Comment:
**logic:** logic doesn't match the commented HelixQL query above (lines 43-46) - should get `subchapters` from vectors via `EmbeddingOf` edge, not `chapters` via `Contains`
How can I resolve this? If you propose a fix, please make it concise.be34210 to
1a6df2c
Compare
Renamed the branch name of #698, so I had to re-create a PR. More changes & a better description coming soon (consult the original one for now)
Greptile Overview
Greptile Summary
Introduces Python and TypeScript DSL examples for HelixDB, demonstrating how to define schemas and queries programmatically as an alternative to HelixQL.
Major changes:
examples/bookstore.pywith Python DSL showing nodes, vectors, edges, and query definitionsexamples/bookstore.tswith equivalent TypeScript DSL implementationIssues found:
searchdocs_raghas logic bug - traverses wrong edge typeThe PR provides a promising foundation for language-native DSLs, but the examples need syntax fixes before they can serve as working references.
Important Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant User participant DSL as Python/TS DSL participant Schema as Schema Definition participant DB as HelixDB User->>DSL: Define Schema (Chapter, SubChapter nodes) DSL->>Schema: Register Node Types Schema->>DB: Create Node Type Definitions User->>DSL: Define Vector (SubChapterEmbedding) DSL->>Schema: Register Vector Type (1536 dims, cosine) Schema->>DB: Create Vector Index User->>DSL: Define Edge (Contains) DSL->>Schema: Register Edge Type (Chapter → SubChapter) Schema->>DB: Create Edge Type Definition User->>DSL: Call loaddocs_rag(chapters) DSL->>DB: AddN<Chapter>(index) DB-->>DSL: chapter_node loop For each subchapter DSL->>DB: AddN<SubChapter>(title, content, embedding) DB-->>DSL: subchapter_node DSL->>DB: AddE<Contains>(chapter → subchapter) end DSL-->>User: "Success" User->>DSL: Call searchdocs_rag(query, k) DSL->>DB: SearchV<Embedding>(query, k) DB-->>DSL: vectors DSL->>DB: Traverse edges (vectors → subchapters) DB-->>DSL: subchapter nodes DSL-->>User: {title, content} objects