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));
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
12
8-skill.md
12
8-skill.md
@@ -1,5 +1,5 @@
|
||||
```
|
||||
curl -X POST 'https://api.openai.com/v1/skills' -H "Authorization: Bearer $OPENAI_API_KEY" -F 'files[]=@./contacts/SKILL.md;filename=contacts/SKILL.md;type=text/markdown''
|
||||
$ curl -X POST 'https://api.openai.com/v1/skills' -H "Authorization: Bearer $OPENAI_API_KEY" -F 'files[]=@./contacts/SKILL.md;filename=contacts/SKILL.md;type=text/markdown''
|
||||
{
|
||||
"id": "skill_69b7aab7a0988191afca6ad2c530326b07c9ae27b6429c7c",
|
||||
"object": "skill",
|
||||
@@ -9,10 +9,11 @@ curl -X POST 'https://api.openai.com/v1/skills' -H "Authorization: Bearer $OPENA
|
||||
"latest_version": "1",
|
||||
"name": "contacts"
|
||||
}
|
||||
<07:01:11#root@codespaces-5a7969=23.97.62.113^x86_64,Linux,Debtrixie/sid:/workspaces/my-default-codespace/aitest>#
|
||||
```
|
||||
|
||||
注意,必须只有一级目录,不能有子目录 (skills/contacts/skill.md),否则会报错:
|
||||
会被上传到 OpenAI,可以在个人中心的 Storage 里的 Skills 标签下找到。
|
||||
|
||||
注意,通过curl上传,必须只有一级目录,不能有子目录 (skills/contacts/skill.md),否则会报错:
|
||||
|
||||
```
|
||||
{
|
||||
@@ -24,3 +25,8 @@ curl -X POST 'https://api.openai.com/v1/skills' -H "Authorization: Bearer $OPENA
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
curl -X POST 'https://api.openai.com/v1/skills' \
|
||||
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
||||
-F 'files[]=@./contacts2/skill.md;filename=contacts2/skill.md;type=text/markdown' \
|
||||
-F 'files[]=@./contacts2/contacts.csv;filename=contacts2/contacts.csv;type=text/csv'
|
||||
|
||||
3
contacts2/contacts.csv
Normal file
3
contacts2/contacts.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
Xue Hua, 18617591633
|
||||
Luk Lu, 15295439901
|
||||
Zong Qiaozhen, 13585016982
|
||||
|
6
contacts2/skill.md
Normal file
6
contacts2/skill.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
name: contacts2
|
||||
description: My contact list
|
||||
---
|
||||
|
||||
Use this skill when you need to find details of a contact of mine. The skill provides a list of contacts in CSV format: "name, phone" in contacts.csv.
|
||||
Reference in New Issue
Block a user