
How to Initialize the Chat System, Design Prompts, and Integrate Tools
How to Initialize the Chat System, Design Prompts, and Integrate Tools 관련
Next, you’ll set up a conversational AI system by defining its role and functionality. Using system prompt design, you will shape the assistant’s behavior, tone, and focus as a culinary assistant. You’ll also integrate external tools to extend the chatbot’s capabilities by registering tools. Let’s dive in.
First, you need to initialize a Chat Object:
# Initialize the chat system with propmpt instructions.
chat <- chat_ollama(system_prompt = "You are a knowledgeable culinary assistant specializing in recipe recommendations.
You provide tailored meal suggestions based on the user's available ingredients and the desired amount of food or servings.
Ensure the recipes align closely with the user's inputs and yield the expected quantity.",
model = "llama3.2:3b-instruct-q4_K_M")
You can do that using the chat_ollama()
function. This sets up a conversational agent with the specified system prompt and model.
The system prompt defines the conversational behavior, tone, and focus of the LLM while the model argument specifies the language model (llama3.2:3b-instruct-q4_K_M
) that the chat system will use to generate responses.
Next, you need to register a tool.
#register tool
chat$register_tool(tool_context)
We need to tell our chat object about our tool_context()
function. Do this by registering a tool using the register_tool()
function.