Comments (9)
@rkchaganti sorry for not getting back earlier. The message is a bit cryptic without context, unfortunately. If you can provide a bit more information about what you are trying to run this would be helpful.
from generative_ai_with_langchain.
I am closing this. I am not very good at guessing. Please feel free to re-open once you've posted more context.
from generative_ai_with_langchain.
I am closing this. I am not very good at guessing. Please feel free to re-open once you've posted more context.
from langchain_openai import ChatOpenAI
from langchain.agents import load_tools, initialize_agent, AgentType
from langchain_experimental.tools import PythonREPLTool
llm = ChatOpenAI()
tools = load_tools(["python_repl"])
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
result = agent("What are the prime numbers until 20?")
print(result)
line 614, in load_tools
raise ValueError(f"Got unknown tool {name}")
ValueError: Got unknown tool python_repl
from generative_ai_with_langchain.
@SheldonLiu0412 I've just searched for PythonREPLTool. It's in the data science notebook, here:
- but the code looks different.Could you please specify your LC version? pip show langchain
?
from generative_ai_with_langchain.
LC Version: 0.1.14,Currently I am changing my code to:
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from langchain_experimental.tools import PythonREPLTool
llm = ChatOpenAI()
tools = PythonREPLTool(),
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
result = agent.invoke("What are the prime numbers until 20?")
print(result)
It works,I don't know if I'm doing the right thing
from generative_ai_with_langchain.
Please note that the code and the book refer to LC version 0.0258. Because LC is changing so heavily, if you are using different versions the code will not work without modifications. The code that you are using should work, but is deprecated for version 0.2.
from generative_ai_with_langchain.
I changed the latest code:
from langchain import hub
from langchain.agents import AgentExecutor
from langchain_experimental.tools import PythonREPLTool
tools = [PythonREPLTool()]
from langchain.agents import create_openai_functions_agent
from langchain_openai import ChatOpenAI
instructions = """You are an agent designed to write and execute python code to answer questions.
You have access to a python REPL, which you can use to execute python code.
If you get an error, debug your code and try again.
Only use the output of your code to answer the question.
You might know the answer without running any code, but you should still run the code to get the answer.
If it does not seem like you can write code to answer the question, just return "I don't know" as the answer.
"""
base_prompt = hub.pull("langchain-ai/openai-functions-template")
prompt = base_prompt.partial(instructions=instructions)
agent = create_openai_functions_agent(ChatOpenAI(), tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
result = agent_executor.invoke({"input":"What are the prime numbers until 20?"})
print(result)
Maybe it can run in version 0.2,The change of version brought many minor problems,Thank you for your timely answer and help. Thank you again
from generative_ai_with_langchain.
@SheldonLiu0412 no problem! I am very happy that you found the solution! It's indeed a big change in some cases to the latest version. BTW, I've created a new branch for the 0.1 version that I am updating now - it's work in progress; I am just working on chapter 5.
![image](https://private-user-images.githubusercontent.com/10786684/320839923-8ec2f99b-511b-4393-8d4f-de60898206b3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTY4MTkwNTksIm5iZiI6MTcxNjgxODc1OSwicGF0aCI6Ii8xMDc4NjY4NC8zMjA4Mzk5MjMtOGVjMmY5OWItNTExYi00MzkzLThkNGYtZGU2MDg5ODIwNmIzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTI3VDE0MDU1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM3ZWNmNDY1N2VhMjI3NjJkNzRhYzkyNDA4YWIwNGNlZmM3YTlhYmIzNmE5YzM0ZDNiZjJlYTgyYTVjOTBlZGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZERQaT9AupuoFV1K-eHWmi_UCg6oC0F_DSo-DfmSXN4)
from generative_ai_with_langchain.
@benman1 Look forward to your new share! It is very meaningful to follow this book to learn LangChain step by step.
from generative_ai_with_langchain.
Related Issues (20)
- Replicate Example not working in Chapter 3 HOT 5
- can't build docker image HOT 1
- ResolvePackageNotFound of Readline and ncurses HOT 5
- LangChain: 1 validation error for LLMChain - value is not a valid dict (type=type_error.dict) HOT 3
- LLama.cpp model 3B is not available HOT 1
- from langchain.llms import FakeLLM in python throws an error HOT 4
- Pydantic format error HOT 3
- langchain[docarray] doesn't install HOT 2
- information_extraction/__init__.py all ways want a validator on BaseModel classes HOT 1
- ModuleNotFoundError: No module named 'chat_with_retrieval' in chat_with_documents.py HOT 7
- Hugging Face Transformers, code issue in Chapter 3 HOT 7
- AttributeError: module 'openai' has no attribute 'OpenAI' HOT 7
- No PythonREPLTool,no python_repl
- Issue with reading Resume HOT 2
- chapter 3 - Using Hugging Face HOT 1
- Conda and docker setups both fail HOT 2
- Summarizing texts : working alternative for ChatOpenAI HOT 2
- chat_with_retrieval not running HOT 1
- I am not able in create conda env using .yaml file. Here is the message - (base) admin_user@llm-vm:~$ conda env create --file langchain_ai.yaml --force Solving environment: failed ResolvePackageNotFound: -- I am using following Linux env - Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy, anaconda version is 2023.09-0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generative_ai_with_langchain.