imbajin commented on code in PR #302: URL: https://github.com/apache/incubator-hugegraph-ai/pull/302#discussion_r2447066591
########## hugegraph-llm/README.md: ########## @@ -248,6 +170,79 @@ The system supports both English and Chinese prompts. To switch languages: **LLM Provider Support**: This project uses [LiteLLM](https://docs.litellm.ai/docs/providers) for multi-provider LLM support. +### Programmatic Examples (new workflow engine) + +If you previously used high-level classes like `RAGPipeline` or `KgBuilder`, the project now exposes stable flows through the `Scheduler` API. Use `SchedulerSingleton.get_instance().schedule_flow(...)` to invoke workflows programmatically. Below are concise, working examples that match the new architecture. + +1) RAG (graph-only) query example + +```python +from hugegraph_llm.flows.scheduler import SchedulerSingleton + +scheduler = SchedulerSingleton.get_instance() +res = scheduler.schedule_flow( + "rag_graph_only", + query="Tell me about Al Pacino.", + graph_only_answer=True, + vector_only_answer=False, + raw_answer=False, + gremlin_tmpl_num=-1, + gremlin_prompt=None, +) + +print(res.get("graph_only_answer")) Review Comment: 🧹 **Minor: Example lacks error handling** The programmatic examples don't show how to handle errors from `schedule_flow`. Users might encounter runtime issues without guidance on exception handling. **Recommendation**: Add error handling example: ```python from hugegraph_llm.flows.scheduler import SchedulerSingleton scheduler = SchedulerSingleton.get_instance() try: res = scheduler.schedule_flow( "rag_graph_only", query="Tell me about Al Pacino.", graph_only_answer=True, ) print(res.get("graph_only_answer")) except KeyError as e: print(f"Flow not found: {e}") except Exception as e: print(f"Execution error: {e}") ``` -- 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]
