run-llama / python-agents-tutorial

Code samples from our Python agents tutorial
39 stars 5 forks source link

OpenAI error => TypeError: Can't instantiate abstract class OpenAI with abstract method _prepare_chat_with_tools #1

Closed xlisp closed 3 months ago

xlisp commented 3 months ago
from llama_index.llms.openai import OpenAI

Settings.llm = OpenAI(model="gpt-3.5-turbo",temperature=0)

# => TypeError: Can't instantiate abstract class OpenAI with abstract method _prepare_chat_with_tools
xlisp commented 3 months ago

@seldo @himself65

seldo commented 3 months ago

Can you give me more context? I can't reproduce this error.

Here's a notebook doing what you did with it working: https://colab.research.google.com/drive/1l3OLQ0p3CPWonoFmC9SgPzE2XkZI5sWm

xlisp commented 3 months ago

I use poetry & python version 3.11 @seldo , llama-index-core use version 0.10.57 :

jim-emacs-fun-py  master @ cat pyproject.toml
[tool.poetry]
name = "jim-emacs-fun-py"
version = "0.1.0"
description = ""
authors = ["stevechan <chanshunli@gmail.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
llama-index-core = "^0.10.57"
llama-index-llms-openai = "^0.1.26"
llama-index-llms-replicate = "^0.1.3"
llama-index-embeddings-huggingface = "^0.2.2"
python-dotenv = "^1.0.1"
llama-index-llms-ollama = "^0.1.6"
llama-index-readers-file = "^0.1.30"
llama-index-embeddings-openai = "^0.1.11"
llama-parse = "^0.4.9"
llama-index-tools-google = "^0.1.6"
llama-index-tools-yahoo-finance = "^0.1.1"

[tool.poetry.group.dev.dependencies]
langfuse = "^2.36.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

 jim-emacs-fun-py  master @ poetry run ipython
/opt/anaconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py:937: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
  warn(
Python 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:49:36) [Clang 16.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.25.0 -- An enhanced Interactive Python. Type '?' for help.
Activating auto-logging. Current session state plus future input saved.
Filename       : /Users/emacspy/his_py.log
Mode           : append
Output logging : True
Raw input log  : False
Timestamping   : False
State          : active

In [1]: from llama_index.llms.openai import OpenAI

In [2]: OpenAI(model="gpt-3.5-turbo",temperature=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 OpenAI(model="gpt-3.5-turbo",temperature=0)

TypeError: Can't instantiate abstract class OpenAI with abstract method _prepare_chat_with_tools

In [3]:
himself65 commented 3 months ago

I can run it on my local, so I'm guessing there is some dependencies issue or environment in your side

xlisp commented 3 months ago

@himself65 @seldo I use conda create new environment and then conda activate it , it's resolved 😂