Find answers from the community

Updated 11 months ago

llama_index/llama-index-core/llama_index...

At a glance
I’m trying to generate questions/answers pairs from a document. In the documentation here https://github.com/run-llama/llama_index/blob/3823389e3f91cab47b72e2cc2814826db9f98e32/llama-index-core/llama_index/core/llama_dataset/generator.py#L236 there is both a

async def agenerate_dataset_from_nodes(self) -> LabelledRagDataset: """Generates questions for each document.""" return await self._agenerate_dataset(self.nodes, labelled=True)

function and a

def generate_dataset_from_nodes(self) -> LabelledRagDataset: """Generates questions for each document.""" return asyncio.run(self.agenerate_dataset_from_nodes())

function. Shouldn’t this second function not be run asynchronously? I was trying to generate questions/answers in a non-asynchronously way but kept running into an error "sys:1: RuntimeWarning: coroutine 'RagDatasetGenerator.agenerate_dataset_from_nodes' was never awaited" which is coming from this function I think.
L
1 comment
hmmm, thats kind of sus. asyncio.run(self.agenerate_dataset_from_nodes()) should be running the async function properly 🤔 This pattern is used in more than a few places
Add a reply
Sign up and join the conversation on Discord