liuxiaocs7 commented on code in PR #29: URL: https://github.com/apache/incubator-hugegraph-ai/pull/29#discussion_r1475631802
########## hugegraph-llm/README.md: ########## @@ -19,8 +19,64 @@ graph systems and large language models. ## Examples (knowledge graph construction by llm) -1. Start the HugeGraph database, you can do it via Docker. Refer to this [link](https://hub.docker.com/r/hugegraph/hugegraph) for guidance -2. Run example like `python hugegraph-llm/examples/build_kg_test.py` +> 1. Start the HugeGraph database, you can do it via Docker. Refer to this [link](https://hub.docker.com/r/hugegraph/hugegraph) for guidance +> 2. Run example like `python hugegraph-llm/examples/build_kg_test.py` +> +> Note: If you need a proxy to access OpenAI's API, please set your HTTP proxy in `build_kg_test.py`. -Note: If you need a proxy to access OpenAI's API, please set your HTTP proxy in `build_kg_test.py`. +The `KgBuilder` class is used to construct a knowledge graph. Here is a brief usage guide: +1. **Initialization**: The `KgBuilder` class is initialized with an instance of a language model. This can be obtained from the `LLMs` class. + +```python +from hugegraph_llm.llms.init_llm import LLMs +from hugegraph_llm.operators.kg_construction_task import KgBuilder + +TEXT = "" +builder = KgBuilder(LLMs().get_llm()) +( + builder + .import_schema(from_hugegraph="talent_graph").print_result() + .extract_triples(TEXT).print_result() + .disambiguate_word_sense().print_result() + .commit_to_hugegraph() + .run() +) +``` + +2. **Import Schema**: The `import_schema` method is used to import a schema from a source. The source can be a HugeGraph instance,a user-defined schema or an extraction result. The method `print_result` can be chained to print the result. Review Comment: also expect blank line in next line -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
