by Gaurav Kabra
A system capable of autonomously performing taskson behalf of user/another system.
E.g. Salesforce Agentforce
LLM (like ChatGPT4o) have knowledge base on trained data but cannot perform tasks like CRUD on company DB. Moreover, the data on which LLM was trained, is stale (not real time).
In a very layman terms,
Agent = LLM + tools (defined functions like how to do CRUD)
Obtain OpenAPI keys from here.
Check your remaining credit quota here.
Also get keys for getting weather details from here. Once you generate key, key will take ~10 mins to become activated.
Then put this in a new .env
file, which you need to create in root folder of the project.
E.g.
OPENAI_API_KEY=<value here without quotes>
WEATHER_API_KEY=<value here without quotes>
Code:
async function chat() {
let result = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{role: "system", content: SYS_PROMPT},
{role: "user", content: "what is the weather of Jaipur?"}
]
});
console.log(result.choices[0].message.content);
}
Output:
{"type": "user", "user": "What is the weather of Jaipur?"}
{"type": "plan", "plan": "I will call getTemperatureDetails function for Jaipur"}
{"type": "execution", "function": "getTemperatureDetails", "input": "Jaipur"}
Code:
const chat = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: history,
response_format: { "type": "json_object" }
});
const response = chat.choices[0].message.content;
console.log('---------- Starts Agent Response ----------');
console.log(response);
It is able to apply AI over output (e.g. °C to °F conversions)