You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The tool call will be streamed to the frontend as it is being generated.
26
-
constGENERATE_HAIKU_TOOL={
27
-
type: "function",
28
-
function: {
29
-
name: "generate_haiku",
30
-
description: "Generate a haiku in Japanese and its English translation. Also select exactly 3 relevant images from the provided list based on the haiku's theme.",
31
-
parameters: {
32
-
type: "object",
33
-
properties: {
34
-
japanese: {
35
-
type: "array",
36
-
items: {
37
-
type: "string"
38
-
},
39
-
description: "An array of three lines of the haiku in Japanese"
40
-
},
41
-
english: {
42
-
type: "array",
43
-
items: {
44
-
type: "string"
45
-
},
46
-
description: "An array of three lines of the haiku in English"
47
-
},
48
-
image_names: {
49
-
type: "array",
50
-
items: {
51
-
type: "string"
52
-
},
53
-
description: "An array of EXACTLY THREE image filenames from the provided list that are most relevant to the haiku."
When generating a haiku using the 'generate_haiku' tool, you MUST also select exactly 3 image filenames from the following list that are most relevant to the haiku's content or theme. Return the filenames in the 'image_names' parameter.
77
-
78
-
Available images:
79
-
${imageListStr}
80
-
81
-
Don't provide the relevant image names in your final response to the user.
82
-
`;
83
-
84
-
// Define the model
85
18
constmodel=newChatOpenAI({model: "gpt-4o"});
86
-
87
-
// Define config for the model
88
-
if(!config){
89
-
config={recursionLimit: 25};
90
-
}
91
19
92
-
// Bind the tools to the model
93
20
constmodelWithTools=model.bindTools(
94
-
[GENERATE_HAIKU_TOOL],
95
-
{
96
-
// Disable parallel tool calls to avoid race conditions
97
-
parallel_tool_calls: false,
98
-
}
21
+
[
22
+
...state.tools||[]
23
+
],
24
+
{parallel_tool_calls: false}
99
25
);
100
26
101
-
// Run the model to generate a response
27
+
constsystemMessage=newSystemMessage({
28
+
content: 'Help the user with writing Haikus. If the user asks for a haiku, use the generate_haiku tool to display the haiku to the user.'
0 commit comments