Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assistant, Files, Foundation Models, Operation sdk and update for mono generated #178

Merged
merged 22 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: search clients
GermanVor committed Dec 24, 2024
commit 3137c86e631d44daa5408b70c9b1627fcbc9e326
10 changes: 6 additions & 4 deletions clients/ai-assistants-v1/sdk/assistantSdk.ts
Original file line number Diff line number Diff line change
@@ -64,8 +64,10 @@ export class AssistantWithSdk {
export class AssistantSdk {
private assistantClient: Client<typeof AssistantServiceService, ClientCallArgs>;

constructor(session: SessionArg) {
this.assistantClient = session.client(assistantService.AssistantServiceClient);
static ENDPOINT = 'assistant.api.cloud.yandex.net:443';

constructor(session: SessionArg, endpoint = AssistantSdk.ENDPOINT) {
this.assistantClient = session.client(assistantService.AssistantServiceClient, endpoint);
}

private static _withSdk(this: AssistantSdk, assistantP: Promise<Assistant>) {
@@ -134,6 +136,6 @@ export class AssistantSdk {
}
}

export const initAssistantSdk = (session: SessionArg) => {
return new AssistantSdk(session);
export const initAssistantSdk = (session: SessionArg, endpoint = AssistantSdk.ENDPOINT) => {
return new AssistantSdk(session, endpoint);
};
3 changes: 3 additions & 0 deletions clients/ai-assistants-v1/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -2,3 +2,6 @@ export * from './assistantSdk';
export * from './messageSdk';
export * from './runSdk';
export * from './threadSdk';
export * from './searchIndexFileSdk';
export * from './searchIndexSdk';
export * from './userSdk';
10 changes: 6 additions & 4 deletions clients/ai-assistants-v1/sdk/messageSdk.ts
Original file line number Diff line number Diff line change
@@ -18,8 +18,10 @@ export type ListMessagesProps = TypeFromProtoc<ListMessagesRequest, 'threadId'>;
export class MessageSdk {
private messageClient: Client<typeof MessageServiceService, ClientCallArgs>;

constructor(session: SessionArg) {
this.messageClient = session.client(messageService.MessageServiceClient);
static ENDPOINT = 'assistant.api.cloud.yandex.net:443';

constructor(session: SessionArg, endpoint = MessageSdk.ENDPOINT) {
this.messageClient = session.client(messageService.MessageServiceClient, endpoint);
}

static getMessageContent(...args: string[]): TypeFromProtoc<MessageContent> {
@@ -66,6 +68,6 @@ export class MessageSdk {
}
}

export const initMessageSdk = (session: SessionArg) => {
return new MessageSdk(session);
export const initMessageSdk = (session: SessionArg, endpoint = MessageSdk.ENDPOINT) => {
return new MessageSdk(session, endpoint);
};
10 changes: 6 additions & 4 deletions clients/ai-assistants-v1/sdk/runSdk.ts
Original file line number Diff line number Diff line change
@@ -46,8 +46,10 @@ export class RunWithSdk {
export class RunSdk {
private runClient: RunClientType;

constructor(session: SessionArg) {
this.runClient = session.client(runService.RunServiceClient);
static ENDPOINT = 'assistant.api.cloud.yandex.net:443';

constructor(session: SessionArg, endpoint = RunSdk.ENDPOINT) {
this.runClient = session.client(runService.RunServiceClient, endpoint);
}

private static _withSdk(this: RunSdk, runP: Promise<Run>) {
@@ -87,6 +89,6 @@ export class RunSdk {
}
}

export const initRunSdk = (session: SessionArg) => {
return new RunSdk(session);
export const initRunSdk = (session: SessionArg, endpoint = RunSdk.ENDPOINT) => {
return new RunSdk(session, endpoint);
};
63 changes: 63 additions & 0 deletions clients/ai-assistants-v1/sdk/searchIndexFileSdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Client } from 'nice-grpc';
import { searchIndexFileService } from '..';

import { ClientCallArgs, SessionArg, TypeFromProtoc } from './types';
import {
BatchCreateSearchIndexFileRequest,
GetSearchIndexFileRequest,
ListSearchIndexFilesRequest,
SearchIndexFileServiceService,
} from '../generated/yandex/cloud/ai/assistants/v1/searchindex/search_index_file_service';

export type CreateSearchIndexFileProps = TypeFromProtoc<
BatchCreateSearchIndexFileRequest,
'fileIds' | 'searchIndexId'
>;

export type GetSearchIndexFileProps = TypeFromProtoc<
GetSearchIndexFileRequest,
'fileId' | 'searchIndexId'
>;

export type ListSearchIndexFileProps = TypeFromProtoc<ListSearchIndexFilesRequest, 'searchIndexId'>;

export class SearchIndexFileSdk {
private searchIndexFileClient: Client<typeof SearchIndexFileServiceService, ClientCallArgs>;

static ENDPOINT = 'assistant.api.cloud.yandex.net:443';

constructor(session: SessionArg, endpoint = SearchIndexFileSdk.ENDPOINT) {
this.searchIndexFileClient = session.client(
searchIndexFileService.SearchIndexFileServiceClient,
endpoint,
);
}

batchCreate(params: CreateSearchIndexFileProps, args?: ClientCallArgs) {
return this.searchIndexFileClient.batchCreate(
searchIndexFileService.BatchCreateSearchIndexFileRequest.fromPartial(params),
args,
);
}

get(params: GetSearchIndexFileProps, args?: ClientCallArgs) {
return this.searchIndexFileClient.get(
searchIndexFileService.GetSearchIndexFileRequest.fromPartial(params),
args,
);
}

list(params: ListSearchIndexFileProps, args?: ClientCallArgs) {
return this.searchIndexFileClient.list(
searchIndexFileService.ListSearchIndexFilesRequest.fromPartial(params),
args,
);
}
}

export const initSearchIndexFileSdk = (
session: SessionArg,
endpoint = SearchIndexFileSdk.ENDPOINT,
) => {
return new SearchIndexFileSdk(session, endpoint);
};
80 changes: 80 additions & 0 deletions clients/ai-assistants-v1/sdk/searchIndexSdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Client } from 'nice-grpc';
import { searchIndexService } from '..';

import { ClientCallArgs, SessionArg, TypeFromProtoc } from './types';
import {
CreateSearchIndexRequest,
DeleteSearchIndexRequest,
GetSearchIndexRequest,
ListSearchIndicesRequest,
SearchIndexServiceService,
UpdateSearchIndexRequest,
} from '../generated/yandex/cloud/ai/assistants/v1/searchindex/search_index_service';

export type CreateSearchIndexProps = TypeFromProtoc<
CreateSearchIndexRequest,
'folderId' | 'fileIds'
>;

export type GetSearchIndexProps = TypeFromProtoc<GetSearchIndexRequest, 'searchIndexId'>;

export type ListSearchIndexProps = TypeFromProtoc<ListSearchIndicesRequest, 'folderId'>;

export type DeleteSearchIndexProps = TypeFromProtoc<DeleteSearchIndexRequest, 'searchIndexId'>;

export type UpdateSearchIndexProps = TypeFromProtoc<
UpdateSearchIndexRequest,
'searchIndexId' | 'updateMask'
>;

export class SearchIndexSdk {
private searchIndexClient: Client<typeof SearchIndexServiceService, ClientCallArgs>;

static ENDPOINT = 'assistant.api.cloud.yandex.net:443';

constructor(session: SessionArg, endpoint = SearchIndexSdk.ENDPOINT) {
this.searchIndexClient = session.client(
searchIndexService.SearchIndexServiceClient,
endpoint,
);
}

create(params: CreateSearchIndexProps, args?: ClientCallArgs) {
return this.searchIndexClient.create(
searchIndexService.CreateSearchIndexRequest.fromPartial(params),
args,
);
}

get(params: GetSearchIndexProps, args?: ClientCallArgs) {
return this.searchIndexClient.get(
searchIndexService.GetSearchIndexRequest.fromPartial(params),
args,
);
}

list(params: ListSearchIndexProps, args?: ClientCallArgs) {
return this.searchIndexClient.list(
searchIndexService.ListSearchIndicesRequest.fromPartial(params),
args,
);
}

delete(params: DeleteSearchIndexProps, args?: ClientCallArgs) {
return this.searchIndexClient.delete(
searchIndexService.DeleteSearchIndexRequest.fromPartial(params),
args,
);
}

update(params: UpdateSearchIndexProps, args?: ClientCallArgs) {
return this.searchIndexClient.update(
searchIndexService.UpdateSearchIndexRequest.fromPartial(params),
args,
);
}
}

export const initSearchIndexSdk = (session: SessionArg, endpoint = SearchIndexSdk.ENDPOINT) => {
return new SearchIndexSdk(session, endpoint);
};
10 changes: 6 additions & 4 deletions clients/ai-assistants-v1/sdk/threadSdk.ts
Original file line number Diff line number Diff line change
@@ -143,9 +143,11 @@ export class ThreadSdk {
private session: SessionArg;
private threadClient: Client<typeof ThreadServiceService, ClientCallArgs>;

constructor(session: SessionArg) {
static ENDPOINT = 'assistant.api.cloud.yandex.net:443';

constructor(session: SessionArg, endpoint = ThreadSdk.ENDPOINT) {
this.session = session;
this.threadClient = session.client(threadService.ThreadServiceClient);
this.threadClient = session.client(threadService.ThreadServiceClient, endpoint);
}

private static _withSdk(this: ThreadSdk, threadP: Promise<Thread>) {
@@ -194,6 +196,6 @@ export class ThreadSdk {
}
}

export const initThreadSdk = (session: SessionArg) => {
return new ThreadSdk(session);
export const initThreadSdk = (session: SessionArg, endpoint = ThreadSdk.ENDPOINT) => {
return new ThreadSdk(session, endpoint);
};
56 changes: 56 additions & 0 deletions clients/ai-assistants-v1/sdk/userSdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Client } from 'nice-grpc';
import { userService } from '..';

import { ClientCallArgs, SessionArg, TypeFromProtoc } from './types';
import {
CreateUserRequest,
DeleteUserRequest,
GetUserRequest,
ListUsersRequest,
UpdateUserRequest,
UserServiceService,
} from '../generated/yandex/cloud/ai/assistants/v1/users/user_service';

export type CreateUserProps = TypeFromProtoc<CreateUserRequest, 'folderId'>;

export type GetUserProps = TypeFromProtoc<GetUserRequest, 'userId'>;

export type ListUserProps = TypeFromProtoc<ListUsersRequest, 'folderId'>;

export type DeleteUserProps = TypeFromProtoc<DeleteUserRequest, 'userId'>;

export type UpdateUserProps = TypeFromProtoc<UpdateUserRequest, 'userId' | 'updateMask'>;

export class UserSdk {
private userClient: Client<typeof UserServiceService, ClientCallArgs>;

static ENDPOINT = 'assistant.api.cloud.yandex.net:443';

constructor(session: SessionArg, endpoint = UserSdk.ENDPOINT) {
this.userClient = session.client(userService.UserServiceClient, endpoint);
}

create(params: CreateUserProps, args?: ClientCallArgs) {
return this.userClient.create(userService.CreateUserRequest.fromPartial(params), args);
}

get(params: GetUserProps, args?: ClientCallArgs) {
return this.userClient.get(userService.GetUserRequest.fromPartial(params), args);
}

list(params: ListUserProps, args?: ClientCallArgs) {
return this.userClient.list(userService.ListUsersRequest.fromPartial(params), args);
}

delete(params: DeleteUserProps, args?: ClientCallArgs) {
return this.userClient.delete(userService.DeleteUserRequest.fromPartial(params), args);
}

update(params: UpdateUserProps, args?: ClientCallArgs) {
return this.userClient.update(userService.UpdateUserRequest.fromPartial(params), args);
}
}

export const initUserSdk = (session: SessionArg, endpoint = UserSdk.ENDPOINT) => {
return new UserSdk(session, endpoint);
};