It is currently 8 June 2025, 7:43 Advanced search

Select Single Node domanda

Domande e risposte su come utilizzare Instant Developer Foundation al meglio

Select Single Node domanda

Postby giopoi47 » 30 December 2023, 10:08

DEBUG
nstatus := rnodo.Select Single Node ("/Root_JSON/status") [Null]
base := C"/Root_JSON/required_action/submit_tool_outputs/tool_calls" [/Root_JSON/required_action/submit_tool_outputs/tool_calls]
n Function := rnodo.Select Single Node (base + "/function/name") [Null]
n Arguments := rnodo.Select Single Node (base + "/function/arguments") [Null]
DOMANDA:
i null sono dovuti al fatto che ad esempio status non è considerato un nodo?
Però il convertitore da json a xml mi dà: <status>requires_action</status>
Ok, comunque Select Single Node è molto utile e fa risparmiare molto tempo
è praticamente una find su un json.

una parte del mio JSON:
{
"id": "run_y9p9ecZVEJo5WLvROUrWzsKy",
"object": "thread.run",
"created_at": 1703793348,
"assistant_id": "asst_J00a337CrYjT619kZ8sUM7zE",
"thread_id": "thread_YPBOVlvx8YSbPyFekdqHjNpk",
"status": "requires_action",
"started_at": 1703793349,
"expires_at": 1703793948,
"cancelled_at": null,
"failed_at": null,
"completed_at": null,
"required_action": {
"type": "submit_tool_outputs",
"submit_tool_outputs": {
"tool_calls": [
{
"id": "call_xSBIyZ2d89Fahg4r3aNfmBcZ",
"type": "function",
"function": {
"name": "getchurch",
"arguments": "{\"id\":1}"
}
}
]
}
},
Poidomani Giovanni, freelance
User avatar
giopoi47
 
Posts: 161
Joined: 27 January 2023, 10:47

Re: Select Single Node domanda

Postby ljwilson » 2 January 2024, 22:39

Se prendo questo json:
Code: Select all
{
  "id": "run_y9p9ecZVEJo5WLvROUrWzsKy",
  "object": "thread.run",
  "created_at": 1703793348,
  "assistant_id": "asst_J00a337CrYjT619kZ8sUM7zE",
  "thread_id": "thread_YPBOVlvx8YSbPyFekdqHjNpk",
  "status": "requires_action",
  "started_at": 1703793349,
  "expires_at": 1703793948,
  "cancelled_at": null,
  "failed_at": null,
  "completed_at": null,
  "required_action": {
    "type": "submit_tool_outputs",
    "submit_tool_outputs": {
      "tool_calls": [
        {
          "id": "call_xSBIyZ2d89Fahg4r3aNfmBcZ",
          "type": "function",
          "function": {
            "name": "getchurch",
            "arguments": "{\"id\":1}"
          }
        }
      ]
    }
  }
}



Ed eseguilo tramite un convertitore web json->xml https://jsonformatter.org ottengo:
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<id>run_y9p9ecZVEJo5WLvROUrWzsKy</id>
<object>thread.run</object>
<created_at>1703793348</created_at>
<assistant_id>asst_J00a337CrYjT619kZ8sUM7zE</assistant_id>
<thread_id>thread_YPBOVlvx8YSbPyFekdqHjNpk</thread_id>
<status>requires_action</status>
<started_at>1703793349</started_at>
<expires_at>1703793948</expires_at>
<cancelled_at />
<failed_at />
<completed_at />
<required_action>
  <type>submit_tool_outputs</type>
  <submit_tool_outputs>
    <tool_calls>
      <id>call_xSBIyZ2d89Fahg4r3aNfmBcZ</id>
      <type>function</type>
      <function>
        <name>getchurch</name>
        <arguments>{"id":1}</arguments>
      </function>
    </tool_calls>
  </submit_tool_outputs>
</required_action>


Tuttavia, se lo fai all'interno di INDE caricandolo in un documento xml e salvandolo di nuovo come xml, ottengo:
Code: Select all
<?xml version="1.0" encoding="utf-16"?>
<Root_JSON id="run_y9p9ecZVEJo5WLvROUrWzsKy" object="thread.run" created_at="1703793348" assistant_id="asst_J00a337CrYjT619kZ8sUM7zE" thread_id="thread_YPBOVlvx8YSbPyFekdqHjNpk" status="requires_action" started_at="1703793349" expires_at="1703793948" cancelled_at="" failed_at="" completed_at="">
  <required_action type="submit_tool_outputs">
    <submit_tool_outputs>
      <tool_calls id="call_xSBIyZ2d89Fahg4r3aNfmBcZ" type="function">
        <function name="getchurch" arguments="{&quot;id&quot;:1}" />
      </tool_calls>
    </submit_tool_outputs>
  </required_action>
</Root_JSON>

Puoi vedere che internamente INDE vede lo "status" come un attributo del nodo Root_JSON.

Al momento ricevo un errore quando provo a caricare un piccolo progetto di esempio da illustrare, ma il codice è simile a:
Code: Select all
string sJson = "{"id":"run_y9p9ecZVEJo5WLvROUrWzsKy","object":"thread.
         run","created_at":1703793348,"assistant_id":"asst_J00a337CrYjT619kZ8sUM7zE","thread_id":"thread_YPBOVlvx8YSbPyFekdqHjNpk","status":"requires_action","started_at":1703793349,"expires_a­
         t":1703793948,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_xSBIyZ2d89Fahg4­
         r3aNfmBcZ","type":"function","function":{"name":"getchurch","arguments":"{\\"id\\":1}"}}]}}}"

string sXml = ""

XMLDocument xmld = new()
xmld.loadFromString(sJson, JSON)
sXml = xmld.saveToString(XML)
xmld.loadFromString(sXml, XML)
XMLNode xmln = null
xmln = xmld.getRootNode()
string sMyStatus = xmln.getAttribute("status", ...)
TestXpathApp.messageBox(sMyStatus)


...jack
ljwilson
 
Posts: 787
Joined: 26 November 2013, 14:15

Re: Select Single Node domanda

Postby giopoi47 » 18 October 2024, 12:47

grazie!
Poidomani Giovanni, freelance
User avatar
giopoi47
 
Posts: 161
Joined: 27 January 2023, 10:47


Return to Tips & Tricks - Foundation

Who is online

Users browsing this forum: No registered users and 81 guests

cron