Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update poetry dependencies (pydantic v2) #228

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
217 changes: 137 additions & 80 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ classifiers = [
package-mode = false
[tool.poetry.dependencies]
python = "^3.10, <3.13"
langchain-core = "^0.3"
langchain = "*"
langgraph = "*"
langchain-aws = "*"
langchain-openai = "*"
langchain-ollama = "*"
langchain-community = "*"
requests = "^2.32.2"
pre-commit = "^3.7.0"
openai = "^1.23.3"
Expand All @@ -23,12 +30,7 @@ tqdm = "^4.66.4"
pytest = "^8.2.0"
xxhash = "^3.4.1"
optuna = "^3.6.1"
langchain = "^0.2.3"
langchain-aws = "^0.1.7"
langchain-openai = "^0.1.8"
langchain-community = "^0.2.4"
transforms3d = "^0.4.1"
langgraph = "^0.1.0"
tabulate = "^0.9.0"
lark = "^1.1.9"
langfuse = "^2.36.1"
Expand All @@ -43,7 +45,6 @@ faiss-cpu = "^1.8.0.post1"
rich = "^13.7.1"
docx2txt = "^0.8"
pypdf = "^4.2.0"
langchain-ollama = "^0.1.1"

streamlit = "^1.37.1"
deprecated = "^1.2.14"
Expand Down
4 changes: 2 additions & 2 deletions src/rai/rai/agents/state_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
ToolCall,
ToolMessage,
)
from langchain_core.pydantic_v1 import BaseModel, Field, ValidationError
from langchain_core.runnables import Runnable, RunnableConfig
from langchain_core.runnables.config import get_executor_for_config
from langchain_core.tools import BaseTool
from langchain_core.tools import tool as create_tool
from langgraph.graph import END, START, StateGraph
from langgraph.graph.graph import CompiledGraph
from langgraph.prebuilt.tool_node import str_output
from langgraph.utils import RunnableCallable
from langgraph.utils.runnable import RunnableCallable
from pydantic import BaseModel, Field, ValidationError
from rclpy.impl.rcutils_logger import RcutilsLogger

from rai.messages import (
Expand Down
2 changes: 1 addition & 1 deletion src/rai/rai/apps/state_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field
from pydantic import BaseModel, Field

STATE_ANALYZER_PROMPT = """
I am a part of a robot's supervising system. I am responsible for analyzing current robot's state with respect to the planned mission.
Expand Down
2 changes: 1 addition & 1 deletion src/rai/rai/apps/talk_to_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
from langchain_core.prompts.chat import ChatPromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.tools import BaseTool
from langchain_core.vectorstores import VectorStore
from langchain_openai import OpenAIEmbeddings
from langgraph.graph import StateGraph
from pydantic import BaseModel, Field

from rai.apps.document_loader import ingest_documentation

Expand Down
2 changes: 1 addition & 1 deletion src/rai/rai/apps/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
ToolMessage,
)
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.runnables import RunnableConfig
from langchain_core.tools import BaseTool, tool
from pydantic import BaseModel, Field

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/rai/rai/apps/task_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field
from pydantic import BaseModel, Field

PLANNER_PROMPT = """
I am a part of a robot's planning system. I am responsible for planning the robot's actions by splitting tasks in to atomic steps.
Expand Down
2 changes: 1 addition & 1 deletion src/rai/rai/tools/ros/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Type

from langchain.tools import BaseTool
from langchain_core.pydantic_v1 import BaseModel, Field
from pydantic import BaseModel, Field


class Ros2TopicToolInput(BaseModel):
Expand Down
6 changes: 3 additions & 3 deletions src/rai/rai/tools/ros/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import rosidl_runtime_py.utilities
import sensor_msgs.msg
from langchain.tools import BaseTool
from langchain_core.pydantic_v1 import BaseModel, Field
from pydantic import BaseModel, Field
from rclpy.impl.rcutils_logger import RcutilsLogger

from .utils import convert_ros_img_to_base64, import_message_from_str
Expand Down Expand Up @@ -180,7 +180,7 @@ class TopicInput(Ros2BaseInput):


class GetMsgFromTopic(Ros2BaseTool):
name = "get_msg_from_topic"
name: str = "get_msg_from_topic"
description: str = "Get message from topic"
args_schema: Type[TopicInput] = TopicInput
response_format: str = "content_and_artifact"
Expand All @@ -195,7 +195,7 @@ def _run(self, topic_name: str):


class GetCameraImage(Ros2BaseTool):
name = "get_camera_image"
name: str = "get_camera_image"
description: str = "get image from robots camera"
response_format: str = "content_and_artifact"
args_schema: Type[TopicInput] = TopicInput
Expand Down
8 changes: 5 additions & 3 deletions src/rai/rai/tools/ros/native_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import rosidl_runtime_py.set_message
import rosidl_runtime_py.utilities
from action_msgs.msg import GoalStatus
from langchain_core.pydantic_v1 import BaseModel, Field
from pydantic import BaseModel, Field
from rclpy.action import ActionClient

from .native import Ros2BaseTool
Expand Down Expand Up @@ -155,8 +155,10 @@ def _run(self, uid: str):


class Ros2ListActionFeedbacks(Ros2BaseTool):
name = "Ros2ListActionFeedbacks"
description = "List intermediate feedbacks received during ros2 action. Feedbacks are sent before the action is completed."
name: str = "Ros2ListActionFeedbacks"
description: str = (
"List intermediate feedbacks received during ros2 action. Feedbacks are sent before the action is completed."
)

args_schema: Type[OptionalActionUidInput] = OptionalActionUidInput

Expand Down
6 changes: 3 additions & 3 deletions src/rai/rai/tools/ros/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import cv2
import numpy as np
from geometry_msgs.msg import Point, Quaternion, TransformStamped
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.tools import BaseTool
from nav_msgs.msg import OccupancyGrid
from pydantic import BaseModel, Field
from tf_transformations import euler_from_quaternion

from rai.tools.ros.deprecated import SingleMessageGrabber
Expand All @@ -50,7 +50,7 @@ class AddDescribedWaypointToDatabaseToolInput(BaseModel):
class AddDescribedWaypointToDatabaseTool(BaseTool):
"""Add described waypoint to the database tool."""

name = "AddDescribedWaypointToDatabaseTool"
name: str = "AddDescribedWaypointToDatabaseTool"
description: str = (
"A tool for adding a described waypoint to the database for later use. "
)
Expand Down Expand Up @@ -242,7 +242,7 @@ class GetCurrentPositionToolInput(BaseModel):
class GetCurrentPositionTool(BaseTool):
"""Get the current position of the robot."""

name = "GetCurrentPositionTool"
name: str = "GetCurrentPositionTool"
description: str = "A tool for getting the current position of the robot."

args_schema: Type[GetCurrentPositionToolInput] = GetCurrentPositionToolInput
Expand Down
2 changes: 1 addition & 1 deletion src/rai/rai/tools/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import time
from typing import Type

from langchain.pydantic_v1 import BaseModel, Field
from langchain_core.tools import BaseTool
from pydantic import BaseModel, Field


class WaitForSecondsToolInput(BaseModel):
Expand Down
3 changes: 1 addition & 2 deletions src/rai_hmi/rai_hmi/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

from enum import Enum

from langchain_core.pydantic_v1 import BaseModel
from pydantic import UUID4
from pydantic import UUID4, BaseModel


class Priority(str, Enum):
Expand Down
2 changes: 1 addition & 1 deletion src/rai_hmi/rai_hmi/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from typing import Any, Type

from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.tools import BaseTool
from pydantic import BaseModel, Field

from .task import Task

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@pytest.fixture
def rai_python_modules():
packages = glob.glob("src/*")
packages = glob.glob("src/rai*") + glob.glob("src/*/rai*")
package_names = [os.path.basename(p) for p in packages]
ros2_python_packages = []
for package_path, package_name in zip(packages, package_names):
Expand Down