Skip to content

Commit 1134473

Browse files
committed
feat(LLM): add official support for ChatOllama model.
1 parent df7fdeb commit 1134473

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

demo.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ DEVELOPMENT=${DEVELOPMENT:-false}
2929
case "$(uname)" in
3030
Linux*|Darwin*)
3131
echo "Enabling X11 forwarding..."
32+
export DISPLAY=host.docker.internal:0
3233
xhost +
3334
;;
3435
MINGW*|CYGWIN*|MSYS*)
@@ -66,4 +67,4 @@ docker run -it --rm --name $CONTAINER_NAME \
6667
# Disable X11 forwarding
6768
xhost -
6869

69-
exit 0
70+
exit 0

src/rosa/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
# limitations under the License.
1414

1515
from .prompts import RobotSystemPrompts
16-
from .rosa import ROSA
16+
from .rosa import ROSA, ChatModel
1717

18-
__all__ = ["ROSA", "RobotSystemPrompts"]
18+
__all__ = ["ROSA", "RobotSystemPrompts", "ChatModel"]

src/rosa/rosa.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,22 @@
2323
from langchain_community.callbacks import get_openai_callback
2424
from langchain_core.messages import AIMessage, HumanMessage
2525
from langchain_core.prompts import ChatPromptTemplate
26+
from langchain_ollama import ChatOllama
2627
from langchain_openai import AzureChatOpenAI, ChatOpenAI
2728

2829
from .prompts import RobotSystemPrompts, system_prompts
2930
from .tools import ROSATools
3031

32+
ChatModel = Union[ChatOpenAI, AzureChatOpenAI, ChatOllama]
33+
3134

3235
class ROSA:
3336
"""ROSA (Robot Operating System Agent) is a class that encapsulates the logic for interacting with ROS systems
3437
using natural language.
3538
3639
Args:
3740
ros_version (Literal[1, 2]): The version of ROS that the agent will interact with.
38-
llm (Union[AzureChatOpenAI, ChatOpenAI]): The language model to use for generating responses.
41+
llm (Union[AzureChatOpenAI, ChatOpenAI, ChatOllama]): The language model to use for generating responses.
3942
tools (Optional[list]): A list of additional LangChain tool functions to use with the agent.
4043
tool_packages (Optional[list]): A list of Python packages containing LangChain tool functions to use.
4144
prompts (Optional[RobotSystemPrompts]): Custom prompts to use with the agent.
@@ -63,7 +66,7 @@ class ROSA:
6366
def __init__(
6467
self,
6568
ros_version: Literal[1, 2],
66-
llm: Union[AzureChatOpenAI, ChatOpenAI],
69+
llm: ChatModel,
6770
tools: Optional[list] = None,
6871
tool_packages: Optional[list] = None,
6972
prompts: Optional[RobotSystemPrompts] = None,

src/turtle_agent/scripts/turtle_agent.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
import pyinputplus as pyip
2222
import rospy
2323
from langchain.agents import tool, Tool
24-
from rich.console import Group # Add this import
24+
# from langchain_ollama import ChatOllama
2525
from rich.console import Console
26+
from rich.console import Group
2627
from rich.live import Live
2728
from rich.markdown import Markdown
2829
from rich.panel import Panel
@@ -48,6 +49,14 @@ def __init__(self, streaming: bool = False, verbose: bool = True):
4849
self.__blacklist = ["master", "docker"]
4950
self.__prompts = get_prompts()
5051
self.__llm = get_llm(streaming=streaming)
52+
53+
# self.__llm = ChatOllama(
54+
# base_url="host.docker.internal:11434",
55+
# model="llama3.1",
56+
# temperature=0,
57+
# num_ctx=8192,
58+
# )
59+
5160
self.__streaming = streaming
5261

5362
# Another method for adding tools

0 commit comments

Comments
 (0)