@azure/ai-projects 1.0.0-beta.2 → 1.0.0-beta.3

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 (344) hide show
  1. package/LICENSE +4 -4
  2. package/README.md +244 -183
  3. package/dist/browser/agents/assistants.d.ts.map +1 -1
  4. package/dist/browser/agents/assistants.js +3 -1
  5. package/dist/browser/agents/assistants.js.map +1 -1
  6. package/dist/browser/agents/customModels.d.ts +4 -29
  7. package/dist/browser/agents/customModels.d.ts.map +1 -1
  8. package/dist/browser/agents/customModels.js.map +1 -1
  9. package/dist/browser/agents/files.d.ts +5 -4
  10. package/dist/browser/agents/files.d.ts.map +1 -1
  11. package/dist/browser/agents/files.js +55 -27
  12. package/dist/browser/agents/files.js.map +1 -1
  13. package/dist/browser/agents/index.d.ts +10 -10
  14. package/dist/browser/agents/index.d.ts.map +1 -1
  15. package/dist/browser/agents/index.js.map +1 -1
  16. package/dist/browser/agents/inputOutputs.d.ts +3 -3
  17. package/dist/browser/agents/inputOutputs.d.ts.map +1 -1
  18. package/dist/browser/agents/inputOutputs.js.map +1 -1
  19. package/dist/browser/agents/inputValidations.d.ts.map +1 -1
  20. package/dist/browser/agents/inputValidations.js +2 -1
  21. package/dist/browser/agents/inputValidations.js.map +1 -1
  22. package/dist/browser/agents/messages.js +2 -2
  23. package/dist/browser/agents/messages.js.map +1 -1
  24. package/dist/browser/agents/poller.d.ts +8 -33
  25. package/dist/browser/agents/poller.d.ts.map +1 -1
  26. package/dist/browser/agents/poller.js +130 -53
  27. package/dist/browser/agents/poller.js.map +1 -1
  28. package/dist/browser/agents/streamingModels.d.ts +17 -15
  29. package/dist/browser/agents/streamingModels.d.ts.map +1 -1
  30. package/dist/browser/agents/streamingModels.js.map +1 -1
  31. package/dist/browser/agents/traceUtility.d.ts +3 -3
  32. package/dist/browser/agents/traceUtility.d.ts.map +1 -1
  33. package/dist/browser/agents/traceUtility.js.map +1 -1
  34. package/dist/browser/agents/utils.d.ts +53 -3
  35. package/dist/browser/agents/utils.d.ts.map +1 -1
  36. package/dist/browser/agents/utils.js +71 -1
  37. package/dist/browser/agents/utils.js.map +1 -1
  38. package/dist/browser/agents/vectorStores.d.ts +3 -4
  39. package/dist/browser/agents/vectorStores.d.ts.map +1 -1
  40. package/dist/browser/agents/vectorStores.js +44 -26
  41. package/dist/browser/agents/vectorStores.js.map +1 -1
  42. package/dist/browser/agents/vectorStoresFileBatches.d.ts +5 -4
  43. package/dist/browser/agents/vectorStoresFileBatches.d.ts.map +1 -1
  44. package/dist/browser/agents/vectorStoresFileBatches.js +46 -32
  45. package/dist/browser/agents/vectorStoresFileBatches.js.map +1 -1
  46. package/dist/browser/agents/vectorStoresFiles.d.ts +4 -4
  47. package/dist/browser/agents/vectorStoresFiles.d.ts.map +1 -1
  48. package/dist/browser/agents/vectorStoresFiles.js +57 -28
  49. package/dist/browser/agents/vectorStoresFiles.js.map +1 -1
  50. package/dist/browser/constants.d.ts +1 -1
  51. package/dist/browser/constants.js +1 -1
  52. package/dist/browser/constants.js.map +1 -1
  53. package/dist/browser/customization/convertModelsToWrite.d.ts.map +1 -1
  54. package/dist/browser/customization/convertModelsToWrite.js +42 -93
  55. package/dist/browser/customization/convertModelsToWrite.js.map +1 -1
  56. package/dist/browser/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  57. package/dist/browser/customization/convertOutputModelsFromWire.js +51 -9
  58. package/dist/browser/customization/convertOutputModelsFromWire.js.map +1 -1
  59. package/dist/browser/customization/convertParametersToWire.d.ts +1 -1
  60. package/dist/browser/customization/convertParametersToWire.d.ts.map +1 -1
  61. package/dist/browser/customization/convertParametersToWire.js.map +1 -1
  62. package/dist/browser/customization/models.d.ts +146 -151
  63. package/dist/browser/customization/models.d.ts.map +1 -1
  64. package/dist/browser/customization/models.js.map +1 -1
  65. package/dist/browser/customization/outputModels.d.ts +188 -37
  66. package/dist/browser/customization/outputModels.d.ts.map +1 -1
  67. package/dist/browser/customization/outputModels.js.map +1 -1
  68. package/dist/browser/customization/streamingModels.d.ts +2 -1
  69. package/dist/browser/customization/streamingModels.d.ts.map +1 -1
  70. package/dist/browser/customization/streamingModels.js.map +1 -1
  71. package/dist/browser/customization/streamingWireModels.d.ts +2 -1
  72. package/dist/browser/customization/streamingWireModels.d.ts.map +1 -1
  73. package/dist/browser/customization/streamingWireModels.js.map +1 -1
  74. package/dist/browser/generated/src/models.d.ts +131 -150
  75. package/dist/browser/generated/src/models.d.ts.map +1 -1
  76. package/dist/browser/generated/src/models.js.map +1 -1
  77. package/dist/browser/generated/src/outputModels.d.ts +187 -36
  78. package/dist/browser/generated/src/outputModels.d.ts.map +1 -1
  79. package/dist/browser/generated/src/outputModels.js.map +1 -1
  80. package/dist/browser/generated/src/paginateHelper.d.ts +27 -2
  81. package/dist/browser/generated/src/paginateHelper.d.ts.map +1 -1
  82. package/dist/browser/generated/src/paginateHelper.js +98 -1
  83. package/dist/browser/generated/src/paginateHelper.js.map +1 -1
  84. package/dist/browser/generated/src/projectsClient.d.ts +2 -2
  85. package/dist/browser/generated/src/projectsClient.d.ts.map +1 -1
  86. package/dist/browser/generated/src/projectsClient.js +3 -3
  87. package/dist/browser/generated/src/projectsClient.js.map +1 -1
  88. package/dist/commonjs/agents/assistants.d.ts.map +1 -1
  89. package/dist/commonjs/agents/assistants.js +3 -1
  90. package/dist/commonjs/agents/assistants.js.map +1 -1
  91. package/dist/commonjs/agents/customModels.d.ts +4 -29
  92. package/dist/commonjs/agents/customModels.d.ts.map +1 -1
  93. package/dist/commonjs/agents/customModels.js.map +1 -1
  94. package/dist/commonjs/agents/files.d.ts +5 -4
  95. package/dist/commonjs/agents/files.d.ts.map +1 -1
  96. package/dist/commonjs/agents/files.js +55 -26
  97. package/dist/commonjs/agents/files.js.map +1 -1
  98. package/dist/commonjs/agents/index.d.ts +10 -10
  99. package/dist/commonjs/agents/index.d.ts.map +1 -1
  100. package/dist/commonjs/agents/index.js.map +1 -1
  101. package/dist/commonjs/agents/inputOutputs.d.ts +3 -3
  102. package/dist/commonjs/agents/inputOutputs.d.ts.map +1 -1
  103. package/dist/commonjs/agents/inputOutputs.js.map +1 -1
  104. package/dist/commonjs/agents/inputValidations.d.ts.map +1 -1
  105. package/dist/commonjs/agents/inputValidations.js +2 -1
  106. package/dist/commonjs/agents/inputValidations.js.map +1 -1
  107. package/dist/commonjs/agents/messages.js +2 -2
  108. package/dist/commonjs/agents/messages.js.map +1 -1
  109. package/dist/commonjs/agents/poller.d.ts +8 -33
  110. package/dist/commonjs/agents/poller.d.ts.map +1 -1
  111. package/dist/commonjs/agents/poller.js +131 -55
  112. package/dist/commonjs/agents/poller.js.map +1 -1
  113. package/dist/commonjs/agents/streamingModels.d.ts +17 -15
  114. package/dist/commonjs/agents/streamingModels.d.ts.map +1 -1
  115. package/dist/commonjs/agents/streamingModels.js.map +1 -1
  116. package/dist/commonjs/agents/traceUtility.d.ts +3 -3
  117. package/dist/commonjs/agents/traceUtility.d.ts.map +1 -1
  118. package/dist/commonjs/agents/traceUtility.js.map +1 -1
  119. package/dist/commonjs/agents/utils.d.ts +53 -3
  120. package/dist/commonjs/agents/utils.d.ts.map +1 -1
  121. package/dist/commonjs/agents/utils.js +71 -1
  122. package/dist/commonjs/agents/utils.js.map +1 -1
  123. package/dist/commonjs/agents/vectorStores.d.ts +3 -4
  124. package/dist/commonjs/agents/vectorStores.d.ts.map +1 -1
  125. package/dist/commonjs/agents/vectorStores.js +43 -25
  126. package/dist/commonjs/agents/vectorStores.js.map +1 -1
  127. package/dist/commonjs/agents/vectorStoresFileBatches.d.ts +5 -4
  128. package/dist/commonjs/agents/vectorStoresFileBatches.d.ts.map +1 -1
  129. package/dist/commonjs/agents/vectorStoresFileBatches.js +46 -31
  130. package/dist/commonjs/agents/vectorStoresFileBatches.js.map +1 -1
  131. package/dist/commonjs/agents/vectorStoresFiles.d.ts +4 -4
  132. package/dist/commonjs/agents/vectorStoresFiles.d.ts.map +1 -1
  133. package/dist/commonjs/agents/vectorStoresFiles.js +56 -27
  134. package/dist/commonjs/agents/vectorStoresFiles.js.map +1 -1
  135. package/dist/commonjs/constants.d.ts +1 -1
  136. package/dist/commonjs/constants.js +1 -1
  137. package/dist/commonjs/constants.js.map +1 -1
  138. package/dist/commonjs/customization/convertModelsToWrite.d.ts.map +1 -1
  139. package/dist/commonjs/customization/convertModelsToWrite.js +42 -93
  140. package/dist/commonjs/customization/convertModelsToWrite.js.map +1 -1
  141. package/dist/commonjs/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  142. package/dist/commonjs/customization/convertOutputModelsFromWire.js +51 -9
  143. package/dist/commonjs/customization/convertOutputModelsFromWire.js.map +1 -1
  144. package/dist/commonjs/customization/convertParametersToWire.d.ts +1 -1
  145. package/dist/commonjs/customization/convertParametersToWire.d.ts.map +1 -1
  146. package/dist/commonjs/customization/convertParametersToWire.js.map +1 -1
  147. package/dist/commonjs/customization/models.d.ts +146 -151
  148. package/dist/commonjs/customization/models.d.ts.map +1 -1
  149. package/dist/commonjs/customization/models.js.map +1 -1
  150. package/dist/commonjs/customization/outputModels.d.ts +188 -37
  151. package/dist/commonjs/customization/outputModels.d.ts.map +1 -1
  152. package/dist/commonjs/customization/outputModels.js.map +1 -1
  153. package/dist/commonjs/customization/streamingModels.d.ts +2 -1
  154. package/dist/commonjs/customization/streamingModels.d.ts.map +1 -1
  155. package/dist/commonjs/customization/streamingModels.js.map +1 -1
  156. package/dist/commonjs/customization/streamingWireModels.d.ts +2 -1
  157. package/dist/commonjs/customization/streamingWireModels.d.ts.map +1 -1
  158. package/dist/commonjs/customization/streamingWireModels.js.map +1 -1
  159. package/dist/commonjs/generated/src/models.d.ts +131 -150
  160. package/dist/commonjs/generated/src/models.d.ts.map +1 -1
  161. package/dist/commonjs/generated/src/models.js.map +1 -1
  162. package/dist/commonjs/generated/src/outputModels.d.ts +187 -36
  163. package/dist/commonjs/generated/src/outputModels.d.ts.map +1 -1
  164. package/dist/commonjs/generated/src/outputModels.js.map +1 -1
  165. package/dist/commonjs/generated/src/paginateHelper.d.ts +27 -2
  166. package/dist/commonjs/generated/src/paginateHelper.d.ts.map +1 -1
  167. package/dist/commonjs/generated/src/paginateHelper.js +99 -2
  168. package/dist/commonjs/generated/src/paginateHelper.js.map +1 -1
  169. package/dist/commonjs/generated/src/projectsClient.d.ts +2 -2
  170. package/dist/commonjs/generated/src/projectsClient.d.ts.map +1 -1
  171. package/dist/commonjs/generated/src/projectsClient.js +3 -3
  172. package/dist/commonjs/generated/src/projectsClient.js.map +1 -1
  173. package/dist/commonjs/tsdoc-metadata.json +1 -1
  174. package/dist/esm/agents/assistants.d.ts.map +1 -1
  175. package/dist/esm/agents/assistants.js +3 -1
  176. package/dist/esm/agents/assistants.js.map +1 -1
  177. package/dist/esm/agents/customModels.d.ts +4 -29
  178. package/dist/esm/agents/customModels.d.ts.map +1 -1
  179. package/dist/esm/agents/customModels.js.map +1 -1
  180. package/dist/esm/agents/files.d.ts +5 -4
  181. package/dist/esm/agents/files.d.ts.map +1 -1
  182. package/dist/esm/agents/files.js +55 -27
  183. package/dist/esm/agents/files.js.map +1 -1
  184. package/dist/esm/agents/index.d.ts +10 -10
  185. package/dist/esm/agents/index.d.ts.map +1 -1
  186. package/dist/esm/agents/index.js.map +1 -1
  187. package/dist/esm/agents/inputOutputs.d.ts +3 -3
  188. package/dist/esm/agents/inputOutputs.d.ts.map +1 -1
  189. package/dist/esm/agents/inputOutputs.js.map +1 -1
  190. package/dist/esm/agents/inputValidations.d.ts.map +1 -1
  191. package/dist/esm/agents/inputValidations.js +2 -1
  192. package/dist/esm/agents/inputValidations.js.map +1 -1
  193. package/dist/esm/agents/messages.js +2 -2
  194. package/dist/esm/agents/messages.js.map +1 -1
  195. package/dist/esm/agents/poller.d.ts +8 -33
  196. package/dist/esm/agents/poller.d.ts.map +1 -1
  197. package/dist/esm/agents/poller.js +130 -53
  198. package/dist/esm/agents/poller.js.map +1 -1
  199. package/dist/esm/agents/streamingModels.d.ts +17 -15
  200. package/dist/esm/agents/streamingModels.d.ts.map +1 -1
  201. package/dist/esm/agents/streamingModels.js.map +1 -1
  202. package/dist/esm/agents/traceUtility.d.ts +3 -3
  203. package/dist/esm/agents/traceUtility.d.ts.map +1 -1
  204. package/dist/esm/agents/traceUtility.js.map +1 -1
  205. package/dist/esm/agents/utils.d.ts +53 -3
  206. package/dist/esm/agents/utils.d.ts.map +1 -1
  207. package/dist/esm/agents/utils.js +71 -1
  208. package/dist/esm/agents/utils.js.map +1 -1
  209. package/dist/esm/agents/vectorStores.d.ts +3 -4
  210. package/dist/esm/agents/vectorStores.d.ts.map +1 -1
  211. package/dist/esm/agents/vectorStores.js +44 -26
  212. package/dist/esm/agents/vectorStores.js.map +1 -1
  213. package/dist/esm/agents/vectorStoresFileBatches.d.ts +5 -4
  214. package/dist/esm/agents/vectorStoresFileBatches.d.ts.map +1 -1
  215. package/dist/esm/agents/vectorStoresFileBatches.js +46 -32
  216. package/dist/esm/agents/vectorStoresFileBatches.js.map +1 -1
  217. package/dist/esm/agents/vectorStoresFiles.d.ts +4 -4
  218. package/dist/esm/agents/vectorStoresFiles.d.ts.map +1 -1
  219. package/dist/esm/agents/vectorStoresFiles.js +57 -28
  220. package/dist/esm/agents/vectorStoresFiles.js.map +1 -1
  221. package/dist/esm/constants.d.ts +1 -1
  222. package/dist/esm/constants.js +1 -1
  223. package/dist/esm/constants.js.map +1 -1
  224. package/dist/esm/customization/convertModelsToWrite.d.ts.map +1 -1
  225. package/dist/esm/customization/convertModelsToWrite.js +42 -93
  226. package/dist/esm/customization/convertModelsToWrite.js.map +1 -1
  227. package/dist/esm/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  228. package/dist/esm/customization/convertOutputModelsFromWire.js +51 -9
  229. package/dist/esm/customization/convertOutputModelsFromWire.js.map +1 -1
  230. package/dist/esm/customization/convertParametersToWire.d.ts +1 -1
  231. package/dist/esm/customization/convertParametersToWire.d.ts.map +1 -1
  232. package/dist/esm/customization/convertParametersToWire.js.map +1 -1
  233. package/dist/esm/customization/models.d.ts +146 -151
  234. package/dist/esm/customization/models.d.ts.map +1 -1
  235. package/dist/esm/customization/models.js.map +1 -1
  236. package/dist/esm/customization/outputModels.d.ts +188 -37
  237. package/dist/esm/customization/outputModels.d.ts.map +1 -1
  238. package/dist/esm/customization/outputModels.js.map +1 -1
  239. package/dist/esm/customization/streamingModels.d.ts +2 -1
  240. package/dist/esm/customization/streamingModels.d.ts.map +1 -1
  241. package/dist/esm/customization/streamingModels.js.map +1 -1
  242. package/dist/esm/customization/streamingWireModels.d.ts +2 -1
  243. package/dist/esm/customization/streamingWireModels.d.ts.map +1 -1
  244. package/dist/esm/customization/streamingWireModels.js.map +1 -1
  245. package/dist/esm/generated/src/models.d.ts +131 -150
  246. package/dist/esm/generated/src/models.d.ts.map +1 -1
  247. package/dist/esm/generated/src/models.js.map +1 -1
  248. package/dist/esm/generated/src/outputModels.d.ts +187 -36
  249. package/dist/esm/generated/src/outputModels.d.ts.map +1 -1
  250. package/dist/esm/generated/src/outputModels.js.map +1 -1
  251. package/dist/esm/generated/src/paginateHelper.d.ts +27 -2
  252. package/dist/esm/generated/src/paginateHelper.d.ts.map +1 -1
  253. package/dist/esm/generated/src/paginateHelper.js +98 -1
  254. package/dist/esm/generated/src/paginateHelper.js.map +1 -1
  255. package/dist/esm/generated/src/projectsClient.d.ts +2 -2
  256. package/dist/esm/generated/src/projectsClient.d.ts.map +1 -1
  257. package/dist/esm/generated/src/projectsClient.js +3 -3
  258. package/dist/esm/generated/src/projectsClient.js.map +1 -1
  259. package/dist/react-native/agents/assistants.d.ts.map +1 -1
  260. package/dist/react-native/agents/assistants.js +3 -1
  261. package/dist/react-native/agents/assistants.js.map +1 -1
  262. package/dist/react-native/agents/customModels.d.ts +4 -29
  263. package/dist/react-native/agents/customModels.d.ts.map +1 -1
  264. package/dist/react-native/agents/customModels.js.map +1 -1
  265. package/dist/react-native/agents/files.d.ts +5 -4
  266. package/dist/react-native/agents/files.d.ts.map +1 -1
  267. package/dist/react-native/agents/files.js +55 -27
  268. package/dist/react-native/agents/files.js.map +1 -1
  269. package/dist/react-native/agents/index.d.ts +10 -10
  270. package/dist/react-native/agents/index.d.ts.map +1 -1
  271. package/dist/react-native/agents/index.js.map +1 -1
  272. package/dist/react-native/agents/inputOutputs.d.ts +3 -3
  273. package/dist/react-native/agents/inputOutputs.d.ts.map +1 -1
  274. package/dist/react-native/agents/inputOutputs.js.map +1 -1
  275. package/dist/react-native/agents/inputValidations.d.ts.map +1 -1
  276. package/dist/react-native/agents/inputValidations.js +2 -1
  277. package/dist/react-native/agents/inputValidations.js.map +1 -1
  278. package/dist/react-native/agents/messages.js +2 -2
  279. package/dist/react-native/agents/messages.js.map +1 -1
  280. package/dist/react-native/agents/poller.d.ts +8 -33
  281. package/dist/react-native/agents/poller.d.ts.map +1 -1
  282. package/dist/react-native/agents/poller.js +130 -53
  283. package/dist/react-native/agents/poller.js.map +1 -1
  284. package/dist/react-native/agents/streamingModels.d.ts +17 -15
  285. package/dist/react-native/agents/streamingModels.d.ts.map +1 -1
  286. package/dist/react-native/agents/streamingModels.js.map +1 -1
  287. package/dist/react-native/agents/traceUtility.d.ts +3 -3
  288. package/dist/react-native/agents/traceUtility.d.ts.map +1 -1
  289. package/dist/react-native/agents/traceUtility.js.map +1 -1
  290. package/dist/react-native/agents/utils.d.ts +53 -3
  291. package/dist/react-native/agents/utils.d.ts.map +1 -1
  292. package/dist/react-native/agents/utils.js +71 -1
  293. package/dist/react-native/agents/utils.js.map +1 -1
  294. package/dist/react-native/agents/vectorStores.d.ts +3 -4
  295. package/dist/react-native/agents/vectorStores.d.ts.map +1 -1
  296. package/dist/react-native/agents/vectorStores.js +44 -26
  297. package/dist/react-native/agents/vectorStores.js.map +1 -1
  298. package/dist/react-native/agents/vectorStoresFileBatches.d.ts +5 -4
  299. package/dist/react-native/agents/vectorStoresFileBatches.d.ts.map +1 -1
  300. package/dist/react-native/agents/vectorStoresFileBatches.js +46 -32
  301. package/dist/react-native/agents/vectorStoresFileBatches.js.map +1 -1
  302. package/dist/react-native/agents/vectorStoresFiles.d.ts +4 -4
  303. package/dist/react-native/agents/vectorStoresFiles.d.ts.map +1 -1
  304. package/dist/react-native/agents/vectorStoresFiles.js +57 -28
  305. package/dist/react-native/agents/vectorStoresFiles.js.map +1 -1
  306. package/dist/react-native/constants.d.ts +1 -1
  307. package/dist/react-native/constants.js +1 -1
  308. package/dist/react-native/constants.js.map +1 -1
  309. package/dist/react-native/customization/convertModelsToWrite.d.ts.map +1 -1
  310. package/dist/react-native/customization/convertModelsToWrite.js +42 -93
  311. package/dist/react-native/customization/convertModelsToWrite.js.map +1 -1
  312. package/dist/react-native/customization/convertOutputModelsFromWire.d.ts.map +1 -1
  313. package/dist/react-native/customization/convertOutputModelsFromWire.js +51 -9
  314. package/dist/react-native/customization/convertOutputModelsFromWire.js.map +1 -1
  315. package/dist/react-native/customization/convertParametersToWire.d.ts +1 -1
  316. package/dist/react-native/customization/convertParametersToWire.d.ts.map +1 -1
  317. package/dist/react-native/customization/convertParametersToWire.js.map +1 -1
  318. package/dist/react-native/customization/models.d.ts +146 -151
  319. package/dist/react-native/customization/models.d.ts.map +1 -1
  320. package/dist/react-native/customization/models.js.map +1 -1
  321. package/dist/react-native/customization/outputModels.d.ts +188 -37
  322. package/dist/react-native/customization/outputModels.d.ts.map +1 -1
  323. package/dist/react-native/customization/outputModels.js.map +1 -1
  324. package/dist/react-native/customization/streamingModels.d.ts +2 -1
  325. package/dist/react-native/customization/streamingModels.d.ts.map +1 -1
  326. package/dist/react-native/customization/streamingModels.js.map +1 -1
  327. package/dist/react-native/customization/streamingWireModels.d.ts +2 -1
  328. package/dist/react-native/customization/streamingWireModels.d.ts.map +1 -1
  329. package/dist/react-native/customization/streamingWireModels.js.map +1 -1
  330. package/dist/react-native/generated/src/models.d.ts +131 -150
  331. package/dist/react-native/generated/src/models.d.ts.map +1 -1
  332. package/dist/react-native/generated/src/models.js.map +1 -1
  333. package/dist/react-native/generated/src/outputModels.d.ts +187 -36
  334. package/dist/react-native/generated/src/outputModels.d.ts.map +1 -1
  335. package/dist/react-native/generated/src/outputModels.js.map +1 -1
  336. package/dist/react-native/generated/src/paginateHelper.d.ts +27 -2
  337. package/dist/react-native/generated/src/paginateHelper.d.ts.map +1 -1
  338. package/dist/react-native/generated/src/paginateHelper.js +98 -1
  339. package/dist/react-native/generated/src/paginateHelper.js.map +1 -1
  340. package/dist/react-native/generated/src/projectsClient.d.ts +2 -2
  341. package/dist/react-native/generated/src/projectsClient.d.ts.map +1 -1
  342. package/dist/react-native/generated/src/projectsClient.js +3 -3
  343. package/dist/react-native/generated/src/projectsClient.js.map +1 -1
  344. package/package.json +33 -34
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
@@ -69,7 +69,7 @@ Use the AI Projects client library (in preview) to:
69
69
  ### Install the package
70
70
 
71
71
  ```bash
72
- npm install @azure/ai-projects
72
+ npm install @azure/ai-projects @azure/identity
73
73
  ```
74
74
 
75
75
  ## Key concepts
@@ -78,14 +78,11 @@ npm install @azure/ai-projects
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();
@@ -440,9 +463,8 @@ const agent = await client.agents.createAgent("gpt-4-1106-preview", {
440
463
  });
441
464
  console.log(`Created agent, agent ID: ${agent.id}`);
442
465
 
443
- const thread = client.agents.createThread();
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" ||
@@ -479,47 +500,65 @@ To have the SDK poll on your behalf, use the `createThreadAndRun` method.
479
500
  Here is an example:
480
501
 
481
502
  ```javascript
482
- const run = await client.agents.createThreadAndRun(thread.id, agent.id);
503
+ const run = await client.agents.createThreadAndRun(agent.id, {
504
+ thread: {
505
+ messages: [
506
+ {
507
+ role: "user",
508
+ content: "hello, world!",
509
+ },
510
+ ],
511
+ },
512
+ });
483
513
  ```
484
514
 
485
515
  With streaming, polling also need not be considered.
486
516
 
487
517
  Here is an example:
488
518
 
489
- ```javascript
519
+ ```ts snippet:createRunStream
490
520
  const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream();
491
521
  ```
492
522
 
493
523
  Event handling can be done as follows:
494
524
 
495
- ```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();
496
536
  for await (const eventMessage of streamEventMessages) {
497
- switch (eventMessage.event) {
498
- case RunStreamEvent.ThreadRunCreated:
499
- console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`)
500
- break;
501
- case MessageStreamEvent.ThreadMessageDelta:
502
- {
503
- const messageDelta = eventMessage.data as MessageDeltaChunk;
504
- messageDelta.delta.content.forEach((contentPart) => {
505
- if (contentPart.type === "text") {
506
- const textContent = contentPart as MessageDeltaTextContent
507
- const textValue = textContent.text?.value || "No text"
508
- console.log(`Text delta received:: ${textValue}`)
509
- }
510
- });
511
- }
512
- break;
513
-
514
- case RunStreamEvent.ThreadRunCompleted:
515
- console.log("Thread Run Completed");
516
- break;
517
- case ErrorEvent.Error:
518
- console.log(`An error occurred. Data ${eventMessage.data}`);
519
- break;
520
- case DoneEvent.Done:
521
- console.log("Stream completed.");
522
- 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;
523
562
  }
524
563
  }
525
564
  ```
@@ -528,18 +567,30 @@ switch (eventMessage.event) {
528
567
 
529
568
  To retrieve messages from agents, use the following example:
530
569
 
531
- ```javascript
570
+ ```ts snippet:listMessages
571
+ import { MessageContentOutput, isOutputOfType, MessageTextContentOutput } from "../src/index.js";
572
+
532
573
  const messages = await client.agents.listMessages(thread.id);
574
+ while (messages.hasMore) {
575
+ const nextMessages = await client.agents.listMessages(currentRun.threadId, {
576
+ after: messages.lastId,
577
+ });
578
+ messages.data = messages.data.concat(nextMessages.data);
579
+ messages.hasMore = nextMessages.hasMore;
580
+ messages.lastId = nextMessages.lastId;
581
+ }
533
582
 
534
583
  // The messages are following in the reverse order,
535
584
  // we will iterate them and output only text contents.
536
585
  for (const dataPoint of messages.data.reverse()) {
537
- const lastMessageContent: MessageContentOutput = dataPoint.content[dataPoint.content.length - 1];
538
- console.log( lastMessageContent);
539
- if (isOutputOfType<MessageTextContentOutput>(lastMessageContent, "text")) {
540
- console.log(`${dataPoint.role}: ${(lastMessageContent as MessageTextContentOutput).text.value}`);
541
- }
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
+ );
542
592
  }
593
+ }
543
594
  ```
544
595
 
545
596
  ### Retrieve File
@@ -548,12 +599,29 @@ Files uploaded by Agents cannot be retrieved back. If your use case needs to acc
548
599
 
549
600
  Here is an example retrieving file ids from messages:
550
601
 
551
- ```javascript
602
+ ```ts snippet:retrieveFile
603
+ import {
604
+ isOutputOfType,
605
+ MessageTextContentOutput,
606
+ MessageImageFileContentOutput,
607
+ } from "../src/index.js";
608
+
552
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
+ }
553
620
  const imageFile = (messages.data[0].content[0] as MessageImageFileContentOutput).imageFile;
554
621
  const imageFileName = (await client.agents.getFile(imageFile.fileId)).filename;
555
-
556
- 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;
557
625
  if (fileContent) {
558
626
  const chunks: Buffer[] = [];
559
627
  for await (const chunk of fileContent) {
@@ -571,13 +639,11 @@ console.log(`Saved image file to: ${imageFileName}`);
571
639
 
572
640
  To remove resources after completing tasks, use the following functions:
573
641
 
574
- ```javascript
642
+ ```ts snippet:teardown
575
643
  await client.agents.deleteVectorStore(vectorStore.id);
576
644
  console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`);
577
-
578
645
  await client.agents.deleteFile(file.id);
579
646
  console.log(`Deleted file, file ID: ${file.id}`);
580
-
581
647
  client.agents.deleteAgent(agent.id);
582
648
  console.log(`Deleted agent, agent ID: ${agent.id}`);
583
649
  ```
@@ -611,39 +677,34 @@ npm install @opentelemetry/exporter-trace-otlp-proto \
611
677
 
612
678
  Here is a code sample to be included above `createAgent`:
613
679
 
614
- ```javascript
615
- import { trace } from "@opentelemetry/api";
616
- import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter"
680
+ ```ts snippet:tracing
617
681
  import {
618
- ConsoleSpanExporter,
619
- NodeTracerProvider,
620
- SimpleSpanProcessor,
682
+ NodeTracerProvider,
683
+ SimpleSpanProcessor,
684
+ ConsoleSpanExporter,
621
685
  } from "@opentelemetry/sdk-trace-node";
686
+ import { trace } from "@opentelemetry/api";
687
+ import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter";
622
688
 
623
689
  const provider = new NodeTracerProvider();
624
690
  provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
625
691
  provider.register();
626
-
627
692
  const tracer = trace.getTracer("Agents Sample", "1.0.0");
628
-
629
- const client = AIProjectsClient.fromConnectionString(
630
- connectionString || "", new DefaultAzureCredential()
631
- );
632
-
633
- if (!appInsightsConnectionString) {
693
+ let appInsightsConnectionString =
694
+ process.env.APP_INSIGHTS_CONNECTION_STRING ?? "<appInsightsConnectionString>";
695
+ if (appInsightsConnectionString == "<appInsightsConnectionString>") {
634
696
  appInsightsConnectionString = await client.telemetry.getConnectionString();
635
697
  }
636
-
637
698
  if (appInsightsConnectionString) {
638
699
  const exporter = new AzureMonitorTraceExporter({
639
- connectionString: appInsightsConnectionString
700
+ connectionString: appInsightsConnectionString,
640
701
  });
641
702
  provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
642
703
  }
643
-
644
704
  await tracer.startActiveSpan("main", async (span) => {
645
- client.telemetry.updateSettings({enableContentRecording: true})
646
- // ...
705
+ client.telemetry.updateSettings({ enableContentRecording: true });
706
+ // ...
707
+ });
647
708
  ```
648
709
 
649
710
  ## Troubleshooting
@@ -652,16 +713,18 @@ await tracer.startActiveSpan("main", async (span) => {
652
713
 
653
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:
654
715
 
655
- ```javascript
656
- import { RestError } from "@azure/core-rest-pipeline"
657
-
658
- // ...
716
+ ```ts snippet:exceptions
717
+ import { RestError } from "@azure/core-rest-pipeline";
659
718
 
660
719
  try {
661
720
  const result = await client.connections.listConnections();
662
- } catch (e as RestError) {
663
- console.log(`Status code: ${e.code}`);
664
- 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
+ }
665
728
  }
666
729
  ```
667
730
 
@@ -676,9 +739,9 @@ Operation returned an invalid status 'Unauthorized'
676
739
 
677
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)
678
741
 
679
- <!-- ## Next steps
742
+ ## Next steps
680
743
 
681
- 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.
682
745
 
683
746
  ## Contributing
684
747
 
@@ -699,8 +762,6 @@ additional questions or comments.
699
762
 
700
763
  <!-- LINKS -->
701
764
 
702
- <!-- [samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples -->
703
-
704
765
  [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
705
766
  [entra_id]: https://learn.microsoft.com/azure/ai-services/authentication?tabs=powershell#authenticate-with-microsoft-entra-id
706
767
  [azure_identity_npm]: https://www.npmjs.com/package/@azure/identity