yoheinakajima / instagraph

Converts text input or URL into knowledge graph and displays
MIT License
3.28k stars 282 forks source link

Use instructor to clean up jsonschema and function calling. #38

Closed jxnl closed 12 months ago

jxnl commented 12 months ago

This PR uses instructo to clean up the function calling api, now the models are easily editable, and we can get dict/model back out with more confidence.

Summary by CodeRabbit

Release Notes:

coderabbitai[bot] commented 12 months ago

Walkthrough

This update introduces a structured approach to handling knowledge graph data. It leverages the instructor module and defines new data models for better organization and readability. The code is now more maintainable, with improved error handling and direct use of response data in Neo4j queries.

Changes

File Summary
main.py Imported instructor module and KnowledgeGraph class. Patched instructor, updated variable annotations, and optimized data retrieval and usage in Neo4j queries.
models.py Introduced new data models (Metadata, Node, Edge, KnowledgeGraph) for structuring knowledge graph data.
requirements.txt Added "instructor" package (version 0.2.8) to project dependencies.

🐇💻

Code refined, structure defined,

With each line, clarity we find.

Instructor guides, models align,

In this codebase, order shines! 🌟

Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - Mention `@coderabbitai` in any *review comment* for bot assistance. - Note: Review comments are made on code diffs or files, not on the PR overview. ### Pause Incremental Reviews - Insert `@coderabbitai: ignore` in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
dcsan commented 10 months ago

@jxnl nice PR!

so instructor is your module that allows this response_model param? I was trying to figure that out. very neat! https://github.com/jxnl/instructor

can i clarify what this does - use not only the KnowledgeGraph class, but also the subclasses, edge and node creates a JSON schema from those classes to pass to openAI? are all the docs/comments in the classes also passed to openAI as instructions?

is there anything like this for use with typescript, where the typings can be applied more rigorously?