@azure/ai-projects 1.0.0-alpha.20250313.1 → 1.0.0-alpha.20250318.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/README.md +231 -185
  2. package/dist/browser/agents/assistants.d.ts.map +1 -1
  3. package/dist/browser/agents/assistants.js +3 -1
  4. package/dist/browser/agents/assistants.js.map +1 -1
  5. package/dist/browser/agents/customModels.d.ts +4 -29
  6. package/dist/browser/agents/customModels.d.ts.map +1 -1
  7. package/dist/browser/agents/customModels.js.map +1 -1
  8. package/dist/browser/agents/files.d.ts +5 -4
  9. package/dist/browser/agents/files.d.ts.map +1 -1
  10. package/dist/browser/agents/files.js +55 -27
  11. package/dist/browser/agents/files.js.map +1 -1
  12. package/dist/browser/agents/index.d.ts +10 -10
  13. package/dist/browser/agents/index.d.ts.map +1 -1
  14. package/dist/browser/agents/index.js.map +1 -1
  15. package/dist/browser/agents/inputOutputs.d.ts +3 -3
  16. package/dist/browser/agents/inputOutputs.d.ts.map +1 -1
  17. package/dist/browser/agents/inputOutputs.js.map +1 -1
  18. package/dist/browser/agents/inputValidations.d.ts.map +1 -1
  19. package/dist/browser/agents/inputValidations.js +2 -1
  20. package/dist/browser/agents/inputValidations.js.map +1 -1
  21. package/dist/browser/agents/messages.js +2 -2
  22. package/dist/browser/agents/messages.js.map +1 -1
  23. package/dist/browser/agents/poller.d.ts +8 -33
  24. package/dist/browser/agents/poller.d.ts.map +1 -1
  25. package/dist/browser/agents/poller.js +130 -53
  26. package/dist/browser/agents/poller.js.map +1 -1
  27. package/dist/browser/agents/streamingModels.d.ts +17 -15
  28. package/dist/browser/agents/streamingModels.d.ts.map +1 -1
  29. package/dist/browser/agents/streamingModels.js.map +1 -1
  30. package/dist/browser/agents/traceUtility.d.ts +3 -3
  31. package/dist/browser/agents/traceUtility.d.ts.map +1 -1
  32. package/dist/browser/agents/traceUtility.js.map +1 -1
  33. package/dist/browser/agents/utils.d.ts +53 -3
  34. package/dist/browser/agents/utils.d.ts.map +1 -1
  35. package/dist/browser/agents/utils.js +71 -1
  36. package/dist/browser/agents/utils.js.map +1 -1
  37. package/dist/browser/agents/vectorStores.d.ts +3 -4
  38. package/dist/browser/agents/vectorStores.d.ts.map +1 -1
  39. package/dist/browser/agents/vectorStores.js +44 -26
  40. package/dist/browser/agents/vectorStores.js.map +1 -1
  41. package/dist/browser/agents/vectorStoresFileBatches.d.ts +5 -4
  42. package/dist/browser/agents/vectorStoresFileBatches.d.ts.map +1 -1
  43. package/dist/browser/agents/vectorStoresFileBatches.js +46 -32
  44. package/dist/browser/agents/vectorStoresFileBatches.js.map +1 -1
  45. package/dist/browser/agents/vectorStoresFiles.d.ts +4 -4
  46. package/dist/browser/agents/vectorStoresFiles.d.ts.map +1 -1
  47. package/dist/browser/agents/vectorStoresFiles.js +57 -28
  48. package/dist/browser/agents/vectorStoresFiles.js.map +1 -1
  49. package/dist/browser/customization/convertModelsToWrite.d.ts.map +1 -1
  50. package/dist/browser/customization/convertModelsToWrite.js +42 -93
  51. package/dist/browser/customization/convertModelsToWrite.js.map +1 -1
  52. package/dist/browser/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  53. package/dist/browser/customization/convertOutputModelsFromWire.js +51 -9
  54. package/dist/browser/customization/convertOutputModelsFromWire.js.map +1 -1
  55. package/dist/browser/customization/convertParametersToWire.d.ts +1 -1
  56. package/dist/browser/customization/convertParametersToWire.d.ts.map +1 -1
  57. package/dist/browser/customization/convertParametersToWire.js.map +1 -1
  58. package/dist/browser/customization/models.d.ts +146 -151
  59. package/dist/browser/customization/models.d.ts.map +1 -1
  60. package/dist/browser/customization/models.js.map +1 -1
  61. package/dist/browser/customization/outputModels.d.ts +188 -37
  62. package/dist/browser/customization/outputModels.d.ts.map +1 -1
  63. package/dist/browser/customization/outputModels.js.map +1 -1
  64. package/dist/browser/customization/streamingModels.d.ts +2 -1
  65. package/dist/browser/customization/streamingModels.d.ts.map +1 -1
  66. package/dist/browser/customization/streamingModels.js.map +1 -1
  67. package/dist/browser/customization/streamingWireModels.d.ts +2 -1
  68. package/dist/browser/customization/streamingWireModels.d.ts.map +1 -1
  69. package/dist/browser/customization/streamingWireModels.js.map +1 -1
  70. package/dist/browser/generated/src/models.d.ts +131 -150
  71. package/dist/browser/generated/src/models.d.ts.map +1 -1
  72. package/dist/browser/generated/src/models.js.map +1 -1
  73. package/dist/browser/generated/src/outputModels.d.ts +187 -36
  74. package/dist/browser/generated/src/outputModels.d.ts.map +1 -1
  75. package/dist/browser/generated/src/outputModels.js.map +1 -1
  76. package/dist/browser/generated/src/paginateHelper.d.ts +27 -2
  77. package/dist/browser/generated/src/paginateHelper.d.ts.map +1 -1
  78. package/dist/browser/generated/src/paginateHelper.js +98 -1
  79. package/dist/browser/generated/src/paginateHelper.js.map +1 -1
  80. package/dist/browser/generated/src/projectsClient.d.ts +2 -2
  81. package/dist/browser/generated/src/projectsClient.d.ts.map +1 -1
  82. package/dist/browser/generated/src/projectsClient.js +2 -2
  83. package/dist/browser/generated/src/projectsClient.js.map +1 -1
  84. package/dist/commonjs/agents/assistants.d.ts.map +1 -1
  85. package/dist/commonjs/agents/assistants.js +3 -1
  86. package/dist/commonjs/agents/assistants.js.map +1 -1
  87. package/dist/commonjs/agents/customModels.d.ts +4 -29
  88. package/dist/commonjs/agents/customModels.d.ts.map +1 -1
  89. package/dist/commonjs/agents/customModels.js.map +1 -1
  90. package/dist/commonjs/agents/files.d.ts +5 -4
  91. package/dist/commonjs/agents/files.d.ts.map +1 -1
  92. package/dist/commonjs/agents/files.js +55 -26
  93. package/dist/commonjs/agents/files.js.map +1 -1
  94. package/dist/commonjs/agents/index.d.ts +10 -10
  95. package/dist/commonjs/agents/index.d.ts.map +1 -1
  96. package/dist/commonjs/agents/index.js.map +1 -1
  97. package/dist/commonjs/agents/inputOutputs.d.ts +3 -3
  98. package/dist/commonjs/agents/inputOutputs.d.ts.map +1 -1
  99. package/dist/commonjs/agents/inputOutputs.js.map +1 -1
  100. package/dist/commonjs/agents/inputValidations.d.ts.map +1 -1
  101. package/dist/commonjs/agents/inputValidations.js +2 -1
  102. package/dist/commonjs/agents/inputValidations.js.map +1 -1
  103. package/dist/commonjs/agents/messages.js +2 -2
  104. package/dist/commonjs/agents/messages.js.map +1 -1
  105. package/dist/commonjs/agents/poller.d.ts +8 -33
  106. package/dist/commonjs/agents/poller.d.ts.map +1 -1
  107. package/dist/commonjs/agents/poller.js +131 -55
  108. package/dist/commonjs/agents/poller.js.map +1 -1
  109. package/dist/commonjs/agents/streamingModels.d.ts +17 -15
  110. package/dist/commonjs/agents/streamingModels.d.ts.map +1 -1
  111. package/dist/commonjs/agents/streamingModels.js.map +1 -1
  112. package/dist/commonjs/agents/traceUtility.d.ts +3 -3
  113. package/dist/commonjs/agents/traceUtility.d.ts.map +1 -1
  114. package/dist/commonjs/agents/traceUtility.js.map +1 -1
  115. package/dist/commonjs/agents/utils.d.ts +53 -3
  116. package/dist/commonjs/agents/utils.d.ts.map +1 -1
  117. package/dist/commonjs/agents/utils.js +71 -1
  118. package/dist/commonjs/agents/utils.js.map +1 -1
  119. package/dist/commonjs/agents/vectorStores.d.ts +3 -4
  120. package/dist/commonjs/agents/vectorStores.d.ts.map +1 -1
  121. package/dist/commonjs/agents/vectorStores.js +43 -25
  122. package/dist/commonjs/agents/vectorStores.js.map +1 -1
  123. package/dist/commonjs/agents/vectorStoresFileBatches.d.ts +5 -4
  124. package/dist/commonjs/agents/vectorStoresFileBatches.d.ts.map +1 -1
  125. package/dist/commonjs/agents/vectorStoresFileBatches.js +46 -31
  126. package/dist/commonjs/agents/vectorStoresFileBatches.js.map +1 -1
  127. package/dist/commonjs/agents/vectorStoresFiles.d.ts +4 -4
  128. package/dist/commonjs/agents/vectorStoresFiles.d.ts.map +1 -1
  129. package/dist/commonjs/agents/vectorStoresFiles.js +56 -27
  130. package/dist/commonjs/agents/vectorStoresFiles.js.map +1 -1
  131. package/dist/commonjs/customization/convertModelsToWrite.d.ts.map +1 -1
  132. package/dist/commonjs/customization/convertModelsToWrite.js +42 -93
  133. package/dist/commonjs/customization/convertModelsToWrite.js.map +1 -1
  134. package/dist/commonjs/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  135. package/dist/commonjs/customization/convertOutputModelsFromWire.js +51 -9
  136. package/dist/commonjs/customization/convertOutputModelsFromWire.js.map +1 -1
  137. package/dist/commonjs/customization/convertParametersToWire.d.ts +1 -1
  138. package/dist/commonjs/customization/convertParametersToWire.d.ts.map +1 -1
  139. package/dist/commonjs/customization/convertParametersToWire.js.map +1 -1
  140. package/dist/commonjs/customization/models.d.ts +146 -151
  141. package/dist/commonjs/customization/models.d.ts.map +1 -1
  142. package/dist/commonjs/customization/models.js.map +1 -1
  143. package/dist/commonjs/customization/outputModels.d.ts +188 -37
  144. package/dist/commonjs/customization/outputModels.d.ts.map +1 -1
  145. package/dist/commonjs/customization/outputModels.js.map +1 -1
  146. package/dist/commonjs/customization/streamingModels.d.ts +2 -1
  147. package/dist/commonjs/customization/streamingModels.d.ts.map +1 -1
  148. package/dist/commonjs/customization/streamingModels.js.map +1 -1
  149. package/dist/commonjs/customization/streamingWireModels.d.ts +2 -1
  150. package/dist/commonjs/customization/streamingWireModels.d.ts.map +1 -1
  151. package/dist/commonjs/customization/streamingWireModels.js.map +1 -1
  152. package/dist/commonjs/generated/src/models.d.ts +131 -150
  153. package/dist/commonjs/generated/src/models.d.ts.map +1 -1
  154. package/dist/commonjs/generated/src/models.js.map +1 -1
  155. package/dist/commonjs/generated/src/outputModels.d.ts +187 -36
  156. package/dist/commonjs/generated/src/outputModels.d.ts.map +1 -1
  157. package/dist/commonjs/generated/src/outputModels.js.map +1 -1
  158. package/dist/commonjs/generated/src/paginateHelper.d.ts +27 -2
  159. package/dist/commonjs/generated/src/paginateHelper.d.ts.map +1 -1
  160. package/dist/commonjs/generated/src/paginateHelper.js +99 -2
  161. package/dist/commonjs/generated/src/paginateHelper.js.map +1 -1
  162. package/dist/commonjs/generated/src/projectsClient.d.ts +2 -2
  163. package/dist/commonjs/generated/src/projectsClient.d.ts.map +1 -1
  164. package/dist/commonjs/generated/src/projectsClient.js +2 -2
  165. package/dist/commonjs/generated/src/projectsClient.js.map +1 -1
  166. package/dist/commonjs/tsdoc-metadata.json +1 -1
  167. package/dist/esm/agents/assistants.d.ts.map +1 -1
  168. package/dist/esm/agents/assistants.js +3 -1
  169. package/dist/esm/agents/assistants.js.map +1 -1
  170. package/dist/esm/agents/customModels.d.ts +4 -29
  171. package/dist/esm/agents/customModels.d.ts.map +1 -1
  172. package/dist/esm/agents/customModels.js.map +1 -1
  173. package/dist/esm/agents/files.d.ts +5 -4
  174. package/dist/esm/agents/files.d.ts.map +1 -1
  175. package/dist/esm/agents/files.js +55 -27
  176. package/dist/esm/agents/files.js.map +1 -1
  177. package/dist/esm/agents/index.d.ts +10 -10
  178. package/dist/esm/agents/index.d.ts.map +1 -1
  179. package/dist/esm/agents/index.js.map +1 -1
  180. package/dist/esm/agents/inputOutputs.d.ts +3 -3
  181. package/dist/esm/agents/inputOutputs.d.ts.map +1 -1
  182. package/dist/esm/agents/inputOutputs.js.map +1 -1
  183. package/dist/esm/agents/inputValidations.d.ts.map +1 -1
  184. package/dist/esm/agents/inputValidations.js +2 -1
  185. package/dist/esm/agents/inputValidations.js.map +1 -1
  186. package/dist/esm/agents/messages.js +2 -2
  187. package/dist/esm/agents/messages.js.map +1 -1
  188. package/dist/esm/agents/poller.d.ts +8 -33
  189. package/dist/esm/agents/poller.d.ts.map +1 -1
  190. package/dist/esm/agents/poller.js +130 -53
  191. package/dist/esm/agents/poller.js.map +1 -1
  192. package/dist/esm/agents/streamingModels.d.ts +17 -15
  193. package/dist/esm/agents/streamingModels.d.ts.map +1 -1
  194. package/dist/esm/agents/streamingModels.js.map +1 -1
  195. package/dist/esm/agents/traceUtility.d.ts +3 -3
  196. package/dist/esm/agents/traceUtility.d.ts.map +1 -1
  197. package/dist/esm/agents/traceUtility.js.map +1 -1
  198. package/dist/esm/agents/utils.d.ts +53 -3
  199. package/dist/esm/agents/utils.d.ts.map +1 -1
  200. package/dist/esm/agents/utils.js +71 -1
  201. package/dist/esm/agents/utils.js.map +1 -1
  202. package/dist/esm/agents/vectorStores.d.ts +3 -4
  203. package/dist/esm/agents/vectorStores.d.ts.map +1 -1
  204. package/dist/esm/agents/vectorStores.js +44 -26
  205. package/dist/esm/agents/vectorStores.js.map +1 -1
  206. package/dist/esm/agents/vectorStoresFileBatches.d.ts +5 -4
  207. package/dist/esm/agents/vectorStoresFileBatches.d.ts.map +1 -1
  208. package/dist/esm/agents/vectorStoresFileBatches.js +46 -32
  209. package/dist/esm/agents/vectorStoresFileBatches.js.map +1 -1
  210. package/dist/esm/agents/vectorStoresFiles.d.ts +4 -4
  211. package/dist/esm/agents/vectorStoresFiles.d.ts.map +1 -1
  212. package/dist/esm/agents/vectorStoresFiles.js +57 -28
  213. package/dist/esm/agents/vectorStoresFiles.js.map +1 -1
  214. package/dist/esm/customization/convertModelsToWrite.d.ts.map +1 -1
  215. package/dist/esm/customization/convertModelsToWrite.js +42 -93
  216. package/dist/esm/customization/convertModelsToWrite.js.map +1 -1
  217. package/dist/esm/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  218. package/dist/esm/customization/convertOutputModelsFromWire.js +51 -9
  219. package/dist/esm/customization/convertOutputModelsFromWire.js.map +1 -1
  220. package/dist/esm/customization/convertParametersToWire.d.ts +1 -1
  221. package/dist/esm/customization/convertParametersToWire.d.ts.map +1 -1
  222. package/dist/esm/customization/convertParametersToWire.js.map +1 -1
  223. package/dist/esm/customization/models.d.ts +146 -151
  224. package/dist/esm/customization/models.d.ts.map +1 -1
  225. package/dist/esm/customization/models.js.map +1 -1
  226. package/dist/esm/customization/outputModels.d.ts +188 -37
  227. package/dist/esm/customization/outputModels.d.ts.map +1 -1
  228. package/dist/esm/customization/outputModels.js.map +1 -1
  229. package/dist/esm/customization/streamingModels.d.ts +2 -1
  230. package/dist/esm/customization/streamingModels.d.ts.map +1 -1
  231. package/dist/esm/customization/streamingModels.js.map +1 -1
  232. package/dist/esm/customization/streamingWireModels.d.ts +2 -1
  233. package/dist/esm/customization/streamingWireModels.d.ts.map +1 -1
  234. package/dist/esm/customization/streamingWireModels.js.map +1 -1
  235. package/dist/esm/generated/src/models.d.ts +131 -150
  236. package/dist/esm/generated/src/models.d.ts.map +1 -1
  237. package/dist/esm/generated/src/models.js.map +1 -1
  238. package/dist/esm/generated/src/outputModels.d.ts +187 -36
  239. package/dist/esm/generated/src/outputModels.d.ts.map +1 -1
  240. package/dist/esm/generated/src/outputModels.js.map +1 -1
  241. package/dist/esm/generated/src/paginateHelper.d.ts +27 -2
  242. package/dist/esm/generated/src/paginateHelper.d.ts.map +1 -1
  243. package/dist/esm/generated/src/paginateHelper.js +98 -1
  244. package/dist/esm/generated/src/paginateHelper.js.map +1 -1
  245. package/dist/esm/generated/src/projectsClient.d.ts +2 -2
  246. package/dist/esm/generated/src/projectsClient.d.ts.map +1 -1
  247. package/dist/esm/generated/src/projectsClient.js +2 -2
  248. package/dist/esm/generated/src/projectsClient.js.map +1 -1
  249. package/dist/react-native/agents/assistants.d.ts.map +1 -1
  250. package/dist/react-native/agents/assistants.js +3 -1
  251. package/dist/react-native/agents/assistants.js.map +1 -1
  252. package/dist/react-native/agents/customModels.d.ts +4 -29
  253. package/dist/react-native/agents/customModels.d.ts.map +1 -1
  254. package/dist/react-native/agents/customModels.js.map +1 -1
  255. package/dist/react-native/agents/files.d.ts +5 -4
  256. package/dist/react-native/agents/files.d.ts.map +1 -1
  257. package/dist/react-native/agents/files.js +55 -27
  258. package/dist/react-native/agents/files.js.map +1 -1
  259. package/dist/react-native/agents/index.d.ts +10 -10
  260. package/dist/react-native/agents/index.d.ts.map +1 -1
  261. package/dist/react-native/agents/index.js.map +1 -1
  262. package/dist/react-native/agents/inputOutputs.d.ts +3 -3
  263. package/dist/react-native/agents/inputOutputs.d.ts.map +1 -1
  264. package/dist/react-native/agents/inputOutputs.js.map +1 -1
  265. package/dist/react-native/agents/inputValidations.d.ts.map +1 -1
  266. package/dist/react-native/agents/inputValidations.js +2 -1
  267. package/dist/react-native/agents/inputValidations.js.map +1 -1
  268. package/dist/react-native/agents/messages.js +2 -2
  269. package/dist/react-native/agents/messages.js.map +1 -1
  270. package/dist/react-native/agents/poller.d.ts +8 -33
  271. package/dist/react-native/agents/poller.d.ts.map +1 -1
  272. package/dist/react-native/agents/poller.js +130 -53
  273. package/dist/react-native/agents/poller.js.map +1 -1
  274. package/dist/react-native/agents/streamingModels.d.ts +17 -15
  275. package/dist/react-native/agents/streamingModels.d.ts.map +1 -1
  276. package/dist/react-native/agents/streamingModels.js.map +1 -1
  277. package/dist/react-native/agents/traceUtility.d.ts +3 -3
  278. package/dist/react-native/agents/traceUtility.d.ts.map +1 -1
  279. package/dist/react-native/agents/traceUtility.js.map +1 -1
  280. package/dist/react-native/agents/utils.d.ts +53 -3
  281. package/dist/react-native/agents/utils.d.ts.map +1 -1
  282. package/dist/react-native/agents/utils.js +71 -1
  283. package/dist/react-native/agents/utils.js.map +1 -1
  284. package/dist/react-native/agents/vectorStores.d.ts +3 -4
  285. package/dist/react-native/agents/vectorStores.d.ts.map +1 -1
  286. package/dist/react-native/agents/vectorStores.js +44 -26
  287. package/dist/react-native/agents/vectorStores.js.map +1 -1
  288. package/dist/react-native/agents/vectorStoresFileBatches.d.ts +5 -4
  289. package/dist/react-native/agents/vectorStoresFileBatches.d.ts.map +1 -1
  290. package/dist/react-native/agents/vectorStoresFileBatches.js +46 -32
  291. package/dist/react-native/agents/vectorStoresFileBatches.js.map +1 -1
  292. package/dist/react-native/agents/vectorStoresFiles.d.ts +4 -4
  293. package/dist/react-native/agents/vectorStoresFiles.d.ts.map +1 -1
  294. package/dist/react-native/agents/vectorStoresFiles.js +57 -28
  295. package/dist/react-native/agents/vectorStoresFiles.js.map +1 -1
  296. package/dist/react-native/customization/convertModelsToWrite.d.ts.map +1 -1
  297. package/dist/react-native/customization/convertModelsToWrite.js +42 -93
  298. package/dist/react-native/customization/convertModelsToWrite.js.map +1 -1
  299. package/dist/react-native/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  300. package/dist/react-native/customization/convertOutputModelsFromWire.js +51 -9
  301. package/dist/react-native/customization/convertOutputModelsFromWire.js.map +1 -1
  302. package/dist/react-native/customization/convertParametersToWire.d.ts +1 -1
  303. package/dist/react-native/customization/convertParametersToWire.d.ts.map +1 -1
  304. package/dist/react-native/customization/convertParametersToWire.js.map +1 -1
  305. package/dist/react-native/customization/models.d.ts +146 -151
  306. package/dist/react-native/customization/models.d.ts.map +1 -1
  307. package/dist/react-native/customization/models.js.map +1 -1
  308. package/dist/react-native/customization/outputModels.d.ts +188 -37
  309. package/dist/react-native/customization/outputModels.d.ts.map +1 -1
  310. package/dist/react-native/customization/outputModels.js.map +1 -1
  311. package/dist/react-native/customization/streamingModels.d.ts +2 -1
  312. package/dist/react-native/customization/streamingModels.d.ts.map +1 -1
  313. package/dist/react-native/customization/streamingModels.js.map +1 -1
  314. package/dist/react-native/customization/streamingWireModels.d.ts +2 -1
  315. package/dist/react-native/customization/streamingWireModels.d.ts.map +1 -1
  316. package/dist/react-native/customization/streamingWireModels.js.map +1 -1
  317. package/dist/react-native/generated/src/models.d.ts +131 -150
  318. package/dist/react-native/generated/src/models.d.ts.map +1 -1
  319. package/dist/react-native/generated/src/models.js.map +1 -1
  320. package/dist/react-native/generated/src/outputModels.d.ts +187 -36
  321. package/dist/react-native/generated/src/outputModels.d.ts.map +1 -1
  322. package/dist/react-native/generated/src/outputModels.js.map +1 -1
  323. package/dist/react-native/generated/src/paginateHelper.d.ts +27 -2
  324. package/dist/react-native/generated/src/paginateHelper.d.ts.map +1 -1
  325. package/dist/react-native/generated/src/paginateHelper.js +98 -1
  326. package/dist/react-native/generated/src/paginateHelper.js.map +1 -1
  327. package/dist/react-native/generated/src/projectsClient.d.ts +2 -2
  328. package/dist/react-native/generated/src/projectsClient.d.ts.map +1 -1
  329. package/dist/react-native/generated/src/projectsClient.js +2 -2
  330. package/dist/react-native/generated/src/projectsClient.js.map +1 -1
  331. package/package.json +16 -12
package/README.md CHANGED
@@ -9,9 +9,9 @@ Use the AI Projects client library (in preview) to:
9
9
 
10
10
  [Product documentation](https://aka.ms/azsdk/azure-ai-projects/product-doc)
11
11
 
12
- <!-- | [Samples][samples] -->
13
- <!-- | [Package (npm)](https://www.npmjs.com/package/@azure/ai-projects) -->
14
- <!-- | [API reference documentation](https://learn.microsoft.com/javascript/api/overview/azure/ai-projects-readme?view=azure-node-preview) -->
12
+ | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples)
13
+ | [Package (npm)](https://www.npmjs.com/package/@azure/ai-projects)
14
+ | [API reference documentation](https://learn.microsoft.com/javascript/api/overview/azure/ai-projects-readme?view=azure-node-preview)
15
15
 
16
16
  ## Table of contents
17
17
 
@@ -49,7 +49,7 @@ Use the AI Projects client library (in preview) to:
49
49
  - [Troubleshooting](#troubleshooting)
50
50
  - [Exceptions](#exceptions)
51
51
  - [Reporting issues](#reporting-issues)
52
- <!-- - [Next steps](#next-steps) -->
52
+ - [Next steps](#next-steps)
53
53
  - [Contributing](#contributing)
54
54
 
55
55
  ## Getting started
@@ -78,14 +78,11 @@ npm install @azure/ai-projects @azure/identity
78
78
 
79
79
  The class factory method `fromConnectionString` is used to construct the client. To construct a client:
80
80
 
81
- ```javascript
81
+ ```ts snippet:setup
82
82
  import { AIProjectsClient } from "@azure/ai-projects";
83
83
  import { DefaultAzureCredential } from "@azure/identity";
84
84
 
85
- import "dotenv/config";
86
-
87
- const connectionString = process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || "<connectionString>";
88
-
85
+ const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING ?? "<connectionString>";
89
86
  const client = AIProjectsClient.fromConnectionString(
90
87
  connectionString,
91
88
  new DefaultAzureCredential(),
@@ -98,13 +95,13 @@ const client = AIProjectsClient.fromConnectionString(
98
95
 
99
96
  Your Azure AI Foundry project has a "Management center". When you enter it, you will see a tab named "Connected resources" under your project. The `.connections` operations on the client allow you to enumerate the connections and get connection properties. Connection properties include the resource URL and authentication credentials, among other things.
100
97
 
101
- Below are code examples of the connection operations. Full samples can be found under the "connections" folder in the [package samples][samples].
98
+ Below are code examples of the connection operations. Full samples can be found under the "connections" folder in the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples).
102
99
 
103
100
  #### Get properties of all connections
104
101
 
105
102
  To list the properties of all the connections in the Azure AI Foundry project:
106
103
 
107
- ```javascript
104
+ ```ts snippet:listConnections
108
105
  const connections = await client.connections.listConnections();
109
106
  for (const connection of connections) {
110
107
  console.log(connection);
@@ -115,7 +112,7 @@ for (const connection of connections) {
115
112
 
116
113
  To list the properties of connections of a certain type (here Azure OpenAI):
117
114
 
118
- ```javascript
115
+ ```ts snippet:filterConnections
119
116
  const connections = await client.connections.listConnections({ category: "AzureOpenAI" });
120
117
  for (const connection of connections) {
121
118
  console.log(connection);
@@ -126,21 +123,21 @@ for (const connection of connections) {
126
123
 
127
124
  To get the connection properties of a connection named `connectionName`:
128
125
 
129
- ```javascript
126
+ ```ts snippet:getConnection
130
127
  const connection = await client.connections.getConnection("connectionName");
131
128
  console.log(connection);
132
129
  ```
133
130
 
134
131
  To get the connection properties with its authentication credentials:
135
132
 
136
- ```javascript
133
+ ```ts snippet:getConnectionWithSecrets
137
134
  const connection = await client.connections.getConnectionWithSecrets("connectionName");
138
135
  console.log(connection);
139
136
  ```
140
137
 
141
138
  ### Agents (Preview)
142
139
 
143
- Agents in the Azure AI Projects client library are designed to facilitate various interactions and operations within your AI projects. They serve as the core components that manage and execute tasks, leveraging different tools and resources to achieve specific goals. The following steps outline the typical sequence for interacting with Agents. See the "agents" folder in the [package samples][samples] for additional Agent samples.
140
+ Agents in the Azure AI Projects client library are designed to facilitate various interactions and operations within your AI projects. They serve as the core components that manage and execute tasks, leveraging different tools and resources to achieve specific goals. The following steps outline the typical sequence for interacting with Agents. See the "agents" folder in the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) for additional Agent samples.
144
141
 
145
142
  Agents are actively being developed. A sign-up form for private preview is coming soon.
146
143
 
@@ -148,7 +145,7 @@ Agents are actively being developed. A sign-up form for private preview is comin
148
145
 
149
146
  Here is an example of how to create an Agent:
150
147
 
151
- ```javascript
148
+ ```ts snippet:createAgent
152
149
  const agent = await client.agents.createAgent("gpt-4o", {
153
150
  name: "my-agent",
154
151
  instructions: "You are a helpful assistant",
@@ -159,12 +156,12 @@ To allow Agents to access your resources or custom functions, you need tools. Yo
159
156
 
160
157
  You can use `ToolSet` to do this:
161
158
 
162
- ```javascript
159
+ ```ts snippet:toolSet
160
+ import { ToolSet } from "@azure/ai-projects";
161
+
163
162
  const toolSet = new ToolSet();
164
163
  toolSet.addFileSearchTool([vectorStore.id]);
165
164
  toolSet.addCodeInterpreterTool([codeInterpreterFile.id]);
166
-
167
- // Create agent with tool set
168
165
  const agent = await client.agents.createAgent("gpt-4o", {
169
166
  name: "my-agent",
170
167
  instructions: "You are a helpful agent",
@@ -178,21 +175,20 @@ console.log(`Created agent, agent ID: ${agent.id}`);
178
175
 
179
176
  To perform file search by an Agent, we first need to upload a file, create a vector store, and associate the file to the vector store. Here is an example:
180
177
 
181
- ```javascript
182
- const localFileStream = fs.createReadStream("sample_file_for_upload.txt");
178
+ ```ts snippet:fileSearch
179
+ import { ToolUtility } from "@azure/ai-projects";
180
+
181
+ const localFileStream = fs.createReadStream(filePath);
183
182
  const file = await client.agents.uploadFile(localFileStream, "assistants", {
184
183
  fileName: "sample_file_for_upload.txt",
185
184
  });
186
185
  console.log(`Uploaded file, ID: ${file.id}`);
187
-
188
186
  const vectorStore = await client.agents.createVectorStore({
189
187
  fileIds: [file.id],
190
188
  name: "my_vector_store",
191
189
  });
192
190
  console.log(`Created vector store, ID: ${vectorStore.id}`);
193
-
194
191
  const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]);
195
-
196
192
  const agent = await client.agents.createAgent("gpt-4o", {
197
193
  name: "SDK Test Agent - Retrieval",
198
194
  instructions: "You are helpful agent that can help fetch data from files you know about.",
@@ -206,15 +202,15 @@ console.log(`Created agent, agent ID : ${agent.id}`);
206
202
 
207
203
  Here is an example to upload a file and use it for code interpreter by an Agent:
208
204
 
209
- ```javascript
210
- const fileStream = fs.createReadStream("nifty_500_quarterly_results.csv");
211
- const fFile = await client.agents.uploadFile(fileStream, "assistants", {
212
- fileName: "nifty_500_quarterly_results.csv",
213
- });
214
- console.log(`Uploaded local file, file ID : ${file.id}`);
215
-
216
- const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([file.id]);
205
+ ```ts snippet:codeInterpreter
206
+ import { ToolUtility } from "@azure/ai-projects";
217
207
 
208
+ const localFileStream = fs.createReadStream(filePath);
209
+ const localFile = await client.agents.uploadFile(localFileStream, "assistants", {
210
+ fileName: "localFile",
211
+ });
212
+ console.log(`Uploaded local file, file ID : ${localFile.id}`);
213
+ const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]);
218
214
  // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment
219
215
  const agent = await client.agents.createAgent("gpt-4o-mini", {
220
216
  name: "my-agent",
@@ -231,13 +227,15 @@ To enable your Agent to perform search through Bing search API, you use `ToolUti
231
227
 
232
228
  Here is an example:
233
229
 
234
- ```javascript
235
- const bingGroundingConnectionId = "<bingGroundingConnectionId>";
236
- const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [
237
- bingGroundingConnectionId,
238
- ]);
230
+ ```ts snippet:bingGrounding
231
+ import { ToolUtility, connectionToolType } from "@azure/ai-projects";
239
232
 
240
- const agent = await client.agents.createAgent("gpt-4-0125-preview", {
233
+ const bingConnection = await client.connections.getConnection(
234
+ process.env.BING_CONNECTION_NAME ?? "<connection-name>",
235
+ );
236
+ const connectionId = bingConnection.id;
237
+ const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [connectionId]);
238
+ const agent = await client.agents.createAgent("gpt-4o", {
241
239
  name: "my-agent",
242
240
  instructions: "You are a helpful agent",
243
241
  tools: [bingTool.definition],
@@ -251,17 +249,13 @@ Azure AI Search is an enterprise search system for high-performance applications
251
249
 
252
250
  Here is an example to integrate Azure AI Search:
253
251
 
254
- ```javascript
255
- const cognitiveServicesConnectionName = "<cognitiveServicesConnectionName>";
256
- const cognitiveServicesConnection = await client.connections.getConnection(
257
- cognitiveServicesConnectionName,
258
- );
259
- const azureAISearchTool = ToolUtility.createAzureAISearchTool(
260
- cognitiveServicesConnection.id,
261
- cognitiveServicesConnection.name,
262
- );
252
+ ```ts snippet:AISearch
253
+ import { ToolUtility } from "@azure/ai-projects";
263
254
 
264
- // Create agent with the Azure AI search tool
255
+ const connectionName =
256
+ process.env.AZURE_AI_SEARCH_CONNECTION_NAME ?? "<AzureAISearchConnectionName>";
257
+ const connection = await client.connections.getConnection(connectionName);
258
+ const azureAISearchTool = ToolUtility.createAzureAISearchTool(connection.id, connection.name);
265
259
  const agent = await client.agents.createAgent("gpt-4-0125-preview", {
266
260
  name: "my-agent",
267
261
  instructions: "You are a helpful agent",
@@ -277,48 +271,71 @@ You can enhance your Agents by defining callback functions as function tools. Th
277
271
 
278
272
  Here is an example:
279
273
 
280
- ```javascript
281
- class FunctionToolExecutor {
282
- private functionTools: { func: Function, definition: FunctionToolDefinition }[];
274
+ ```ts snippet:functionTools
275
+ import {
276
+ FunctionToolDefinition,
277
+ ToolUtility,
278
+ RequiredToolCallOutput,
279
+ FunctionToolDefinitionOutput,
280
+ ToolOutput,
281
+ } from "@azure/ai-projects";
283
282
 
283
+ class FunctionToolExecutor {
284
+ private functionTools: {
285
+ func: Function;
286
+ definition: FunctionToolDefinition;
287
+ }[];
284
288
  constructor() {
285
- this.functionTools = [{
286
- func: this.getUserFavoriteCity,
287
- ...ToolUtility.createFunctionTool({
288
- name: "getUserFavoriteCity",
289
- description: "Gets the user's favorite city.",
290
- parameters: {}
291
- })
292
- }, {
293
- func: this.getCityNickname,
294
- ...ToolUtility.createFunctionTool({
295
- name: "getCityNickname",
296
- description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.",
297
- parameters: { type: "object", properties: { location: { type: "string", description: "The city and state, e.g. Seattle, Wa" } } }
298
- })
299
- }, {
300
- func: this.getWeather,
301
- ...ToolUtility.createFunctionTool({
302
- name: "getWeather",
303
- description: "Gets the weather for a location.",
304
- parameters: { type: "object", properties: { location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, unit: { type: "string", enum: ['c', 'f'] } } }
305
- })
306
- }];
289
+ this.functionTools = [
290
+ {
291
+ func: this.getUserFavoriteCity,
292
+ ...ToolUtility.createFunctionTool({
293
+ name: "getUserFavoriteCity",
294
+ description: "Gets the user's favorite city.",
295
+ parameters: {},
296
+ }),
297
+ },
298
+ {
299
+ func: this.getCityNickname,
300
+ ...ToolUtility.createFunctionTool({
301
+ name: "getCityNickname",
302
+ description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.",
303
+ parameters: {
304
+ type: "object",
305
+ properties: {
306
+ location: { type: "string", description: "The city and state, e.g. Seattle, Wa" },
307
+ },
308
+ },
309
+ }),
310
+ },
311
+ {
312
+ func: this.getWeather,
313
+ ...ToolUtility.createFunctionTool({
314
+ name: "getWeather",
315
+ description: "Gets the weather for a location.",
316
+ parameters: {
317
+ type: "object",
318
+ properties: {
319
+ location: { type: "string", description: "The city and state, e.g. Seattle, Wa" },
320
+ unit: { type: "string", enum: ["c", "f"] },
321
+ },
322
+ },
323
+ }),
324
+ },
325
+ ];
307
326
  }
308
-
309
327
  private getUserFavoriteCity(): {} {
310
- return { "location": "Seattle, WA" };
328
+ return { location: "Seattle, WA" };
311
329
  }
312
-
313
330
  private getCityNickname(location: string): {} {
314
- return { "nickname": "The Emerald City" };
331
+ return { nickname: "The Emerald City" };
315
332
  }
316
-
317
333
  private getWeather(location: string, unit: string): {} {
318
- return { "weather": unit === "f" ? "72f" : "22c" };
334
+ return { weather: unit === "f" ? "72f" : "22c" };
319
335
  }
320
-
321
- public invokeTool(toolCall: RequiredToolCallOutput & FunctionToolDefinitionOutput): ToolOutput | undefined {
336
+ public invokeTool(
337
+ toolCall: RequiredToolCallOutput & FunctionToolDefinitionOutput,
338
+ ): ToolOutput | undefined {
322
339
  console.log(`Function tool call - ${toolCall.function.name}`);
323
340
  const args = [];
324
341
  if (toolCall.function.parameters) {
@@ -334,26 +351,30 @@ class FunctionToolExecutor {
334
351
  return undefined;
335
352
  }
336
353
  }
337
- const result = this.functionTools.find((tool) => tool.definition.function.name === toolCall.function.name)?.func(...args);
338
- return result ? {
339
- toolCallId: toolCall.id,
340
- output: JSON.stringify(result)
341
- } : undefined;
354
+ const result = this.functionTools
355
+ .find((tool) => tool.definition.function.name === toolCall.function.name)
356
+ ?.func(...args);
357
+ return result
358
+ ? {
359
+ toolCallId: toolCall.id,
360
+ output: JSON.stringify(result),
361
+ }
362
+ : undefined;
342
363
  }
343
-
344
364
  public getFunctionDefinitions(): FunctionToolDefinition[] {
345
- return this.functionTools.map(tool => {return tool.definition});
365
+ return this.functionTools.map((tool) => {
366
+ return tool.definition;
367
+ });
346
368
  }
347
369
  }
348
-
349
370
  const functionToolExecutor = new FunctionToolExecutor();
350
371
  const functionTools = functionToolExecutor.getFunctionDefinitions();
351
- const agent = await client.agents.createAgent("gpt-4o",
352
- {
353
- name: "my-agent",
354
- instructions: "You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.",
355
- tools: functionTools
356
- });
372
+ const agent = await client.agents.createAgent("gpt-4o", {
373
+ name: "my-agent",
374
+ instructions:
375
+ "You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.",
376
+ tools: functionTools,
377
+ });
357
378
  console.log(`Created agent, agent ID: ${agent.id}`);
358
379
  ```
359
380
 
@@ -361,7 +382,7 @@ console.log(`Created agent, agent ID: ${agent.id}`);
361
382
 
362
383
  For each session or conversation, a thread is required. Here is an example:
363
384
 
364
- ```javascript
385
+ ```ts snippet:createThread
365
386
  const thread = await client.agents.createThread();
366
387
  ```
367
388
 
@@ -369,28 +390,25 @@ const thread = await client.agents.createThread();
369
390
 
370
391
  In some scenarios, you might need to assign specific resources to individual threads. To achieve this, you provide the `toolResources` argument to `createThread`. In the following example, you create a vector store and upload a file, enable an Agent for file search using the `tools` argument, and then associate the file with the thread using the `toolResources` argument.
371
392
 
372
- ```javascript
373
- const localFileStream = fs.createReadStream("sample_file_for_upload.txt");
393
+ ```ts snippet:threadWithTool
394
+ import { ToolUtility } from "@azure/ai-projects";
395
+
396
+ const localFileStream = fs.createReadStream(filePath);
374
397
  const file = await client.agents.uploadFile(localFileStream, "assistants", {
375
- fileName: "sample_file_for_upload.txt",
398
+ fileName: "sample_file_for_upload.csv",
376
399
  });
377
400
  console.log(`Uploaded file, ID: ${file.id}`);
378
-
379
401
  const vectorStore = await client.agents.createVectorStore({
380
402
  fileIds: [file.id],
381
- name: "my_vector_store",
382
403
  });
383
404
  console.log(`Created vector store, ID: ${vectorStore.id}`);
384
-
385
405
  const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]);
386
-
387
406
  const agent = await client.agents.createAgent("gpt-4o", {
388
- name: "SDK Test Agent - Retrieval",
407
+ name: "myAgent",
389
408
  instructions: "You are helpful agent that can help fetch data from files you know about.",
390
409
  tools: [fileSearchTool.definition],
391
410
  });
392
411
  console.log(`Created agent, agent ID : ${agent.id}`);
393
-
394
412
  // Create thread with file resources.
395
413
  // If the agent has multiple threads, only this thread can search this file.
396
414
  const thread = await client.agents.createThread({ toolResources: fileSearchTool.resources });
@@ -400,18 +418,21 @@ const thread = await client.agents.createThread({ toolResources: fileSearchTool.
400
418
 
401
419
  To create a message for assistant to process, you pass `user` as `role` and a question as `content`:
402
420
 
403
- ```javascript
421
+ ```ts snippet:createMessage
404
422
  const message = await client.agents.createMessage(thread.id, {
405
423
  role: "user",
406
424
  content: "hello, world!",
407
425
  });
426
+ console.log(`Created message, message ID: ${message.id}`);
408
427
  ```
409
428
 
410
429
  #### Create Message with File Search Attachment
411
430
 
412
431
  To attach a file to a message for content searching, you use `ToolUtility.createFileSearchTool()` and the `attachments` argument:
413
432
 
414
- ```javascript
433
+ ```ts snippet:messageWithFileSearch
434
+ import { ToolUtility } from "@azure/ai-projects";
435
+
415
436
  const fileSearchTool = ToolUtility.createFileSearchTool();
416
437
  const message = await client.agents.createMessage(thread.id, {
417
438
  role: "user",
@@ -429,7 +450,9 @@ To attach a file to a message for data analysis, you use `ToolUtility.createCode
429
450
 
430
451
  Here is an example:
431
452
 
432
- ```javascript
453
+ ```ts snippet:messageWithCodeInterpreter
454
+ import { ToolUtility } from "@azure/ai-projects";
455
+
433
456
  // notice that CodeInterpreter must be enabled in the agent creation,
434
457
  // otherwise the agent will not be able to see the file attachment for code interpretation
435
458
  const codeInterpreterTool = ToolUtility.createCodeInterpreterTool();
@@ -442,7 +465,6 @@ console.log(`Created agent, agent ID: ${agent.id}`);
442
465
 
443
466
  const thread = await client.agents.createThread();
444
467
  console.log(`Created thread, thread ID: ${thread.id}`);
445
-
446
468
  const message = await client.agents.createMessage(thread.id, {
447
469
  role: "user",
448
470
  content:
@@ -459,9 +481,8 @@ console.log(`Created message, message ID: ${message.id}`);
459
481
 
460
482
  Here is an example of `createRun` and poll until the run is completed:
461
483
 
462
- ```javascript
484
+ ```ts snippet:createRun
463
485
  let run = await client.agents.createRun(thread.id, agent.id);
464
-
465
486
  // Poll the run as long as run status is queued or in progress
466
487
  while (
467
488
  run.status === "queued" ||
@@ -484,10 +505,10 @@ const run = await client.agents.createThreadAndRun(agent.id, {
484
505
  messages: [
485
506
  {
486
507
  role: "user",
487
- content: "hello, world!"
488
- }
489
- ]
490
- }
508
+ content: "hello, world!",
509
+ },
510
+ ],
511
+ },
491
512
  });
492
513
  ```
493
514
 
@@ -495,40 +516,49 @@ With streaming, polling also need not be considered.
495
516
 
496
517
  Here is an example:
497
518
 
498
- ```javascript
519
+ ```ts snippet:createRunStream
499
520
  const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream();
500
521
  ```
501
522
 
502
523
  Event handling can be done as follows:
503
524
 
504
- ```javascript
525
+ ```ts snippet:eventHandling
526
+ import {
527
+ RunStreamEvent,
528
+ ThreadRunOutput,
529
+ MessageStreamEvent,
530
+ MessageDeltaChunk,
531
+ MessageDeltaTextContent,
532
+ DoneEvent,
533
+ } from "@azure/ai-projects";
534
+
535
+ const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream();
505
536
  for await (const eventMessage of streamEventMessages) {
506
- switch (eventMessage.event) {
507
- case RunStreamEvent.ThreadRunCreated:
508
- console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`)
509
- break;
510
- case MessageStreamEvent.ThreadMessageDelta:
511
- {
512
- const messageDelta = eventMessage.data as MessageDeltaChunk;
513
- messageDelta.delta.content.forEach((contentPart) => {
514
- if (contentPart.type === "text") {
515
- const textContent = contentPart as MessageDeltaTextContent
516
- const textValue = textContent.text?.value || "No text"
517
- console.log(`Text delta received:: ${textValue}`)
518
- }
519
- });
520
- }
521
- break;
522
-
523
- case RunStreamEvent.ThreadRunCompleted:
524
- console.log("Thread Run Completed");
525
- break;
526
- case ErrorEvent.Error:
527
- console.log(`An error occurred. Data ${eventMessage.data}`);
528
- break;
529
- case DoneEvent.Done:
530
- console.log("Stream completed.");
531
- break;
537
+ switch (eventMessage.event) {
538
+ case RunStreamEvent.ThreadRunCreated:
539
+ console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`);
540
+ break;
541
+ case MessageStreamEvent.ThreadMessageDelta:
542
+ {
543
+ const messageDelta = eventMessage.data as MessageDeltaChunk;
544
+ messageDelta.delta.content.forEach((contentPart) => {
545
+ if (contentPart.type === "text") {
546
+ const textContent = contentPart as MessageDeltaTextContent;
547
+ const textValue = textContent.text?.value || "No text";
548
+ console.log(`Text delta received:: ${textValue}`);
549
+ }
550
+ });
551
+ }
552
+ break;
553
+ case RunStreamEvent.ThreadRunCompleted:
554
+ console.log("Thread Run Completed");
555
+ break;
556
+ case ErrorEvent.Error:
557
+ console.log(`An error occurred. Data ${eventMessage.data}`);
558
+ break;
559
+ case DoneEvent.Done:
560
+ console.log("Stream completed.");
561
+ break;
532
562
  }
533
563
  }
534
564
  ```
@@ -537,10 +567,14 @@ switch (eventMessage.event) {
537
567
 
538
568
  To retrieve messages from agents, use the following example:
539
569
 
540
- ```javascript
570
+ ```ts snippet:listMessages
571
+ import { MessageContentOutput, isOutputOfType, MessageTextContentOutput } from "../src/index.js";
572
+
541
573
  const messages = await client.agents.listMessages(thread.id);
542
574
  while (messages.hasMore) {
543
- const nextMessages = await client.agents.listMessages(currentRun.threadId, { after: messages.lastId });
575
+ const nextMessages = await client.agents.listMessages(currentRun.threadId, {
576
+ after: messages.lastId,
577
+ });
544
578
  messages.data = messages.data.concat(nextMessages.data);
545
579
  messages.hasMore = nextMessages.hasMore;
546
580
  messages.lastId = nextMessages.lastId;
@@ -549,12 +583,14 @@ while (messages.hasMore) {
549
583
  // The messages are following in the reverse order,
550
584
  // we will iterate them and output only text contents.
551
585
  for (const dataPoint of messages.data.reverse()) {
552
- const lastMessageContent: MessageContentOutput = dataPoint.content[dataPoint.content.length - 1];
553
- console.log( lastMessageContent);
554
- if (isOutputOfType<MessageTextContentOutput>(lastMessageContent, "text")) {
555
- console.log(`${dataPoint.role}: ${(lastMessageContent as MessageTextContentOutput).text.value}`);
556
- }
586
+ const lastMessageContent: MessageContentOutput = dataPoint.content[dataPoint.content.length - 1];
587
+ console.log(lastMessageContent);
588
+ if (isOutputOfType<MessageTextContentOutput>(lastMessageContent, "text")) {
589
+ console.log(
590
+ `${dataPoint.role}: ${(lastMessageContent as MessageTextContentOutput).text.value}`,
591
+ );
557
592
  }
593
+ }
558
594
  ```
559
595
 
560
596
  ### Retrieve File
@@ -563,12 +599,29 @@ Files uploaded by Agents cannot be retrieved back. If your use case needs to acc
563
599
 
564
600
  Here is an example retrieving file ids from messages:
565
601
 
566
- ```javascript
602
+ ```ts snippet:retrieveFile
603
+ import {
604
+ isOutputOfType,
605
+ MessageTextContentOutput,
606
+ MessageImageFileContentOutput,
607
+ } from "../src/index.js";
608
+
567
609
  const messages = await client.agents.listMessages(thread.id);
610
+ // Get most recent message from the assistant
611
+ const assistantMessage = messages.data.find((msg) => msg.role === "assistant");
612
+ if (assistantMessage) {
613
+ const textContent = assistantMessage.content.find((content) =>
614
+ isOutputOfType<MessageTextContentOutput>(content, "text"),
615
+ ) as MessageTextContentOutput;
616
+ if (textContent) {
617
+ console.log(`Last message: ${textContent.text.value}`);
618
+ }
619
+ }
568
620
  const imageFile = (messages.data[0].content[0] as MessageImageFileContentOutput).imageFile;
569
621
  const imageFileName = (await client.agents.getFile(imageFile.fileId)).filename;
570
-
571
- const fileContent = await (await client.agents.getFileContent(imageFile.fileId).asNodeStream()).body;
622
+ const fileContent = await (
623
+ await client.agents.getFileContent(imageFile.fileId).asNodeStream()
624
+ ).body;
572
625
  if (fileContent) {
573
626
  const chunks: Buffer[] = [];
574
627
  for await (const chunk of fileContent) {
@@ -586,13 +639,11 @@ console.log(`Saved image file to: ${imageFileName}`);
586
639
 
587
640
  To remove resources after completing tasks, use the following functions:
588
641
 
589
- ```javascript
642
+ ```ts snippet:teardown
590
643
  await client.agents.deleteVectorStore(vectorStore.id);
591
644
  console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`);
592
-
593
645
  await client.agents.deleteFile(file.id);
594
646
  console.log(`Deleted file, file ID: ${file.id}`);
595
-
596
647
  client.agents.deleteAgent(agent.id);
597
648
  console.log(`Deleted agent, agent ID: ${agent.id}`);
598
649
  ```
@@ -626,39 +677,34 @@ npm install @opentelemetry/exporter-trace-otlp-proto \
626
677
 
627
678
  Here is a code sample to be included above `createAgent`:
628
679
 
629
- ```javascript
630
- import { trace } from "@opentelemetry/api";
631
- import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter"
680
+ ```ts snippet:tracing
632
681
  import {
633
- ConsoleSpanExporter,
634
- NodeTracerProvider,
635
- SimpleSpanProcessor,
682
+ NodeTracerProvider,
683
+ SimpleSpanProcessor,
684
+ ConsoleSpanExporter,
636
685
  } from "@opentelemetry/sdk-trace-node";
686
+ import { trace } from "@opentelemetry/api";
687
+ import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter";
637
688
 
638
689
  const provider = new NodeTracerProvider();
639
690
  provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
640
691
  provider.register();
641
-
642
692
  const tracer = trace.getTracer("Agents Sample", "1.0.0");
643
-
644
- const client = AIProjectsClient.fromConnectionString(
645
- connectionString || "", new DefaultAzureCredential()
646
- );
647
-
648
- if (!appInsightsConnectionString) {
693
+ let appInsightsConnectionString =
694
+ process.env.APP_INSIGHTS_CONNECTION_STRING ?? "<appInsightsConnectionString>";
695
+ if (appInsightsConnectionString == "<appInsightsConnectionString>") {
649
696
  appInsightsConnectionString = await client.telemetry.getConnectionString();
650
697
  }
651
-
652
698
  if (appInsightsConnectionString) {
653
699
  const exporter = new AzureMonitorTraceExporter({
654
- connectionString: appInsightsConnectionString
700
+ connectionString: appInsightsConnectionString,
655
701
  });
656
702
  provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
657
703
  }
658
-
659
704
  await tracer.startActiveSpan("main", async (span) => {
660
- client.telemetry.updateSettings({enableContentRecording: true})
661
- // ...
705
+ client.telemetry.updateSettings({ enableContentRecording: true });
706
+ // ...
707
+ });
662
708
  ```
663
709
 
664
710
  ## Troubleshooting
@@ -667,16 +713,18 @@ await tracer.startActiveSpan("main", async (span) => {
667
713
 
668
714
  Client methods that make service calls raise an [RestError](https://learn.microsoft.com/javascript/api/%40azure/core-rest-pipeline/resterror) for a non-success HTTP status code response from the service. The exception's `code` will hold the HTTP response status code. The exception's `error.message` contains a detailed message that may be helpful in diagnosing the issue:
669
715
 
670
- ```javascript
671
- import { RestError } from "@azure/core-rest-pipeline"
672
-
673
- // ...
716
+ ```ts snippet:exceptions
717
+ import { RestError } from "@azure/core-rest-pipeline";
674
718
 
675
719
  try {
676
720
  const result = await client.connections.listConnections();
677
- } catch (e as RestError) {
678
- console.log(`Status code: ${e.code}`);
679
- console.log(e.message);
721
+ } catch (e) {
722
+ if (e instanceof RestError) {
723
+ console.log(`Status code: ${e.code}`);
724
+ console.log(e.message);
725
+ } else {
726
+ console.error(e);
727
+ }
680
728
  }
681
729
  ```
682
730
 
@@ -691,9 +739,9 @@ Operation returned an invalid status 'Unauthorized'
691
739
 
692
740
  To report issues with the client library, or request additional features, please open a GitHub issue [here](https://github.com/Azure/azure-sdk-for-js/issues)
693
741
 
694
- <!-- ## Next steps
742
+ ## Next steps
695
743
 
696
- Have a look at the [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) folder, containing fully runnable code. -->
744
+ Have a look at the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) folder, containing fully runnable code.
697
745
 
698
746
  ## Contributing
699
747
 
@@ -714,8 +762,6 @@ additional questions or comments.
714
762
 
715
763
  <!-- LINKS -->
716
764
 
717
- <!-- [samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples -->
718
-
719
765
  [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
720
766
  [entra_id]: https://learn.microsoft.com/azure/ai-services/authentication?tabs=powershell#authenticate-with-microsoft-entra-id
721
767
  [azure_identity_npm]: https://www.npmjs.com/package/@azure/identity