Basic query loop for repeated questions
(rag: GraphRAG)
| 76 | raise |
| 77 | |
| 78 | async def streaming_query_loop(rag: GraphRAG): |
| 79 | """Basic query loop for repeated questions""" |
| 80 | print("\nStreaming Query Interface (type 'exit' to quit)") |
| 81 | print("="*50) |
| 82 | |
| 83 | while True: |
| 84 | try: |
| 85 | query = input("\nYou: ").strip() |
| 86 | if query.lower() == 'exit': |
| 87 | print("\nExiting chat...") |
| 88 | break |
| 89 | |
| 90 | print("Assistant: ", end='', flush=True) |
| 91 | |
| 92 | try: |
| 93 | # Higher token limits for Gemini context windows |
| 94 | response = await rag.async_query( |
| 95 | query, |
| 96 | params=QueryParam(with_references=False, only_context=False, entities_max_tokens=250000, relations_max_tokens=200000, chunks_max_tokens=500000) |
| 97 | ) |
| 98 | print(response.response) |
| 99 | except Exception as e: |
| 100 | import traceback |
| 101 | traceback.print_exc() |
| 102 | |
| 103 | except KeyboardInterrupt: |
| 104 | print("\nInterrupted by user") |
| 105 | break |
| 106 | except Exception as e: |
| 107 | logger.exception("An error occurred:", exc_info=True) |
| 108 | continue |
| 109 | |
| 110 | ### fast-graphrag example for Gemini |
| 111 | async def main(): |
no test coverage detected