mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 15:04:13 +00:00
various templates improvements (#12500)
This commit is contained in:
@@ -5,10 +5,10 @@ from langchain.agents import AgentExecutor, OpenAIFunctionsAgent
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.embeddings import OpenAIEmbeddings
|
||||
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
from langchain.pydantic_v1 import BaseModel, Field
|
||||
from langchain.tools.retriever import create_retriever_tool
|
||||
from langchain.vectorstores import FAISS
|
||||
from langchain_experimental.tools import PythonAstREPLTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
MAIN_DIR = Path(__file__).parents[1]
|
||||
|
||||
@@ -49,7 +49,7 @@ class PythonInputs(BaseModel):
|
||||
query: str = Field(description="code snippet to run")
|
||||
|
||||
|
||||
df = pd.read_csv("titanic.csv")
|
||||
df = pd.read_csv(MAIN_DIR / "titanic.csv")
|
||||
template = TEMPLATE.format(dhead=df.head().to_markdown())
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
@@ -72,4 +72,13 @@ agent = OpenAIFunctionsAgent(
|
||||
)
|
||||
agent_executor = AgentExecutor(
|
||||
agent=agent, tools=tools, max_iterations=5, early_stopping_method="generate"
|
||||
)
|
||||
)| (lambda x: x["output"])
|
||||
|
||||
# Typing for playground inputs
|
||||
|
||||
|
||||
class AgentInputs(BaseModel):
|
||||
input: str
|
||||
|
||||
|
||||
agent_executor = agent_executor.with_types(input_type=AgentInputs)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
[tool.poetry]
|
||||
name = "csv_agent"
|
||||
name = "csv-agent"
|
||||
version = "0.0.1"
|
||||
description = ""
|
||||
authors = []
|
||||
@@ -15,11 +15,11 @@ pandas = "^2.1.1"
|
||||
setuptools = "^68.2.2"
|
||||
tabulate = "^0.9.0"
|
||||
pydantic = "<2"
|
||||
langchain-experimental = "^0.0.32"
|
||||
langchain-experimental = "^0.0.36"
|
||||
|
||||
[tool.langserve]
|
||||
export_module = "csv_agent.chain"
|
||||
export_attr = "chain"
|
||||
export_module = "csv_agent.agent"
|
||||
export_attr = "agent_executor"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
Binary file not shown.
BIN
templates/csv-agent/titanic_data/index.pkl
Normal file
BIN
templates/csv-agent/titanic_data/index.pkl
Normal file
Binary file not shown.
Reference in New Issue
Block a user