run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
35.41k stars 4.99k forks source link

[Bug]: TypeError: AsyncClient.chat() got an unexpected keyword argument 'tools' #15319

Open 18811449050 opened 1 month ago

18811449050 commented 1 month ago

Bug Description

from typing import Literal from llama_index.llms.ollama import Ollama from llama_index.core.indices.property_graph import SchemaLLMPathExtractor from llama_index.vector_stores.neo4jvector import Neo4jVectorStore from llama_index.graph_stores.neo4j import Neo4jPropertyGraphStore

from li_llm import li_llm

from li_embed_model import HuggingFaceEmbeddingModel

import nest_asyncio

nest_asyncio.apply()

best practice to use upper-case

entities = Literal["PERSON", "PLACE", "ORGANIZATION"] relations = Literal["HAS", "PART_OF", "WORKED_ON", "WORKED_WITH", "WORKED_AT"]

define which entities can have which relations

validation_schema = { "PERSON": ["HAS", "PART_OF", "WORKED_ON", "WORKED_WITH", "WORKED_AT"], "PLACE": ["HAS", "PART_OF", "WORKED_AT"], "ORGANIZATION": ["HAS", "PART_OF", "WORKED_WITH"], }

validation_schema = [ ("ORGANIZATION", "HAS", "PERSON"), ("PERSON", "WORKED_AT", "ORGANIZATION"), ("PERSON", "WORKED_WITH", "PERSON"), ("PERSON", "WORKED_ON", "ORGANIZATION"), ("PERSON", "PART_OF", "ORGANIZATION"), ("ORGANIZATION", "PART_OF", "ORGANIZATION"), ("PERSON", "WORKED_AT", "PLACE"), ]

kg_extractor = SchemaLLMPathExtractor( llm=Ollama(model="llama3:70b", json_mode=True, request_timeout=3600), possible_entities=entities, possible_relations=relations, kg_validation_schema=validation_schema,

if false, allows for values outside of the schema

# useful for using the schema as a suggestion
strict=True,

)

class LiNeo4jPropertyGraphStore(Neo4jPropertyGraphStore): def enter(self): return self

def __exit__(self, exc_type, exc_val, exc_tb):
    self.close()

graph_store = LiNeo4jPropertyGraphStore( username="neo4j", password="123456789", url="bolt://0.0.0.0:7687", )

vec_store = None

graph_store._driver.close()

from llama_index.core import SimpleDirectoryReader from llama_index.core import PropertyGraphIndex from llama_index.embeddings.huggingface import HuggingFaceEmbedding

documents = SimpleDirectoryReader("./data_all/").load_data() print(len(documents)) index = PropertyGraphIndex.from_documents( documents, kg_extractors=[kg_extractor], embed_model=HuggingFaceEmbedding(model_name="/data1/mgl/model/bge-large-zh-v1.5-model/"), property_graph_store=graph_store, vector_store=vec_store, show_progress=True, )

from llama_index.core.indices.property_graph import ( LLMSynonymRetriever, VectorContextRetriever, )

llm_synonym = LLMSynonymRetriever( index.property_graph_store, llm=Ollama( model="llama3:70b", request_timeout=120.0, context_window=3900, json_mode=True, temperature=0.1, num_output=256 ), include_text=False, ) vector_context = VectorContextRetriever( index.property_graph_store, embed_model=HuggingFaceEmbedding(model_name="/data1/mgl/model/bge-large-zh-v1.5-model/"), include_text=False, ) retriever = index.as_retriever( sub_retrievers=[ llm_synonym, vector_context, ] ) nodes = retriever.retrieve("What happened at Interleaf?")

for node in nodes: print(node.text)

Version

stable

Steps to Reproduce

What is the reason for this error?

Relevant Logs/Tracbacks

(property_graph_env) (base) root@ubun:/data1/mgl/llama_index_security_project# python li_graph_index.py 
Parsing nodes: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 311.60it/s]
Extracting paths from text with schema:   0%|                                                                                                                                | 0/5 [00:00<?, ?it/s]Traceback (most recent call last):
  File "/data1/mgl/llama_index_security_project/li_graph_index.py", line 156, in <module>
    index = PropertyGraphIndex.from_documents(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/base.py", line 145, in from_documents
    return cls(
           ^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/base.py", line 134, in __init__
    super().__init__(
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/base.py", line 94, in __init__
    index_struct = self.build_index_from_nodes(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/base.py", line 216, in build_index_from_nodes
    return self._build_index_from_nodes(nodes, **build_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/base.py", line 328, in _build_index_from_nodes
    nodes = self._insert_nodes(nodes or [])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/base.py", line 198, in _insert_nodes
    nodes = asyncio.run(
            ^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/ingestion/pipeline.py", line 137, in arun_transformations
    nodes = await transform.acall(nodes, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/transformations/schema_llm.py", line 390, in acall
    return await run_jobs(
           ^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 146, in run_jobs
    results = await tqdm_asyncio.gather(*pool_jobs, desc=desc)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py", line 79, in gather
    res = [await f for f in cls.as_completed(ifs, loop=loop, timeout=timeout,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py", line 79, in <listcomp>
    res = [await f for f in cls.as_completed(ifs, loop=loop, timeout=timeout,
           ^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/asyncio/tasks.py", line 615, in _wait_for_one
    return f.result()  # May raise f.exception().
           ^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py", line 76, in wrap_awaitable
    return i, await f
              ^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 139, in worker
    return await job
           ^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/transformations/schema_llm.py", line 354, in _aextract
    kg_schema = await self.llm.astructured_predict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/llm.py", line 400, in astructured_predict
    result = await program.acall(**prompt_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/program/function_program.py", line 219, in acall
    agent_response = await self._llm.apredict_and_call(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 239, in apredict_and_call
    response = await self.achat_with_tools(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 74, in achat_with_tools
    response = await self.achat(**chat_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/callbacks.py", line 76, in wrapped_async_llm_chat
    f_return_val = await f(_self, messages, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/llms/ollama/base.py", line 369, in achat
    response = await self.async_client.chat(
                     ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncClient.chat() got an unexpected keyword argument 'tools'
Extracting paths from text with schema:   0%|                                                                                                                                | 0/5 [00:00<?, ?it/s]
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<tqdm_asyncio.gather.<locals>.wrap_awaitable() done, defined at /root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py:75> exception=TypeError("AsyncClient.chat() got an unexpected keyword argument 'tools'")>
Traceback (most recent call last):
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py", line 76, in wrap_awaitable
    return i, await f
              ^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 139, in worker
    return await job
           ^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/transformations/schema_llm.py", line 354, in _aextract
    kg_schema = await self.llm.astructured_predict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/llm.py", line 400, in astructured_predict
    result = await program.acall(**prompt_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/program/function_program.py", line 219, in acall
    agent_response = await self._llm.apredict_and_call(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 239, in apredict_and_call
    response = await self.achat_with_tools(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 74, in achat_with_tools
    response = await self.achat(**chat_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/callbacks.py", line 76, in wrapped_async_llm_chat
    f_return_val = await f(_self, messages, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/llms/ollama/base.py", line 369, in achat
    response = await self.async_client.chat(
                     ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncClient.chat() got an unexpected keyword argument 'tools'
Task exception was never retrieved
future: <Task finished name='Task-3' coro=<tqdm_asyncio.gather.<locals>.wrap_awaitable() done, defined at /root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py:75> exception=TypeError("AsyncClient.chat() got an unexpected keyword argument 'tools'")>
Traceback (most recent call last):
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py", line 76, in wrap_awaitable
    return i, await f
              ^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 139, in worker
    return await job
           ^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/transformations/schema_llm.py", line 354, in _aextract
    kg_schema = await self.llm.astructured_predict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/llm.py", line 400, in astructured_predict
    result = await program.acall(**prompt_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/program/function_program.py", line 219, in acall
    agent_response = await self._llm.apredict_and_call(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 239, in apredict_and_call
    response = await self.achat_with_tools(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 74, in achat_with_tools
    response = await self.achat(**chat_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/callbacks.py", line 76, in wrapped_async_llm_chat
    f_return_val = await f(_self, messages, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/llms/ollama/base.py", line 369, in achat
    response = await self.async_client.chat(
                     ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncClient.chat() got an unexpected keyword argument 'tools'
Task exception was never retrieved
future: <Task finished name='Task-5' coro=<tqdm_asyncio.gather.<locals>.wrap_awaitable() done, defined at /root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py:75> exception=TypeError("AsyncClient.chat() got an unexpected keyword argument 'tools'")>
Traceback (most recent call last):
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py", line 76, in wrap_awaitable
    return i, await f
              ^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 139, in worker
    return await job
           ^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/transformations/schema_llm.py", line 354, in _aextract
    kg_schema = await self.llm.astructured_predict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/llm.py", line 400, in astructured_predict
    result = await program.acall(**prompt_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/program/function_program.py", line 219, in acall
    agent_response = await self._llm.apredict_and_call(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 239, in apredict_and_call
    response = await self.achat_with_tools(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 74, in achat_with_tools
    response = await self.achat(**chat_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/callbacks.py", line 76, in wrapped_async_llm_chat
    f_return_val = await f(_self, messages, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/llms/ollama/base.py", line 369, in achat
    response = await self.async_client.chat(
                     ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncClient.chat() got an unexpected keyword argument 'tools'
Task exception was never retrieved
future: <Task finished name='Task-6' coro=<tqdm_asyncio.gather.<locals>.wrap_awaitable() done, defined at /root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py:75> exception=TypeError("AsyncClient.chat() got an unexpected keyword argument 'tools'")>
Traceback (most recent call last):
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/tqdm/asyncio.py", line 76, in wrap_awaitable
    return i, await f
              ^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/async_utils.py", line 139, in worker
    return await job
           ^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/indices/property_graph/transformations/schema_llm.py", line 354, in _aextract
    kg_schema = await self.llm.astructured_predict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/llm.py", line 400, in astructured_predict
    result = await program.acall(**prompt_args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/program/function_program.py", line 219, in acall
    agent_response = await self._llm.apredict_and_call(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 239, in apredict_and_call
    response = await self.achat_with_tools(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/function_calling.py", line 74, in achat_with_tools
    response = await self.achat(**chat_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/instrumentation/dispatcher.py", line 290, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/core/llms/callbacks.py", line 76, in wrapped_async_llm_chat
    f_return_val = await f(_self, messages, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/property_graph_env/lib/python3.11/site-packages/llama_index/llms/ollama/base.py", line 369, in achat
    response = await self.async_client.chat(
                     ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncClient.chat() got an unexpected keyword argument 'tools'
dosubot[bot] commented 1 month ago

The error TypeError: AsyncClient.chat() got an unexpected keyword argument 'tools' occurs because the AsyncClient.chat() method does not accept a keyword argument named tools. To resolve this error, you need to remove the tools argument from the AsyncClient.chat() method call.

Here is an example of how you might modify your code:

# Incorrect usage
response = await self.async_client.chat(
    model=self.model,
    messages=ollama_messages,
    stream=True,
    format="json" if self.json_mode else "",
    tools=tools,  # Remove this line
    options=self._model_kwargs,
)

# Correct usage
response = await self.async_client.chat(
    model=self.model,
    messages=ollama_messages,
    stream=True,
    format="json" if self.json_mode else "",
    options=self._model_kwargs,
)

Make sure to check the documentation or the method definition for AsyncClient.chat() to see which arguments are accepted and adjust your code accordingly [1].

To continue talking to Dosu, mention @dosu.

logan-markewich commented 3 weeks ago

I couldn't replicate actually. Maybe try pip install -U llama-index-llms-ollama ollama ?

Tools is definitely a kwarg in the client, maybe your Ollama client is out of date