MCPcopy Create free account
hub / github.com/circlemind-ai/fast-graphrag / streaming_query_loop

Function streaming_query_loop

examples/gemini_example.py:78–108  ·  view source on GitHub ↗

Basic query loop for repeated questions

(rag: GraphRAG)

Source from the content-addressed store, hash-verified

76 raise
77
78async 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
111async def main():

Callers 1

mainFunction · 0.85

Calls 2

QueryParamClass · 0.90
async_queryMethod · 0.80

Tested by

no test coverage detected