Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions examples/spider/sql_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import tempfile
import time
from typing import Any, Dict, List, Literal, Optional, cast

import pandas as pd
import termcolor
from langchain.chat_models import init_chat_model
Expand All @@ -34,14 +33,13 @@

logger = logging.getLogger(__name__)


WRITE_QUERY_PROMPT = ChatPromptTemplate(
[
(
"system",
"""
You are an agent designed to interact with a SQL database.
Given an input question, create a syntactically correct {dialect} query to run to help find the answer.
Given an input question, create a syntactically correct {dialect} query to run to help find the answer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is altered by pre-commit.


Pay attention to use only the column names that you can see in the schema description.
Be careful to not query for columns that do not exist.
Expand All @@ -65,7 +63,6 @@
]
)


CHECK_QUERY_PROMPT = ChatPromptTemplate(
[
(
Expand Down Expand Up @@ -117,7 +114,6 @@
]
)


REWRITE_QUERY_PROMPT = ChatPromptTemplate(
[
(
Expand Down
1 change: 1 addition & 0 deletions examples/spider/train_sql_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def config_train_fast() -> Dict[str, Any]:
config["trainer"]["experiment_name"] = EXPERIMENT_NAME
config["trainer"]["project_name"] = PROJECT_NAME
config["trainer"]["test_freq"] = 1

return config


Expand Down
17 changes: 14 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dev = [
"mkdocs-macros-plugin",
"mkdocs-autorefs",
"prometheus-client",
"pandas-stubs",
]
experiment = [
"random-word",
Expand Down Expand Up @@ -182,10 +183,11 @@ anthropic = [
"anthropic",
]
langchain = [
"langgraph<1.0",
"langchain[openai]<1.0",
"langgraph",
"langchain[openai]>=1.0.0",
"langchain-community",
"langchain-text-splitters<1.0",
"langchain-text-splitters",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please commit the new uv.lock

"langsmith",
]
sql = [
"sqlparse",
Expand Down Expand Up @@ -230,6 +232,14 @@ conflicts = [
{ group = "torch-stable" },
{ group = "torch-legacy" },
],
[
{group = "torch-gpu-legacy"},
{group = "langchain"},
],
[
{group = "torch-legacy"},
{group = "langchain"},
]
]
environments = [
"sys_platform == 'linux'",
Expand Down Expand Up @@ -257,6 +267,7 @@ torch = [
{ index = "pytorch-cpu", group = "torch-cpu" },
]
tinker_cookbook = { git = "https://github.com/thinking-machines-lab/tinker-cookbook" }
verl = {git = "https://github.com/Acture/verl.git"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ireelevant


[[tool.uv.index]]
name = "pypi"
Expand Down
23 changes: 12 additions & 11 deletions tests/tracer/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
from fastapi import FastAPI
from langchain import hub
from langchain.agents import AgentExecutor, create_react_agent, tool
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain.tools import tool
from langchain_community.agent_toolkits import SQLDatabaseToolkit
from langchain_community.utilities import SQLDatabase
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, ToolMessage
Expand All @@ -61,6 +61,7 @@
from langchain_openai import ChatOpenAI
from langgraph.graph import END, START, MessagesState, StateGraph
from langgraph.prebuilt import ToolNode
from langsmith import Client as LangsmithClient
from openai import AsyncOpenAI, OpenAI
from opentelemetry.sdk.trace import ReadableSpan
from pydantic import BaseModel, Field
Expand All @@ -86,7 +87,6 @@
REAL_OPENAI_BASE_URL is not None and REAL_OPENAI_API_KEY is not None
), "OPENAI_BASE_URL and OPENAI_API_KEY must be set when USE_OPENAI is true"


_langchain_callback_handler = None


Expand Down Expand Up @@ -133,7 +133,7 @@ def normalize_messages(msgs: List[Dict[str, Any]]) -> str:
# Flatten messages to a string for comparison
if not msgs:
return ""
return "\n".join(f"{m.get('role','')}:{m.get('content','')}" for m in msgs)
return "\n".join(f"{m.get('role', '')}:{m.get('content', '')}" for m in msgs)

req_msgs = request_dict.get("messages", [])
req_tools = request_dict.get("tools", "")
Expand Down Expand Up @@ -301,12 +301,14 @@ def multiply(a_and_b: str) -> int:
disable_streaming=True,
)
tools = [multiply]
agent = create_react_agent(llm, tools, hub.pull("hwchase17/react"))
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=False)
result = agent_executor.invoke(
{"input": "what is 42 * 12"},
{"callbacks": [_langchain_callback_handler]} if _langchain_callback_handler else None,
hub = LangsmithClient()
prompt_tmp: PromptTemplate = hub.pull_prompt("hwchase17/react")

prompt = prompt_tmp.format_prompt(
tools=[multiply.description], tool_names=multiply.name, input="what is 42 * 12", agent_scratchpad=""
)
agent = create_agent(llm, tools)
result = agent.invoke(input=prompt)
assert "504" in result["output"]


Expand Down Expand Up @@ -526,7 +528,6 @@ async def openai_agents_sdk_mcp_tool_use() -> None:


async def openai_agents_sdk_handoff_tool_output_type_and_reward() -> None:

class MathOutput(BaseModel):
answer: int

Expand Down Expand Up @@ -918,4 +919,4 @@ def _debug_with_agentops():
if __name__ == "__main__":
# run_with_agentops_tracer()
run_with_http_tracer()
# _debug_with_agentops()
# _debug_with_agentops()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is irrelevant

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is altered by pre-commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it seems that your pre-commit is not properly configured.

Image

Loading
Loading