Skip to content

Commit

Permalink
Move sdk/js to Axios (#9794)
Browse files Browse the repository at this point in the history
* Wrap 100

* add axios

* npm audit fix

* wip

* foo

* WIP axios DustAPI

* Better error logs

* working

* sdk 1.0.22-rc.0

* noop

* fix

* update some signatures:

* fix

* fixes

* version

* distinguish error message
  • Loading branch information
spolu authored Jan 9, 2025
1 parent 95f361c commit 7a79e4f
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 124 deletions.
3 changes: 2 additions & 1 deletion connectors/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions connectors/src/connectors/slack/auto_read_channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,14 @@ export async function autoReadChannel(
);
}

const patchData = {
parentsToAdd: [
slackChannelInternalIdFromSlackChannelId(channel.slackChannelId),
],
parentsToRemove: undefined,
};
const updateDataSourceViewRes = await dustAPI.patchDataSourceView(
dataSourceView,
patchData
{
parentsToAdd: [
slackChannelInternalIdFromSlackChannelId(channel.slackChannelId),
],
parentsToRemove: undefined,
}
);

if (updateDataSourceViewRes.isErr()) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/src/connectors/slack/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ async function answerMessage(
lastSlackChatBotMessage?.conversationId || null
);

const agentConfigurationsRes = await dustAPI.getAgentConfigurations();
const agentConfigurationsRes = await dustAPI.getAgentConfigurations({});
if (agentConfigurationsRes.isErr()) {
return new Err(new Error(agentConfigurationsRes.error.message));
}
Expand Down
19 changes: 9 additions & 10 deletions connectors/src/lib/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const MAX_DOCUMENT_TXT_LEN = 750000;
export const MAX_SMALL_DOCUMENT_TXT_LEN = 500000;
// For some data sources we allow large documents (5mb) to be processed (behind flag).
export const MAX_LARGE_DOCUMENT_TXT_LEN = 5000000;

export const MAX_FILE_SIZE_TO_DOWNLOAD = 128 * 1024 * 1024;

type UpsertContext = {
Expand Down Expand Up @@ -1252,15 +1251,15 @@ export async function _upsertDataSourceFolder({
}) {
const now = new Date();

const r = await getDustAPI(dataSourceConfig).upsertFolder(
dataSourceConfig.dataSourceId,
const r = await getDustAPI(dataSourceConfig).upsertFolder({
dataSourceId: dataSourceConfig.dataSourceId,
folderId,
timestampMs ? timestampMs : now.getTime(),
timestamp: timestampMs ? timestampMs : now.getTime(),
title,
parentId,
parents,
mimeType
);
mimeType,
});

if (r.isErr()) {
throw r.error;
Expand All @@ -1275,10 +1274,10 @@ export async function deleteDataSourceFolder({
folderId: string;
loggerArgs?: Record<string, string | number>;
}) {
const r = await getDustAPI(dataSourceConfig).deleteFolder(
dataSourceConfig.dataSourceId,
folderId
);
const r = await getDustAPI(dataSourceConfig).deleteFolder({
dataSourceId: dataSourceConfig.dataSourceId,
folderId,
});

if (r.isErr()) {
throw r.error;
Expand Down
3 changes: 2 additions & 1 deletion front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 41 additions & 12 deletions sdks/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sdks/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dust-tt/client",
"version": "1.0.21",
"version": "1.0.22",
"description": "Client for Dust API",
"repository": {
"type": "git",
Expand Down Expand Up @@ -40,6 +40,7 @@
"typescript": "^5.4.5"
},
"dependencies": {
"axios": "^1.7.9",
"eventsource-parser": "^1.1.1",
"moment-timezone": "^0.5.46",
"zod": "^3.23.8"
Expand Down
Loading

0 comments on commit 7a79e4f

Please sign in to comment.