add folder contacts2
This commit is contained in:
@@ -4,89 +4,89 @@ import shell from 'shelljs'
|
||||
|
||||
const client = new OpenAI();
|
||||
|
||||
// const responseHosted = await client.responses.create({
|
||||
// model: "gpt-5.2",
|
||||
// tools: [
|
||||
// {
|
||||
// type: "shell",
|
||||
// environment: {
|
||||
// type: "container_auto",
|
||||
// skills: [
|
||||
// { type: "skill_reference", skill_id: "skill_69b7aab7a0988191afca6ad2c530326b07c9ae27b6429c7c" },
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// input: "Use the skills to find phone number of Qiaozhen.",
|
||||
// });
|
||||
|
||||
// console.log('Hosted shell response:', responseHosted.output_text);
|
||||
|
||||
const conversation = [{
|
||||
role: 'user',
|
||||
content: "Use the mycontacts skill and run locally to find the phone number of Qiaozhen."
|
||||
}]
|
||||
|
||||
let hasShellCall = true
|
||||
let round = 0
|
||||
|
||||
while(hasShellCall) {
|
||||
hasShellCall = false
|
||||
round++
|
||||
|
||||
const responseLocal = await client.responses.create({
|
||||
const responseHosted = await client.responses.create({
|
||||
model: "gpt-5.2",
|
||||
tools: [
|
||||
{
|
||||
type: "shell",
|
||||
environment: {
|
||||
type: "local",
|
||||
type: "container_auto",
|
||||
skills: [
|
||||
{
|
||||
name: "mycontacts",
|
||||
description: "My contacts info",
|
||||
path: path.resolve("./skills/mycontacts"),
|
||||
},
|
||||
{ type: "skill_reference", skill_id: "skill_69b7c456a9408193856b890836fcd1950fd5b0453b8a6018" },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
input: conversation,
|
||||
input: "Use the skills to find phone number of Qiaozhen.",
|
||||
});
|
||||
|
||||
console.log('Local shell response output:', JSON.stringify(responseLocal.output, null, 2));
|
||||
console.log('Hosted shell response:', responseHosted.output_text);
|
||||
|
||||
conversation.push(...responseLocal.output)
|
||||
// const conversation = [{
|
||||
// role: 'user',
|
||||
// content: "Use the mycontacts skill and run locally to find the phone number of Qiaozhen."
|
||||
// }]
|
||||
|
||||
responseLocal.output.forEach(item => {
|
||||
if (item.type == 'shell_call') {
|
||||
hasShellCall = true
|
||||
console.log('shell call item =', item)
|
||||
let shell_call_output = []
|
||||
item.action.commands.forEach(command => {
|
||||
// let hasShellCall = true
|
||||
// let round = 0
|
||||
|
||||
console.log('$', command, '\n')
|
||||
// while(hasShellCall) {
|
||||
// hasShellCall = false
|
||||
// round++
|
||||
|
||||
// const responseLocal = await client.responses.create({
|
||||
// model: "gpt-5.2",
|
||||
// tools: [
|
||||
// {
|
||||
// type: "shell",
|
||||
// environment: {
|
||||
// type: "local",
|
||||
// skills: [
|
||||
// {
|
||||
// name: "mycontacts",
|
||||
// description: "My contacts info",
|
||||
// path: path.resolve("./skills/mycontacts"),
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// input: conversation,
|
||||
// });
|
||||
|
||||
// console.log('Local shell response output:', JSON.stringify(responseLocal.output, null, 2));
|
||||
|
||||
// conversation.push(...responseLocal.output)
|
||||
|
||||
// responseLocal.output.forEach(item => {
|
||||
// if (item.type == 'shell_call') {
|
||||
// hasShellCall = true
|
||||
// console.log('shell call item =', item)
|
||||
// let shell_call_output = []
|
||||
// item.action.commands.forEach(command => {
|
||||
|
||||
// console.log('$', command, '\n')
|
||||
|
||||
|
||||
let { stdout, stderr } = shell.exec(command, {
|
||||
silent: true
|
||||
})
|
||||
shell_call_output.push({
|
||||
stdout,
|
||||
stderr,
|
||||
outcome: { type: 'exit', exit_code: 0 }
|
||||
})
|
||||
})
|
||||
// let { stdout, stderr } = shell.exec(command, {
|
||||
// silent: true
|
||||
// })
|
||||
// shell_call_output.push({
|
||||
// stdout,
|
||||
// stderr,
|
||||
// outcome: { type: 'exit', exit_code: 0 }
|
||||
// })
|
||||
// })
|
||||
|
||||
conversation.push({
|
||||
type: 'shell_call_output',
|
||||
call_id: item.call_id,
|
||||
output: shell_call_output
|
||||
})
|
||||
}
|
||||
})
|
||||
// conversation.push({
|
||||
// type: 'shell_call_output',
|
||||
// call_id: item.call_id,
|
||||
// output: shell_call_output
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
|
||||
console.log('Local shell response of round ' + round + ':', JSON.stringify(responseLocal.output_text, null, 2));
|
||||
// console.log('Local shell response of round ' + round + ':', JSON.stringify(responseLocal.output_text, null, 2));
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
Reference in New Issue
Block a user