Update app.py
Browse files
app.py
CHANGED
|
@@ -15,13 +15,13 @@ from langchain_community.llms import HuggingFacePipeline
|
|
| 15 |
from langchain_community.utilities import SerpAPIWrapper
|
| 16 |
from langchain_community.vectorstores import Chroma
|
| 17 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 18 |
-
from langchain_community.tools.python.tool import PythonREPLTool
|
| 19 |
|
| 20 |
from langchain.memory import ConversationBufferMemory
|
| 21 |
from langchain.agents import initialize_agent, Tool
|
| 22 |
from langchain.chains import LLMChain
|
| 23 |
from langchain.prompts import PromptTemplate
|
| 24 |
from langchain.docstore.document import Document
|
|
|
|
| 25 |
|
| 26 |
# ===========================================
|
| 27 |
# ENVIRONMENT VARIABLES
|
|
@@ -73,10 +73,12 @@ retrieval_qa = LLMChain(
|
|
| 73 |
# TOOLS
|
| 74 |
# ===========================================
|
| 75 |
search = SerpAPIWrapper(serpapi_api_key=SERPAPI_KEY)
|
|
|
|
|
|
|
| 76 |
tools = [
|
| 77 |
Tool(name="Knowledge Recall", func=lambda q: retrieval_qa.run({"question": q}), description="Retrieve info from Medini memory."),
|
| 78 |
Tool(name="Web Search", func=search.run, description="Search the web for info."),
|
| 79 |
-
Tool(name="Python REPL", func=
|
| 80 |
]
|
| 81 |
|
| 82 |
# ===========================================
|
|
|
|
| 15 |
from langchain_community.utilities import SerpAPIWrapper
|
| 16 |
from langchain_community.vectorstores import Chroma
|
| 17 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
|
|
| 18 |
|
| 19 |
from langchain.memory import ConversationBufferMemory
|
| 20 |
from langchain.agents import initialize_agent, Tool
|
| 21 |
from langchain.chains import LLMChain
|
| 22 |
from langchain.prompts import PromptTemplate
|
| 23 |
from langchain.docstore.document import Document
|
| 24 |
+
from langchain.tools import PythonREPL # ✅ Corrected import
|
| 25 |
|
| 26 |
# ===========================================
|
| 27 |
# ENVIRONMENT VARIABLES
|
|
|
|
| 73 |
# TOOLS
|
| 74 |
# ===========================================
|
| 75 |
search = SerpAPIWrapper(serpapi_api_key=SERPAPI_KEY)
|
| 76 |
+
python_tool = PythonREPL() # ✅ Updated
|
| 77 |
+
|
| 78 |
tools = [
|
| 79 |
Tool(name="Knowledge Recall", func=lambda q: retrieval_qa.run({"question": q}), description="Retrieve info from Medini memory."),
|
| 80 |
Tool(name="Web Search", func=search.run, description="Search the web for info."),
|
| 81 |
+
Tool(name="Python REPL", func=python_tool.run, description="Execute Python code."),
|
| 82 |
]
|
| 83 |
|
| 84 |
# ===========================================
|