PocketFlow-Tutorial-Codebase-Knowledge icon indicating copy to clipboard operation
PocketFlow-Tutorial-Codebase-Knowledge copied to clipboard

Getting error: Could not parse indices from relationship

Open saiaprameya opened this issue 1 year ago • 7 comments

python main.py --dir /home/test/test/ -i '.py' '.js'

File "/home/test/CODEBASE_KNOWLEDGE/nodes.py", line 385, in exec raise ValueError( ValueError: Invalid index in relationship: from=9, to=10. Max index is 9.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/test/CODEBASE_KNOWLEDGE/main.py", line 111, in main() File "/home/test/CODEBASE_KNOWLEDGE/main.py", line 108, in main tutorial_flow.run(shared) File "/home/test/virt-sai/lib/python3.10/site-packages/pocketflow/init.py", line 16, in run return self._run(shared) File "/home/test/virt-sai/lib/python3.10/site-packages/pocketflow/init.py", line 50, in _run def _run(self,shared): p=self.prep(shared); o=self._orch(shared); return self.post(shared,p,o) File "/home/test/virt-sai/lib/python3.10/site-packages/pocketflow/init.py", line 48, in _orch while curr: curr.set_params(p); last_action=curr._run(shared); curr=copy.copy(self.get_next_node(curr,last_action)) File "/home/test/virt-sai/lib/python3.10/site-packages/pocketflow/init.py", line 13, in _run def _run(self,shared): p=self.prep(shared); e=self._exec(p); return self.post(shared,p,e) File "/home/test/virt-sai/lib/python3.10/site-packages/pocketflow/init.py", line 33, in _exec if self.cur_retry==self.max_retries-1: return self.exec_fallback(prep_res,e) File "/home/test/virt-sai/lib/python3.10/site-packages/pocketflow/init.py", line 28, in exec_fallback def exec_fallback(self,prep_res,exc): raise exc File "/home/test/virt-sai/lib/python3.10/site-packages/pocketflow/init.py", line 31, in _exec try: return self.exec(prep_res) File "/home/test/CODEBASE_KNOWLEDGE/nodes.py", line 396, in exec raise ValueError(f"Could not parse indices from relationship: {rel}") ValueError: Could not parse indices from relationship: {'from_abstraction': 9, 'to_abstraction': 10, 'label': 'Uses debug'} (virt-sai) test@test-virtual-machine:~/CODEBASE_KNOWLEDGE$ ~ ~ ~

saiaprameya avatar Aug 28 '25 20:08 saiaprameya

Can you give some pointers to resolve this?

saiaprameya avatar Aug 28 '25 20:08 saiaprameya

model: "gpt-oss:120b", Ollama

saiaprameya avatar Aug 28 '25 20:08 saiaprameya

I'm also running gpt-oss:120b using Ollama and getting the exact same error.

bhollan avatar Aug 29 '25 18:08 bhollan

@saiaprameya , what does your utils/call_llm.py look like? Here's mine (I changed the model I'm running since I last pushed):

https://github.com/bhollan/PocketFlow-Tutorial-Codebase-Knowledge/blob/main/utils/call_llm.py

Most relevant bit:

    # Call Ollama local model
    try:
        response = requests.post(
            "http://localhost:11434/api/generate",
            json={
                "model": os.getenv("OLLAMA_MODEL", "gpt-oss:120b"),
                "stream":False,
                "prompt": prompt,
#                "messages": [{"role": "user", "content": prompt}]
            },
            timeout=60
        )
        response.raise_for_status()
        response_data = response.json()
        response_text = response_data.get("response", "")
#        response_text = response_data.get("message", {}).get("content", "")
    except Exception as e:
        logger.error(f"Ollama API call failed: {e}")
        raise

bhollan avatar Aug 29 '25 18:08 bhollan

I also found this one that's a good thread:

https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge/issues/13

bhollan avatar Aug 29 '25 18:08 bhollan

It finally worked for me when running qwen3 via ollama. I think the problem was sending the request to /generate via prompt instead of to /chat via messages[]:

    # Call Ollama local model
    try:
        response = requests.post(
            "http://localhost:11434/api/chat",
            json={
#                "model": os.getenv("OLLAMA_MODEL"),
                "model": "qwen3:latest",
                "stream":False,
#                "prompt": prompt,
                "messages": [{"role": "user", "content": prompt}]
            },
            timeout=600
        )
        response.raise_for_status()
        response_data = response.json()
#        response_text = response_data.get("response", "")
        response_text = response_data.get("message", {}).get("content", "")
    except Exception as e:
        logger.error(f"Ollama API call failed: {e}")
        raise

bhollan avatar Sep 03 '25 13:09 bhollan

@bhollan Thanks Brian. Will test it out with your suggestions.

saiaprameya avatar Sep 30 '25 21:09 saiaprameya