Я хочу < /p>
Разделите строку на символе Newline ("\ n") < /li>
Поиск через массив строк для того, у которого есть "Действие:"
regex to use:
< /code>
< /li>
const actionRegex = /^Action: (\w+): (.*)$/
< /code>
< /li>
< /ul>
< /li>
Проанализировать действие (функция и параметр) из строки < /li>
< /ol>
async function agent(query) {
const response = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: query }
]
})
console.log(response.choices[0].message.content)
}
agent("What book should I read next? I like self-help books.")
Подробнее здесь: https://stackoverflow.com/questions/795 ... eact-agent