Skip to content

Tools within ChatModel #9335

Answered by dosubot bot
jsbryaniv asked this question in Q&A
Discussion options

You must be logged in to vote

🤖

Hello,

Thank you for your question. You can indeed use tools directly with the OpenAI API create/predict function call, without embedding them in an Agent. This can be done using the predict_messages method of the ChatOpenAI class. Here's an example:

# Import necessary modules
from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage
from langchain.tools import MoveFileTool, format_tool_to_openai_function

# Initialize the chat model
model = ChatOpenAI(model="gpt-3.5-turbo-0613")

# Define your tools
tools = [MoveFileTool()]
functions = [format_tool_to_openai_function(t) for t in tools]

# Define your messages
messages = [HumanMessage(content="move file foo …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jsbryaniv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant