Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(dcs): kill unused endpoints (#1604)

Eric Hayes7a4052ac103c
diff --git a/js/app/packages/service-clients/service-cognition/client.ts b/js/app/packages/service-clients/service-cognition/client.ts
index 344423978e..ef77a772e7 100644
--- a/js/app/packages/service-clients/service-cognition/client.ts
+++ b/js/app/packages/service-clients/service-cognition/client.ts
@@ -21,25 +21,17 @@ import type { GetBatchPreviewResponse } from './generated/schemas/getBatchPrevie
import type { GetChatPermissionsResponseV2 } from './generated/schemas/getChatPermissionsResponseV2';
import type { GetChatResponse } from './generated/schemas/getChatResponse';
import type { GetChatsForAttachmentResponse } from './generated/schemas/getChatsForAttachmentResponse';
-import type { GetModelsForAttachmentsRequest } from './generated/schemas/getModelsForAttachmentsRequest';
-import type { GetModelsForAttachmentsResponse } from './generated/schemas/getModelsForAttachmentsResponse';
-import type { GetModelsResponse } from './generated/schemas/getModelsResponse';
-import type { GetSimpleCompletionStreamPayload } from './generated/schemas/getSimpleCompletionStreamPayload';
import type { HttpSendChatMessageRequest } from './generated/schemas/httpSendChatMessageRequest';
import type { PatchChatRequestV2 } from './generated/schemas/patchChatRequestV2';
import type { SendChatMessageResponse } from './generated/schemas/sendChatMessageResponse';
-import type { SimpleCompletionResponse } from './generated/schemas/simpleCompletionResponse';
import type { StringIDResponse } from './generated/schemas/stringIDResponse';
import type { StructedOutputCompletionRequest } from './generated/schemas/structedOutputCompletionRequest';
import type { StructedOutputCompletionResponse } from './generated/schemas/structedOutputCompletionResponse';
import type { SuccessResponse } from './generated/schemas/successResponse';
-import type { VerifyAttachmentsRequest } from './generated/schemas/verifyAttachmentsRequest';
-import type { VerifyAttachmentsResponse } from './generated/schemas/verifyAttachmentsResponse';
const dcsHost: string = SERVER_HOSTS['cognition-service'];
type WithChatId = { chat_id: string };
-type WithDocumentId = { document_id: string };
type WithName = { name: string };
type WithProjectId = { project_id: string };
@@ -101,14 +93,6 @@ export const cognitionApiServiceClient = {
seconds: 5,
}
),
- async getModels() {
- return mapOk(
- await dcsFetch<GetModelsResponse>(`/models`, {
- method: 'GET',
- }),
- (result) => result
- );
- },
async editChatProject(args: WithChatId & WithProjectId) {
const { chat_id, project_id } = args;
@@ -216,15 +200,6 @@ export const cognitionApiServiceClient = {
(result) => result
);
},
- async upsertText(args: WithChatId & WithDocumentId & { content: string }) {
- const { content, document_id } = args;
- return await dcsFetch(`/document_text/${document_id}`, {
- method: 'POST',
- body: JSON.stringify({
- content: content,
- }),
- });
- },
async getChatsForAttachment(args: { attachment_id: string }) {
const { attachment_id } = args;
return mapOk(
@@ -237,17 +212,6 @@ export const cognitionApiServiceClient = {
(result) => result
);
},
- async verifyAttachments(args: VerifyAttachmentsRequest) {
- return mapOk(
- await dcsFetch<VerifyAttachmentsResponse>(`/attachments/verify`, {
- method: 'POST',
- body: JSON.stringify(args),
- }),
- (result) => {
- return result;
- }
- );
- },
getCitation: cache(
async function getCitation(args) {
@@ -281,18 +245,6 @@ export const cognitionApiServiceClient = {
(result) => result as { completion: any }
);
},
- async getModelsForAttachments(args: GetModelsForAttachmentsRequest) {
- return mapOk(
- await dcsFetch<GetModelsForAttachmentsResponse>(
- `/attachments/get_models_for_attachments`,
- {
- method: 'POST',
- body: JSON.stringify(args),
- }
- ),
- (result) => result
- );
- },
/** Send a chat message via HTTP stream API. Response chunks arrive via connection_gateway. */
async sendStreamChatMessage(args: HttpSendChatMessageRequest) {
@@ -304,15 +256,4 @@ export const cognitionApiServiceClient = {
(result) => result
);
},
-
- /** Start a simple completion via HTTP stream API. Response chunks arrive via connection_gateway. */
- async streamSimpleCompletion(args: GetSimpleCompletionStreamPayload) {
- return mapOk(
- await dcsFetch<SimpleCompletionResponse>(`/stream/completion/simple`, {
- method: 'POST',
- body: JSON.stringify(args),
- }),
- (result) => result
- );
- },
};
diff --git a/js/app/packages/service-clients/service-cognition/generated/client.ts b/js/app/packages/service-clients/service-cognition/generated/client.ts
index ed26b8dc46..1c900f132b 100644
--- a/js/app/packages/service-clients/service-cognition/generated/client.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/client.ts
@@ -8,9 +8,7 @@ import type {
ChatHistory,
ChatHistoryBatchMessagesRequest,
ChatMessageError,
- ChatsResponse,
CopyChatRequest,
- CreateTextRequestBody,
DocumentTextPart,
EmptyResponse,
GenericErrorResponse,
@@ -19,150 +17,15 @@ import type {
GetChatPermissionsResponseV2,
GetChatResponse,
GetChatsForAttachmentResponse,
- GetCompletionRequest,
- GetCompletionResponse,
- GetModelsForAttachmentsRequest,
- GetModelsForAttachmentsResponse,
GetModelsResponse,
- GetSimpleCompletionStreamPayload,
HttpSendChatMessageRequest,
SendChatMessageResponse,
- SimpleCompletionError,
- SimpleCompletionResponse,
StringIDResponse,
StructedOutputCompletionRequest,
StructedOutputCompletionResponse,
SuccessResponse,
- VerifyAttachmentsRequest,
- VerifyAttachmentsResponse,
} from './schemas';
-export type getModelsForAttachmentsHandlerResponse200 = {
- data: GetModelsForAttachmentsResponse;
- status: 200;
-};
-
-export type getModelsForAttachmentsHandlerResponse401 = {
- data: string;
- status: 401;
-};
-
-export type getModelsForAttachmentsHandlerResponse404 = {
- data: string;
- status: 404;
-};
-
-export type getModelsForAttachmentsHandlerResponse500 = {
- data: string;
- status: 500;
-};
-
-export type getModelsForAttachmentsHandlerResponseSuccess =
- getModelsForAttachmentsHandlerResponse200 & {
- headers: Headers;
- };
-export type getModelsForAttachmentsHandlerResponseError = (
- | getModelsForAttachmentsHandlerResponse401
- | getModelsForAttachmentsHandlerResponse404
- | getModelsForAttachmentsHandlerResponse500
-) & {
- headers: Headers;
-};
-
-export type getModelsForAttachmentsHandlerResponse =
- | getModelsForAttachmentsHandlerResponseSuccess
- | getModelsForAttachmentsHandlerResponseError;
-
-export const getGetModelsForAttachmentsHandlerUrl = () => {
- return `/attachments/get_models_for_attachments`;
-};
-
-export const getModelsForAttachmentsHandler = async (
- getModelsForAttachmentsRequest: GetModelsForAttachmentsRequest,
- options?: RequestInit
-): Promise<getModelsForAttachmentsHandlerResponse> => {
- const res = await fetch(getGetModelsForAttachmentsHandlerUrl(), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(getModelsForAttachmentsRequest),
- });
-
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
-
- const data: getModelsForAttachmentsHandlerResponse['data'] = body
- ? JSON.parse(body)
- : {};
- return {
- data,
- status: res.status,
- headers: res.headers,
- } as getModelsForAttachmentsHandlerResponse;
-};
-
-export type verifyAttachmentsHandlerResponse200 = {
- data: VerifyAttachmentsResponse;
- status: 200;
-};
-
-export type verifyAttachmentsHandlerResponse401 = {
- data: string;
- status: 401;
-};
-
-export type verifyAttachmentsHandlerResponse404 = {
- data: string;
- status: 404;
-};
-
-export type verifyAttachmentsHandlerResponse500 = {
- data: string;
- status: 500;
-};
-
-export type verifyAttachmentsHandlerResponseSuccess =
- verifyAttachmentsHandlerResponse200 & {
- headers: Headers;
- };
-export type verifyAttachmentsHandlerResponseError = (
- | verifyAttachmentsHandlerResponse401
- | verifyAttachmentsHandlerResponse404
- | verifyAttachmentsHandlerResponse500
-) & {
- headers: Headers;
-};
-
-export type verifyAttachmentsHandlerResponse =
- | verifyAttachmentsHandlerResponseSuccess
- | verifyAttachmentsHandlerResponseError;
-
-export const getVerifyAttachmentsHandlerUrl = () => {
- return `/attachments/verify`;
-};
-
-export const verifyAttachmentsHandler = async (
- verifyAttachmentsRequest: VerifyAttachmentsRequest,
- options?: RequestInit
-): Promise<verifyAttachmentsHandlerResponse> => {
- const res = await fetch(getVerifyAttachmentsHandlerUrl(), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(verifyAttachmentsRequest),
- });
-
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
-
- const data: verifyAttachmentsHandlerResponse['data'] = body
- ? JSON.parse(body)
- : {};
- return {
- data,
- status: res.status,
- headers: res.headers,
- } as verifyAttachmentsHandlerResponse;
-};
-
export type getChatsForAttachmentHandlerResponse200 = {
data: GetChatsForAttachmentResponse;
status: 200;
@@ -224,66 +87,6 @@ export const getChatsForAttachmentHandler = async (
} as getChatsForAttachmentHandlerResponse;
};
-/**
- * @summary Gets all the chats for a user
- */
-export type getChatsHandlerResponse200 = {
- data: ChatsResponse;
- status: 200;
-};
-
-export type getChatsHandlerResponse401 = {
- data: string;
- status: 401;
-};
-
-export type getChatsHandlerResponse404 = {
- data: string;
- status: 404;
-};
-
-export type getChatsHandlerResponse500 = {
- data: string;
- status: 500;
-};
-
-export type getChatsHandlerResponseSuccess = getChatsHandlerResponse200 & {
- headers: Headers;
-};
-export type getChatsHandlerResponseError = (
- | getChatsHandlerResponse401
- | getChatsHandlerResponse404
- | getChatsHandlerResponse500
-) & {
- headers: Headers;
-};
-
-export type getChatsHandlerResponse =
- | getChatsHandlerResponseSuccess
- | getChatsHandlerResponseError;
-
-export const getGetChatsHandlerUrl = () => {
- return `/chats`;
-};
-
-export const getChatsHandler = async (
- options?: RequestInit
-): Promise<getChatsHandlerResponse> => {
- const res = await fetch(getGetChatsHandlerUrl(), {
- ...options,
- method: 'GET',
- });
-
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
-
- const data: getChatsHandlerResponse['data'] = body ? JSON.parse(body) : {};
- return {
- data,
- status: res.status,
- headers: res.headers,
- } as getChatsHandlerResponse;
-};
-
export type createChatHandlerResponse201 = {
data: StringIDResponse;
status: 201;
@@ -827,75 +630,6 @@ export const getCitationHandler = async (
} as getCitationHandlerResponse;
};
-export type getCompletionHandlerResponse200 = {
- data: GetCompletionResponse;
- status: 200;
-};
-
-export type getCompletionHandlerResponse400 = {
- data: string;
- status: 400;
-};
-
-export type getCompletionHandlerResponse401 = {
- data: string;
- status: 401;
-};
-
-export type getCompletionHandlerResponse422 = {
- data: string;
- status: 422;
-};
-
-export type getCompletionHandlerResponse500 = {
- data: string;
- status: 500;
-};
-
-export type getCompletionHandlerResponseSuccess =
- getCompletionHandlerResponse200 & {
- headers: Headers;
- };
-export type getCompletionHandlerResponseError = (
- | getCompletionHandlerResponse400
- | getCompletionHandlerResponse401
- | getCompletionHandlerResponse422
- | getCompletionHandlerResponse500
-) & {
- headers: Headers;
-};
-
-export type getCompletionHandlerResponse =
- | getCompletionHandlerResponseSuccess
- | getCompletionHandlerResponseError;
-
-export const getGetCompletionHandlerUrl = () => {
- return `/completions/get_completion`;
-};
-
-export const getCompletionHandler = async (
- getCompletionRequest: GetCompletionRequest,
- options?: RequestInit
-): Promise<getCompletionHandlerResponse> => {
- const res = await fetch(getGetCompletionHandlerUrl(), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(getCompletionRequest),
- });
-
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
-
- const data: getCompletionHandlerResponse['data'] = body
- ? JSON.parse(body)
- : {};
- return {
- data,
- status: res.status,
- headers: res.headers,
- } as getCompletionHandlerResponse;
-};
-
export type handlerResponse200 = {
data: StructedOutputCompletionResponse;
status: 200;
@@ -950,66 +684,6 @@ export const handler = async (
return { data, status: res.status, headers: res.headers } as handlerResponse;
};
-export type upsertTextHandlerResponse201 = {
- data: void;
- status: 201;
-};
-
-export type upsertTextHandlerResponse401 = {
- data: string;
- status: 401;
-};
-
-export type upsertTextHandlerResponse404 = {
- data: string;
- status: 404;
-};
-
-export type upsertTextHandlerResponse500 = {
- data: string;
- status: 500;
-};
-
-export type upsertTextHandlerResponseSuccess = upsertTextHandlerResponse201 & {
- headers: Headers;
-};
-export type upsertTextHandlerResponseError = (
- | upsertTextHandlerResponse401
- | upsertTextHandlerResponse404
- | upsertTextHandlerResponse500
-) & {
- headers: Headers;
-};
-
-export type upsertTextHandlerResponse =
- | upsertTextHandlerResponseSuccess
- | upsertTextHandlerResponseError;
-
-export const getUpsertTextHandlerUrl = () => {
- return `/document_text/:document_id`;
-};
-
-export const upsertTextHandler = async (
- createTextRequestBody: CreateTextRequestBody,
- options?: RequestInit
-): Promise<upsertTextHandlerResponse> => {
- const res = await fetch(getUpsertTextHandlerUrl(), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(createTextRequestBody),
- });
-
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
-
- const data: upsertTextHandlerResponse['data'] = body ? JSON.parse(body) : {};
- return {
- data,
- status: res.status,
- headers: res.headers,
- } as upsertTextHandlerResponse;
-};
-
/**
* @summary Health check
*/
@@ -1201,65 +875,6 @@ export const sendChatMessage = async (
} as sendChatMessageResponse;
};
-/**
- * This endpoint initiates a completion and streams the response via the stream service.
-The client should subscribe to the completion_id stream via connection_gateway to receive chunks.
- * @summary Start a simple completion stream.
- */
-export type simpleCompletionResponse200 = {
- data: SimpleCompletionResponse;
- status: 200;
-};
-
-export type simpleCompletionResponse400 = {
- data: SimpleCompletionError;
- status: 400;
-};
-
-export type simpleCompletionResponse401 = {
- data: void;
- status: 401;
-};
-
-export type simpleCompletionResponseSuccess = simpleCompletionResponse200 & {
- headers: Headers;
-};
-export type simpleCompletionResponseError = (
- | simpleCompletionResponse400
- | simpleCompletionResponse401
-) & {
- headers: Headers;
-};
-
-export type simpleCompletionResponse =
- | simpleCompletionResponseSuccess
- | simpleCompletionResponseError;
-
-export const getSimpleCompletionUrl = () => {
- return `/stream/completion/simple`;
-};
-
-export const simpleCompletion = async (
- getSimpleCompletionStreamPayload: GetSimpleCompletionStreamPayload,
- options?: RequestInit
-): Promise<simpleCompletionResponse> => {
- const res = await fetch(getSimpleCompletionUrl(), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(getSimpleCompletionStreamPayload),
- });
-
- const body = [204, 205, 304].includes(res.status) ? null : await res.text();
-
- const data: simpleCompletionResponse['data'] = body ? JSON.parse(body) : {};
- return {
- data,
- status: res.status,
- headers: res.headers,
- } as simpleCompletionResponse;
-};
-
/**
* @summary Gets the current chat share permissions
*/
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatsResponse.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatsResponse.ts
deleted file mode 100644
index 56de12f3d4..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatsResponse.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { Chat } from './chat';
-
-export interface ChatsResponse {
- chats: Chat[];
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/createTextRequestBody.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/createTextRequestBody.ts
deleted file mode 100644
index ac8dec3bb7..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/createTextRequestBody.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-export interface CreateTextRequestBody {
- content: string;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/createTextRequestParams.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/createTextRequestParams.ts
deleted file mode 100644
index 923534ea73..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/createTextRequestParams.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-export interface CreateTextRequestParams {
- document_id: string;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequest.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequest.ts
deleted file mode 100644
index 02c1e0ee12..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequest.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { GetCompletionRequestMaxTokens } from './getCompletionRequestMaxTokens';
-import type { GetCompletionRequestModel } from './getCompletionRequestModel';
-
-export interface GetCompletionRequest {
- /** @minimum 0 */
- max_tokens?: GetCompletionRequestMaxTokens;
- model?: GetCompletionRequestModel;
- prompt: string;
- user_message: string;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequestMaxTokens.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequestMaxTokens.ts
deleted file mode 100644
index 1b6c204e93..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequestMaxTokens.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-/**
- * @minimum 0
- */
-export type GetCompletionRequestMaxTokens = number | null;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequestModel.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequestModel.ts
deleted file mode 100644
index c9161f9e4e..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionRequestModel.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { Model } from './model';
-
-export type GetCompletionRequestModel = null | Model;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionResponse.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionResponse.ts
deleted file mode 100644
index 8c5d915305..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getCompletionResponse.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-export interface GetCompletionResponse {
- completion: string;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsRequest.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsRequest.ts
deleted file mode 100644
index 6ee85d08eb..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsRequest.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { GetModelsForAttachmentsRequestActiveModel } from './getModelsForAttachmentsRequestActiveModel';
-import type { NewAttachment } from './newAttachment';
-
-export interface GetModelsForAttachmentsRequest {
- active_model?: GetModelsForAttachmentsRequestActiveModel;
- attachments: NewAttachment[];
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsRequestActiveModel.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsRequestActiveModel.ts
deleted file mode 100644
index 5eebca720f..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsRequestActiveModel.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { Model } from './model';
-
-export type GetModelsForAttachmentsRequestActiveModel = null | Model;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsResponse.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsResponse.ts
deleted file mode 100644
index fe20741cb9..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsResponse.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-import type { GetModelsForAttachmentsResponseNewModel } from './getModelsForAttachmentsResponseNewModel';
-import type { Model } from './model';
-
-export interface GetModelsForAttachmentsResponse {
- available_models: Model[];
- new_model?: GetModelsForAttachmentsResponseNewModel;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsResponseNewModel.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsResponseNewModel.ts
deleted file mode 100644
index bcbb9431b8..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getModelsForAttachmentsResponseNewModel.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { Model } from './model';
-
-export type GetModelsForAttachmentsResponseNewModel = null | Model;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayload.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayload.ts
deleted file mode 100644
index 322468036c..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayload.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { GetSimpleCompletionStreamPayloadContentDocumentIds } from './getSimpleCompletionStreamPayloadContentDocumentIds';
-import type { GetSimpleCompletionStreamPayloadMaxTokens } from './getSimpleCompletionStreamPayloadMaxTokens';
-import type { GetSimpleCompletionStreamPayloadModel } from './getSimpleCompletionStreamPayloadModel';
-
-export interface GetSimpleCompletionStreamPayload {
- /** client provided id, returned in responses */
- completion_id: string;
- /** Optional document ID to provide context */
- content_document_ids?: GetSimpleCompletionStreamPayloadContentDocumentIds;
- /**
- * max tokens
- * @minimum 0
- */
- max_tokens?: GetSimpleCompletionStreamPayloadMaxTokens;
- /** model to use for the completion */
- model?: GetSimpleCompletionStreamPayloadModel;
- /** system prompt */
- prompt: string;
- /** user request */
- user_request: string;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadContentDocumentIds.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadContentDocumentIds.ts
deleted file mode 100644
index 5e892ed7dc..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadContentDocumentIds.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-/**
- * Optional document ID to provide context
- */
-export type GetSimpleCompletionStreamPayloadContentDocumentIds =
- | string[]
- | null;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadMaxTokens.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadMaxTokens.ts
deleted file mode 100644
index fa26102bca..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadMaxTokens.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-/**
- * max tokens
- * @minimum 0
- */
-export type GetSimpleCompletionStreamPayloadMaxTokens = number | null;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadModel.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadModel.ts
deleted file mode 100644
index 25ee0e3baf..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/getSimpleCompletionStreamPayloadModel.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-/**
- * model to use for the completion
- */
-export type GetSimpleCompletionStreamPayloadModel = string | null;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/index.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/index.ts
index f2fa0d5267..ed05d2ffa6 100644
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/index.ts
@@ -102,7 +102,6 @@ export * from './chatStreamOneOfTwoseven';
export * from './chatStreamOneOfTwosevenType';
export * from './chatStreamOneOfTwothree';
export * from './chatStreamOneOfTwothreeType';
-export * from './chatsResponse';
export * from './chatTokenCount';
export * from './chatUpdatedAt';
export * from './conversationRecord';
@@ -113,8 +112,6 @@ export * from './createChatRequestIsPersistent';
export * from './createChatRequestModel';
export * from './createChatRequestName';
export * from './createChatRequestProjectId';
-export * from './createTextRequestBody';
-export * from './createTextRequestParams';
export * from './documentCognitionServiceApiVersion';
export * from './documentReference';
export * from './documentReferenceOneOf';
@@ -141,19 +138,7 @@ export * from './getChatPermissionsResponseV2';
export * from './getChatResponse';
export * from './getChatsForAttachmentResponse';
export * from './getChatsForAttachmentResponseRecentChat';
-export * from './getCompletionRequest';
-export * from './getCompletionRequestMaxTokens';
-export * from './getCompletionRequestModel';
-export * from './getCompletionResponse';
-export * from './getModelsForAttachmentsRequest';
-export * from './getModelsForAttachmentsRequestActiveModel';
-export * from './getModelsForAttachmentsResponse';
-export * from './getModelsForAttachmentsResponseNewModel';
export * from './getModelsResponse';
-export * from './getSimpleCompletionStreamPayload';
-export * from './getSimpleCompletionStreamPayloadContentDocumentIds';
-export * from './getSimpleCompletionStreamPayloadMaxTokens';
-export * from './getSimpleCompletionStreamPayloadModel';
export * from './httpSendChatMessageRequest';
export * from './httpSendChatMessageRequestAdditionalInstructions';
export * from './httpSendChatMessageRequestAttachments';
@@ -186,9 +171,6 @@ export * from './sendChatMessageResponse';
export * from './sharePermissionV2';
export * from './sharePermissionV2ChannelSharePermissions';
export * from './sharePermissionV2PublicAccessLevel';
-export * from './simpleCompletionError';
-export * from './simpleCompletionErrorCompletionId';
-export * from './simpleCompletionResponse';
export * from './streamError';
export * from './streamErrorOneOf';
export * from './streamErrorOneOfFive';
@@ -215,6 +197,4 @@ export * from './updateSharePermissionRequestV2ChannelSharePermissions';
export * from './updateSharePermissionRequestV2IsPublic';
export * from './updateSharePermissionRequestV2PublicAccessLevel';
export * from './userPdfRect';
-export * from './verifyAttachmentsRequest';
-export * from './verifyAttachmentsResponse';
export * from './withChatId';
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionError.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionError.ts
deleted file mode 100644
index 1c2e659c72..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionError.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-import type { SimpleCompletionErrorCompletionId } from './simpleCompletionErrorCompletionId';
-
-/**
- * Error response for simple completion endpoint
- */
-export interface SimpleCompletionError {
- completion_id?: SimpleCompletionErrorCompletionId;
- error: string;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionErrorCompletionId.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionErrorCompletionId.ts
deleted file mode 100644
index d37024ca2f..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionErrorCompletionId.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-export type SimpleCompletionErrorCompletionId = string | null;
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionResponse.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionResponse.ts
deleted file mode 100644
index 05345f91d8..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/simpleCompletionResponse.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-/**
- * Response for initiating a simple completion stream
- */
-export interface SimpleCompletionResponse {
- /** The completion ID that will receive the response chunks */
- completion_id: string;
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/verifyAttachmentsRequest.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/verifyAttachmentsRequest.ts
deleted file mode 100644
index 0cf7763c15..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/verifyAttachmentsRequest.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-export interface VerifyAttachmentsRequest {
- attachments: string[];
-}
diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/verifyAttachmentsResponse.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/verifyAttachmentsResponse.ts
deleted file mode 100644
index f17b75f9cf..0000000000
--- a/js/app/packages/service-clients/service-cognition/generated/schemas/verifyAttachmentsResponse.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * Document Cognition Service
- * OpenAPI spec version: 1.0.0
- */
-
-export interface VerifyAttachmentsResponse {
- attachments: string[];
-}
diff --git a/js/app/packages/service-clients/service-cognition/openapi.json b/js/app/packages/service-clients/service-cognition/openapi.json
index cdc5dfbad5..012fbad103 100644
--- a/js/app/packages/service-clients/service-cognition/openapi.json
+++ b/js/app/packages/service-clients/service-cognition/openapi.json
@@ -11,122 +11,6 @@
"version": "1.0.0"
},
"paths": {
- "/attachments/get_models_for_attachments": {
- "post": {
- "tags": ["get_models_for_attachments"],
- "operationId": "get_models_for_attachments_handler",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GetModelsForAttachmentsRequest"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GetModelsForAttachmentsResponse"
- }
- }
- }
- },
- "401": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "404": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "500": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- }
- }
- }
- },
- "/attachments/verify": {
- "post": {
- "tags": ["verify_attachments"],
- "operationId": "verify_attachments_handler",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/VerifyAttachmentsRequest"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/VerifyAttachmentsResponse"
- }
- }
- }
- },
- "401": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "404": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "500": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- }
- }
- }
- },
"/attachments/{attachment_id}/chats": {
"get": {
"tags": ["get_chats_for_attachment"],
@@ -187,53 +71,6 @@
}
},
"/chats": {
- "get": {
- "tags": ["get_chats"],
- "summary": "Gets all the chats for a user",
- "operationId": "get_chats_handler",
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ChatsResponse"
- }
- }
- }
- },
- "401": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "404": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "500": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- }
- }
- },
"post": {
"tags": ["create_user_chat"],
"operationId": "create_chat_handler",
@@ -746,74 +583,6 @@
}
}
},
- "/completions/get_completion": {
- "post": {
- "tags": ["get_completion"],
- "operationId": "get_completion_handler",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GetCompletionRequest"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GetCompletionResponse"
- }
- }
- }
- },
- "400": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "401": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "422": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "500": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- }
- }
- }
- },
"/completions/structured_output": {
"post": {
"tags": ["structured_output"],
@@ -872,68 +641,6 @@
}
}
},
- "/document_text/:document_id": {
- "post": {
- "tags": ["upsert_document_text"],
- "operationId": "upsert_text_handler",
- "parameters": [
- {
- "name": "document_id",
- "in": "path",
- "description": "Id of the document to create text for",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/CreateTextRequestBody"
- }
- }
- },
- "required": true
- },
- "responses": {
- "201": {
- "description": ""
- },
- "401": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "404": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- },
- "500": {
- "description": "",
- "content": {
- "text/plain": {
- "schema": {
- "type": "string"
- }
- }
- }
- }
- }
- }
- },
"/health": {
"get": {
"tags": ["health"],
@@ -1066,49 +773,6 @@
}
}
},
- "/stream/completion/simple": {
- "post": {
- "tags": ["simple_completion"],
- "summary": "Start a simple completion stream.",
- "description": "This endpoint initiates a completion and streams the response via the stream service.\nThe client should subscribe to the completion_id stream via connection_gateway to receive chunks.",
- "operationId": "simple_completion",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/GetSimpleCompletionStreamPayload"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Stream initiated successfully",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/SimpleCompletionResponse"
- }
- }
- }
- },
- "400": {
- "description": "Bad request",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/SimpleCompletionError"
- }
- }
- }
- },
- "401": {
- "description": "Unauthorized"
- }
- }
- }
- },
"/v2/chats/{chat_id}/permissions": {
"get": {
"tags": ["get_chat_permissions"],
@@ -2054,18 +1718,6 @@
}
]
},
- "ChatsResponse": {
- "type": "object",
- "required": ["chats"],
- "properties": {
- "chats": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Chat"
- }
- }
- }
- },
"ConversationRecord": {
"type": "object",
"required": ["chat_id", "title", "messages"],
@@ -2123,24 +1775,6 @@
}
}
},
- "CreateTextRequestBody": {
- "type": "object",
- "required": ["content"],
- "properties": {
- "content": {
- "type": "string"
- }
- }
- },
- "CreateTextRequestParams": {
- "type": "object",
- "required": ["document_id"],
- "properties": {
- "document_id": {
- "type": "string"
- }
- }
- },
"DocumentCognitionServiceApiVersion": {
"type": "string",
"enum": ["v1", "v2"]
@@ -2385,86 +2019,6 @@
}
}
},
- "GetCompletionRequest": {
- "type": "object",
- "required": ["prompt", "user_message"],
- "properties": {
- "max_tokens": {
- "type": ["integer", "null"],
- "format": "int32",
- "minimum": 0
- },
- "model": {
- "oneOf": [
- {
- "type": "null"
- },
- {
- "$ref": "#/components/schemas/Model"
- }
- ]
- },
- "prompt": {
- "type": "string"
- },
- "user_message": {
- "type": "string"
- }
- }
- },
- "GetCompletionResponse": {
- "type": "object",
- "required": ["completion"],
- "properties": {
- "completion": {
- "type": "string"
- }
- }
- },
- "GetModelsForAttachmentsRequest": {
- "type": "object",
- "required": ["attachments"],
- "properties": {
- "active_model": {
- "oneOf": [
- {
- "type": "null"
- },
- {
- "$ref": "#/components/schemas/Model"
- }
- ]
- },
- "attachments": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/NewAttachment"
- }
- }
- }
- },
- "GetModelsForAttachmentsResponse": {
- "type": "object",
- "required": ["available_models"],
- "properties": {
- "available_models": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Model"
- }
- },
- "new_model": {
- "oneOf": [
- {
- "type": "null"
- },
- {
- "$ref": "#/components/schemas/Model"
- }
- ]
- }
- }
- },
"GetModelsResponse": {
"type": "object",
"required": ["models"],
@@ -2477,41 +2031,6 @@
}
}
},
- "GetSimpleCompletionStreamPayload": {
- "type": "object",
- "required": ["prompt", "user_request", "completion_id"],
- "properties": {
- "completion_id": {
- "type": "string",
- "description": "client provided id, returned in responses"
- },
- "content_document_ids": {
- "type": ["array", "null"],
- "items": {
- "type": "string"
- },
- "description": "Optional document ID to provide context"
- },
- "max_tokens": {
- "type": ["integer", "null"],
- "format": "int32",
- "description": "max tokens",
- "minimum": 0
- },
- "model": {
- "type": ["string", "null"],
- "description": "model to use for the completion"
- },
- "prompt": {
- "type": "string",
- "description": "system prompt"
- },
- "user_request": {
- "type": "string",
- "description": "user request"
- }
- }
- },
"HttpSendChatMessageRequest": {
"type": "object",
"description": "HTTP request payload for sending a chat message.\nUnlike the WebSocket payload, this does not include stream_id as it's generated server-side.",
@@ -2816,30 +2335,6 @@
}
}
},
- "SimpleCompletionError": {
- "type": "object",
- "description": "Error response for simple completion endpoint",
- "required": ["error"],
- "properties": {
- "completion_id": {
- "type": ["string", "null"]
- },
- "error": {
- "type": "string"
- }
- }
- },
- "SimpleCompletionResponse": {
- "type": "object",
- "description": "Response for initiating a simple completion stream",
- "required": ["completion_id"],
- "properties": {
- "completion_id": {
- "type": "string",
- "description": "The completion ID that will receive the response chunks"
- }
- }
- },
"StreamError": {
"oneOf": [
{
@@ -3068,30 +2563,6 @@
}
}
},
- "VerifyAttachmentsRequest": {
- "type": "object",
- "required": ["attachments"],
- "properties": {
- "attachments": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- }
- },
- "VerifyAttachmentsResponse": {
- "type": "object",
- "required": ["attachments"],
- "properties": {
- "attachments": {
- "type": "array",
- "items": {
- "type": "string"
- }
- }
- }
- },
"WithChatId": {
"type": "object",
"required": ["chat_id"],
diff --git a/rust/cloud-storage/ai_tools/src/read.rs b/rust/cloud-storage/ai_tools/src/read.rs
index 8252b3450a..a23b976c60 100644
--- a/rust/cloud-storage/ai_tools/src/read.rs
+++ b/rust/cloud-storage/ai_tools/src/read.rs
@@ -359,7 +359,7 @@ impl Read {
let id = self.provide_single_id()?;
let history = scribe
.chat
- .get_chat_history(&id, Some(&*request_context.jwt))
+ .get_chat_history(&id, &request_context.jwt)
.await
.map_err(|e| ToolCallError {
description: format!("failed to fetch chat thread: {}", e),
@@ -379,7 +379,7 @@ impl Read {
let history = scribe
.chat
- .get_chat_history_for_messages(message_ids, Some(&*request_context.jwt))
+ .get_chat_history_for_messages(message_ids, &request_context.jwt)
.await
.map_err(|e| ToolCallError {
description: format!("failed to fetch chat messages: {}", e),
diff --git a/rust/cloud-storage/document_cognition_service/src/api/attachments/get_models_for_attachments.rs b/rust/cloud-storage/document_cognition_service/src/api/attachments/get_models_for_attachments.rs
deleted file mode 100644
index 71961e0d86..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/attachments/get_models_for_attachments.rs
+++ /dev/null
@@ -1,123 +0,0 @@
-use crate::{
- api::context::ApiContext,
- core::{
- constants::{
- DEFAULT_CHANNEL_TOKENS, DEFAULT_EMAIL_TOKENS, DEFAULT_IMAGE_TOKENS,
- DEFAULT_PROJECT_TOKENS,
- },
- model::CHAT_MODELS,
- },
- model::request::chats::NewAttachment,
- service::attachment::document::get_document_token_count,
-};
-
-use ai::{model_selection::select_model, types::Model};
-use anyhow::Result;
-use axum::{Extension, Json, extract::State, http::StatusCode, response::IntoResponse};
-use macro_middleware::cloud_storage::ensure_access::get_users_access_level_v2;
-use model::chat::AttachmentType;
-use model::user::UserContext;
-use serde::{Deserialize, Serialize};
-use utoipa::ToSchema;
-
-#[derive(Serialize, ToSchema)]
-pub struct GetModelsForAttachmentsResponse {
- pub available_models: Vec<Model>,
- pub new_model: Option<Model>,
-}
-
-#[derive(Deserialize, Serialize, Debug, ToSchema)]
-pub struct GetModelsForAttachmentsRequest {
- pub attachments: Vec<NewAttachment>,
- pub active_model: Option<Model>,
-}
-
-#[utoipa::path(
- post,
- path = "/attachments/get_models_for_attachments",
- responses(
- (status = 200, body=GetModelsForAttachmentsResponse),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- ),
- )]
-#[tracing::instrument(err(Debug), skip(state, user_context))]
-pub async fn get_models_for_attachments_handler(
- State(state): State<ApiContext>,
- user_context: Extension<UserContext>,
- req: Json<GetModelsForAttachmentsRequest>,
-) -> Result<impl IntoResponse, (StatusCode, String)> {
- let mut attachment_tokens = 0;
- for attachment in &req.attachments {
- if attachment.attachment_type == AttachmentType::Document {
- get_users_access_level_v2(
- &state.db,
- &user_context.user_id,
- &attachment.attachment_id,
- "document",
- )
- .await
- .map_err(|err| {
- tracing::error!(error = ?err, user_id = %user_context.user_id, attachment_id = %attachment.attachment_id, attachment_type = "document", "failed to check document access level");
- err
- })?
- .ok_or_else(|| (StatusCode::UNAUTHORIZED, "permission".to_string()))?;
- } else if attachment.attachment_type == AttachmentType::Channel {
- get_users_access_level_v2(
- &state.db,
- &user_context.user_id,
- &attachment.attachment_id,
- "channel",
- )
- .await
- .map_err(|err| {
- tracing::error!(error = ?err, user_id = %user_context.user_id, attachment_id = %attachment.attachment_id, attachment_type = "channel", "failed to check channel access level");
- err
- })?
- .ok_or_else(|| (StatusCode::UNAUTHORIZED, "permission".to_string()))?;
- }
- }
-
- // computer virus
- for attachment in &req.attachments {
- let token_count =
- match attachment.attachment_type {
- AttachmentType::Project => {
- DEFAULT_PROJECT_TOKENS
- }
- AttachmentType::Document => {
- get_document_token_count(&state, attachment.attachment_id.as_str())
- .await
- .map_err(|err: anyhow::Error| {
- tracing::error!(error = %err, attachment_id = %attachment.attachment_id, "failed to get document token count");
- (StatusCode::NOT_FOUND, "could not find data for attachment id".to_string())
- })?
- }
- AttachmentType::Image => {
- DEFAULT_IMAGE_TOKENS
- }
- AttachmentType::Channel => {
- DEFAULT_CHANNEL_TOKENS
- }
- AttachmentType::Email => {
- DEFAULT_EMAIL_TOKENS
- }
- };
- attachment_tokens += token_count;
- }
- let models =
- select_model(req.active_model, attachment_tokens, CHAT_MODELS.to_vec()).map_err(|err| {
- tracing::error!(error = %err, attachment_tokens = attachment_tokens, "failed to select model");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "internal server error".to_string(),
- )
- })?;
- Ok(Json::<GetModelsForAttachmentsResponse>(
- GetModelsForAttachmentsResponse {
- available_models: models.available_models,
- new_model: models.new_model,
- },
- ))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/attachments/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/attachments/mod.rs
index 016594f644..ba79e56590 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/attachments/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/attachments/mod.rs
@@ -1,40 +1,17 @@
pub mod get_chats_for_attachment;
-pub mod get_models_for_attachments;
-pub mod verify_attachments;
-use axum::{
- Router,
- routing::{get, post},
-};
+use axum::{Router, routing::get};
use tower::ServiceBuilder;
-use crate::api::{
- attachments::get_models_for_attachments::get_models_for_attachments_handler,
- context::ApiContext,
-};
+use crate::api::context::ApiContext;
pub fn router() -> Router<ApiContext> {
- Router::new()
- .route(
- "/:attachment_id/chats",
- get(get_chats_for_attachment::get_chats_for_attachment_handler).layer(
- ServiceBuilder::new().layer(axum::middleware::from_fn(
- macro_middleware::auth::ensure_user_exists::handler,
- )),
- ),
- )
- .route(
- "/verify",
- post(verify_attachments::verify_attachments_handler).layer(
- ServiceBuilder::new().layer(axum::middleware::from_fn(
- macro_middleware::auth::ensure_user_exists::handler,
- )),
- ),
- )
- .route(
- "/get_models_for_attachments",
- post(get_models_for_attachments_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
+ Router::new().route(
+ "/:attachment_id/chats",
+ get(get_chats_for_attachment::get_chats_for_attachment_handler).layer(
+ ServiceBuilder::new().layer(axum::middleware::from_fn(
+ macro_middleware::auth::ensure_user_exists::handler,
)),
- )
+ ),
+ )
}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/attachments/verify_attachments.rs b/rust/cloud-storage/document_cognition_service/src/api/attachments/verify_attachments.rs
deleted file mode 100644
index 233f9fc639..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/attachments/verify_attachments.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-use axum::{
- extract::{Json, State},
- http::StatusCode,
-};
-use macro_db_client::dcs::batch_verify::batch_verify;
-use sqlx::PgPool;
-use utoipa::ToSchema;
-
-#[derive(serde::Serialize, serde::Deserialize, Debug, ToSchema)]
-pub struct VerifyAttachmentsRequest {
- pub attachments: Vec<String>,
-}
-#[derive(serde::Serialize, serde::Deserialize, Debug, ToSchema)]
-pub struct VerifyAttachmentsResponse {
- pub attachments: Vec<String>,
-}
-
-#[tracing::instrument(skip(db))]
-#[utoipa::path(
- post,
- path = "/attachments/verify",
- responses(
- (status = 200, body=VerifyAttachmentsResponse),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- )
- )]
-pub async fn verify_attachments_handler(
- State(db): State<PgPool>,
- req: Json<VerifyAttachmentsRequest>,
-) -> Result<(StatusCode, Json<VerifyAttachmentsResponse>), (StatusCode, String)> {
- let attachments = batch_verify(&db, &req.attachments).await.map_err(|e| {
- tracing::error!(error = %e, "unable to verify attachments");
- (StatusCode::INTERNAL_SERVER_ERROR, e.to_string())
- })?;
-
- Ok((
- StatusCode::OK,
- Json(VerifyAttachmentsResponse { attachments }),
- ))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/chats/get_chats.rs b/rust/cloud-storage/document_cognition_service/src/api/chats/get_chats.rs
deleted file mode 100644
index 8af5bc0cde..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/chats/get_chats.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-use crate::model::chats::ChatsResponse;
-use axum::extract::State;
-use axum::{Extension, Json, http::StatusCode, response::IntoResponse};
-use macro_db_client::dcs::get_chats::get_chats;
-use model::user::UserContext;
-use sqlx::PgPool;
-
-/// Gets all the chats for a user
-#[utoipa::path(
- get,
- path = "/chats",
- responses(
- (status = 200, body=ChatsResponse),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- )
- )]
-#[tracing::instrument(skip(db, user_context), fields(user_id=?user_context.user_id))]
-pub async fn get_chats_handler(
- State(db): State<PgPool>,
- user_context: Extension<UserContext>,
-) -> impl IntoResponse {
- let chats = match get_chats(&db, &user_context.user_id).await {
- Ok(chats) => chats,
- Err(err) => {
- tracing::error!(error=%err, user_id=%user_context.user_id, "unable to get chats");
- return (StatusCode::INTERNAL_SERVER_ERROR, "unable to get chats").into_response();
- }
- };
-
- (StatusCode::OK, Json(&chats)).into_response()
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/chats/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/chats/mod.rs
index 6e783d7481..237ddaa46a 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/chats/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/chats/mod.rs
@@ -5,7 +5,6 @@ pub mod create_user_chat;
pub mod delete_chat;
pub mod get_chat;
pub mod get_chat_permissions;
-pub mod get_chats;
pub mod patch_chat;
pub mod revert_delete_chat;
@@ -51,12 +50,6 @@ pub fn router(state: ApiContext) -> Router<ApiContext> {
.layer(ensure_chat_exists.clone()),
),
)
- .route(
- "/",
- get(get_chats::get_chats_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
.route(
"/:chat_id",
get(get_chat::get_chat_handler)
diff --git a/rust/cloud-storage/document_cognition_service/src/api/completions/get_completion.rs b/rust/cloud-storage/document_cognition_service/src/api/completions/get_completion.rs
deleted file mode 100644
index b52043e6d2..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/completions/get_completion.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-use ai::chat_completion::get_chat_completion;
-use ai::types::{ChatCompletionError, MessageBuilder, Model, RequestBuilder};
-use axum::{
- extract::Json,
- http::StatusCode,
- response::{IntoResponse, Response},
-};
-use serde::{Deserialize, Serialize};
-use utoipa::ToSchema;
-
-#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
-pub struct GetCompletionRequest {
- model: Option<Model>,
- max_tokens: Option<u32>,
- prompt: String,
- user_message: String,
-}
-
-#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
-pub struct GetCompletionResponse {
- completion: String,
-}
-
-pub const DEFAULT_COMPLETION_MODEL: Model = Model::OpenAIGPT4oMini;
-pub const DEFAULT_COMPLETION_MAX_TOKENS: u32 = 300;
-
-#[utoipa::path(
- post,
- path = "/completions/get_completion",
- responses(
- (status = 200, body = GetCompletionResponse),
- (status = 400, body=String),
- (status = 422, body=String),
- (status = 401, body=String),
- (status = 500, body=String),
- )
-)]
-pub async fn get_completion_handler(
- Json(req): Json<GetCompletionRequest>,
-) -> Result<Response, Response> {
- let request = RequestBuilder::new()
- .model(req.model.unwrap_or(DEFAULT_COMPLETION_MODEL))
- .max_tokens(req.max_tokens.unwrap_or(DEFAULT_COMPLETION_MAX_TOKENS))
- .messages(vec![
- MessageBuilder::new()
- .user()
- .content(req.user_message)
- .build(),
- ])
- .system_prompt(req.prompt)
- .build();
-
- let completion = get_chat_completion(request).await.map_err(|e| {
- let response = match &e {
- ChatCompletionError::RequestError(e) => (StatusCode::BAD_REQUEST, e.to_string()),
- ChatCompletionError::Refusal(_) => {
- (StatusCode::UNPROCESSABLE_ENTITY, "AI Refusal".to_string())
- }
- ChatCompletionError::NoContent => (
- StatusCode::UNPROCESSABLE_ENTITY,
- "AI responded with nothing".to_string(),
- ),
- _ => (
- StatusCode::INTERNAL_SERVER_ERROR,
- "Internal server error".to_string(),
- ),
- };
- tracing::error!(error = %e, "Chat completion failed");
- response.into_response()
- })?;
- Ok((StatusCode::OK, Json(GetCompletionResponse { completion })).into_response())
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/completions/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/completions/mod.rs
index f093d45c72..fe91867020 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/completions/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/completions/mod.rs
@@ -1,20 +1,12 @@
-pub mod get_completion;
pub mod structured_output;
use axum::{Router, routing::post};
use tower::ServiceBuilder;
pub fn router() -> Router {
- Router::new()
- .route(
- "/structured_output",
- post(structured_output::handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
- .route(
- "/get_completion",
- post(get_completion::get_completion_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
+ Router::new().route(
+ "/structured_output",
+ post(structured_output::handler).layer(ServiceBuilder::new().layer(
+ axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
+ )),
+ )
}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/document_text/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/document_text/mod.rs
deleted file mode 100644
index 0d8bb1543f..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/document_text/mod.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-pub mod upsert_document_text;
-use axum::{Router, routing::post};
-use tower::ServiceBuilder;
-
-use crate::api::context::ApiContext;
-
-pub fn router() -> Router<ApiContext> {
- Router::new().route(
- "/:document_id",
- post(upsert_document_text::upsert_text_handler).layer(ServiceBuilder::new().layer(
- axum::middleware::from_fn(macro_middleware::auth::ensure_user_exists::handler),
- )),
- )
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/document_text/upsert_document_text.rs b/rust/cloud-storage/document_cognition_service/src/api/document_text/upsert_document_text.rs
deleted file mode 100644
index 7c0bc7d039..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/document_text/upsert_document_text.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-use crate::model::request::document_text::CreateTextRequestBody;
-use anyhow::Result;
-use axum::{
- Json,
- extract::{Path, State},
- http::StatusCode,
-};
-use macro_db_client::dcs::upsert_document_text::upsert_document_text;
-use sqlx::PgPool;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub document_id: String,
-}
-
-#[utoipa::path(
- post,
- path = "/document_text/:document_id",
- params(
- ("document_id" = String, Path, description = "Id of the document to create text for")
- ),
- responses(
- (status = 201),
- (status = 401, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- )
- )]
-#[tracing::instrument(skip(db), fields(document_id=?document_id))]
-pub async fn upsert_text_handler(
- State(db): State<PgPool>,
- Path(Params { document_id }): Path<Params>,
- Json(req): Json<CreateTextRequestBody>,
-) -> Result<StatusCode, (StatusCode, String)> {
- let token_count = ai::tokens::count_tokens(&req.content).map_err(|e| {
- tracing::error!(error = %e, document_id, "failed to count tokens");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to count tokens".to_string(),
- )
- })?;
-
- upsert_document_text(&db, &document_id, &req.content, token_count)
- .await
- .map_err(|e| {
- tracing::error!(error = %e, document_id, "failed to upsert document text");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to create document text".to_string(),
- )
- })?;
-
- Ok(StatusCode::CREATED)
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/internal/chat_history.rs b/rust/cloud-storage/document_cognition_service/src/api/internal/chat_history.rs
deleted file mode 100644
index c29a402358..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/internal/chat_history.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use axum::extract::{Path, State};
-use axum::{
- Json,
- http::StatusCode,
- response::{IntoResponse, Response},
-};
-use macro_db_client::chat_history::get_chat_history;
-use model::chat::ChatHistory;
-use sqlx::PgPool;
-
-/// Internal endpoint to retrieve chat history for a specific chat ID
-#[tracing::instrument(skip(db), fields(chat_id=?chat_id))]
-pub async fn get_chat_history_handler(
- State(db): State<PgPool>,
- Path(chat_id): Path<String>,
-) -> Result<Json<ChatHistory>, Response> {
- let chat_history = get_chat_history(&db, &chat_id).await.map_err(|err| {
- tracing::error!(
- chat_id = %chat_id,
- error = %err,
- "Failed to get chat history"
- );
- let error_message = if err.to_string().contains("no rows returned") {
- "Chat history not found"
- } else {
- "Failed to retrieve chat history"
- };
- (
- StatusCode::NOT_FOUND,
- Json(serde_json::json!({"error": error_message})),
- )
- .into_response()
- })?;
-
- Ok(Json(chat_history))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/internal/chat_history_batch_messages.rs b/rust/cloud-storage/document_cognition_service/src/api/internal/chat_history_batch_messages.rs
deleted file mode 100644
index 38c95fa402..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/internal/chat_history_batch_messages.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-use axum::extract::State;
-use axum::{
- Json,
- http::StatusCode,
- response::{IntoResponse, Response},
-};
-use macro_db_client::chat_history::get_chat_history_for_messages;
-use model::chat::ChatHistory;
-use models_dcs::api::ChatHistoryBatchMessagesRequest;
-use sqlx::PgPool;
-
-/// Internal endpoint to retrieve chat history for multiple message IDs
-#[tracing::instrument(skip(db))]
-pub async fn get_chat_history_batch_messages_handler(
- State(db): State<PgPool>,
- Json(request): Json<ChatHistoryBatchMessagesRequest>,
-) -> Result<Json<ChatHistory>, Response> {
- let chat_history = get_chat_history_for_messages(&db, &request.message_ids)
- .await
- .map_err(|err| {
- tracing::error!(
- error = %err,
- message_count = request.message_ids.len(),
- "Failed to get chat history for messages"
- );
- let error_message = if err.to_string().contains("no rows returned") {
- "Chat history not found"
- } else {
- "Failed to retrieve chat history"
- };
- (
- StatusCode::NOT_FOUND,
- Json(serde_json::json!({"error": error_message})),
- )
- .into_response()
- })?;
-
- Ok(Json(chat_history))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/internal/count_tokens.rs b/rust/cloud-storage/document_cognition_service/src/api/internal/count_tokens.rs
deleted file mode 100644
index 06129c784f..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/internal/count_tokens.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-use crate::api::context::ApiContext;
-use anyhow::{Context, Result};
-use axum::extract::State;
-use axum::http::StatusCode;
-use macro_db_client::dcs::get_document_text::{
- get_document_texts_with_no_tokens, get_pdf_docx_document_text,
-};
-use macro_db_client::dcs::upsert_document_text::upsert_document_text;
-
-pub async fn count_tokens_handler(
- State(state): State<ApiContext>,
-) -> Result<(StatusCode, String), (StatusCode, String)> {
- tokio::spawn(recount_documents_with_no_tokens(state));
-
- Ok((
- StatusCode::OK,
- "spawned task to recount documents with no tokens".to_string(),
- ))
-}
-
-#[tracing::instrument(err, skip(ctx))]
-pub async fn recount_documents_with_no_tokens(ctx: ApiContext) -> Result<()> {
- let document_text_with_no_tokens = get_document_texts_with_no_tokens(ctx.db.clone())
- .await
- .context("failed to get document text with no tokens")?;
-
- let documents_length = document_text_with_no_tokens.len();
-
- tracing::debug!(documents_length, "found documents with no tokens");
-
- for document_id in document_text_with_no_tokens {
- tracing::debug!(document_id, "starting to re-count tokens for document");
-
- let document_text = get_pdf_docx_document_text(ctx.db.clone(), &document_id)
- .await
- .context("failed to get document text")?;
-
- let token_count = ai::tokens::count_tokens(&document_text.content)
- .context("failed to count tokens for document")?;
-
- tracing::debug!(
- document_id = document_text.document_id,
- token_count,
- "finished re-counting tokens for document"
- );
-
- upsert_document_text(
- &ctx.db,
- &document_text.document_id,
- &document_text.content,
- token_count,
- )
- .await
- .context("failed to upsert document text")?;
- }
-
- Ok(())
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/internal/extract_text_from_all_documents.rs b/rust/cloud-storage/document_cognition_service/src/api/internal/extract_text_from_all_documents.rs
deleted file mode 100644
index 1fe46f9409..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/internal/extract_text_from_all_documents.rs
+++ /dev/null
@@ -1,118 +0,0 @@
-use crate::{api::context::ApiContext, model::internal::ExtractTextFromAllDocumentsQueryParams};
-use axum::{
- extract::{Query, State},
- http::StatusCode,
- response::IntoResponse,
-};
-use macro_db_client::{
- dcs::get_documents::{
- DocWithOwnerAndType, PaginatedResponse, get_paginated_documents,
- get_paginated_documents_without_text,
- },
- dcs::get_documents_count::get_documents_count,
-};
-use model::document::build_cloud_storage_bucket_document_key;
-
-#[tracing::instrument(skip(state))]
-pub async fn extract_text_from_all_documents_handler(
- State(state): State<ApiContext>,
- Query(params): Query<ExtractTextFromAllDocumentsQueryParams>,
-) -> impl IntoResponse {
- let document_limit = state.config.document_batch_limit;
- let total_count = match get_documents_count(&state.db).await {
- Ok(total_count) => total_count,
- Err(err) => {
- tracing::error!(error = %err, "error getting document count");
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to get document count",
- );
- }
- };
-
- if total_count == 0 {
- tracing::warn!("no documents where found");
- return (StatusCode::OK, "no documents where found");
- }
-
- let mut prev_response: Option<PaginatedResponse<DocWithOwnerAndType>> = None;
-
- // vec of (document id, bucket, key)
- let mut documents_to_enqueue: Vec<(String, String, String)> = vec![];
-
- loop {
- let maybe_paginated_response = match params.force {
- Some(true) => get_paginated_documents(&state.db, document_limit, prev_response).await,
- _ => {
- get_paginated_documents_without_text(&state.db, document_limit, prev_response).await
- }
- };
-
- let paginated_response = match maybe_paginated_response {
- Ok(paginated_response) => paginated_response,
- Err(err) => {
- tracing::error!(error = %err, "failed to get documents");
- return (StatusCode::INTERNAL_SERVER_ERROR, "unable to get documents");
- }
- };
-
- if paginated_response.items.is_empty() {
- tracing::info!("no documents to process");
- return (StatusCode::OK, "no documents to process");
- }
-
- for DocWithOwnerAndType {
- id,
- owner,
- file_type,
- document_version_id,
- ..
- } in paginated_response.items.clone().into_iter()
- {
- if file_type != "pdf" {
- continue;
- }
-
- let version_id = match document_version_id {
- Some(version_id) => version_id,
- None => continue,
- };
-
- let document_key =
- build_cloud_storage_bucket_document_key(&owner, &id, version_id, Some("pdf"));
- documents_to_enqueue.push((
- id,
- state.config.document_storage_bucket.clone(),
- document_key,
- ));
- }
-
- if !paginated_response.has_more {
- break;
- }
-
- prev_response = Some(paginated_response);
- }
-
- tracing::info!(
- document_count = documents_to_enqueue.len(),
- "enqueuing documents for extraction"
- );
-
- for chunk in documents_to_enqueue.chunks(10) {
- if let Err(err) = state
- .sqs_client
- .enqueue_documents_for_extraction(chunk.to_vec())
- .await
- {
- tracing::error!(error = %err, "failed to enqueue documents for extraction");
-
- return (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to enqueue documents for extraction",
- );
- }
- }
-
- return (StatusCode::OK, "text extraction complete");
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/internal/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/internal/mod.rs
deleted file mode 100644
index 243458baeb..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/internal/mod.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-pub mod chat_history;
-pub mod chat_history_batch_messages;
-pub mod count_tokens;
-pub mod extract_text_from_all_documents;
-pub mod re_extract_document;
-use crate::api::{
- context::ApiContext,
- internal::{
- chat_history::get_chat_history_handler,
- chat_history_batch_messages::get_chat_history_batch_messages_handler,
- extract_text_from_all_documents::extract_text_from_all_documents_handler,
- },
-};
-use axum::{
- Router,
- routing::{get, post},
-};
-use macro_middleware::auth::internal_access::ValidInternalKey;
-
-pub fn router(state: ApiContext) -> Router<ApiContext> {
- Router::new()
- .route("/history/:chat_id", get(get_chat_history_handler))
- .route(
- "/history_batch_messages",
- post(get_chat_history_batch_messages_handler),
- )
- .route(
- "/extract_text_from_all_documents",
- post(extract_text_from_all_documents_handler),
- )
- .route(
- "/re_extract_document/:document_id",
- post(re_extract_document::re_extract_document),
- )
- .route(
- "/recount_documents_with_no_tokens",
- post(count_tokens::count_tokens_handler),
- )
- .layer(axum::middleware::from_extractor_with_state::<
- ValidInternalKey,
- _,
- >(state))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/internal/re_extract_document.rs b/rust/cloud-storage/document_cognition_service/src/api/internal/re_extract_document.rs
deleted file mode 100644
index b34fea0c0d..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/internal/re_extract_document.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-use axum::extract::Path;
-use axum::extract::State;
-use axum::http::StatusCode;
-use axum::response::IntoResponse;
-use macro_db_client::dcs::get_document;
-use sqlx::PgPool;
-use std::sync::Arc;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub document_id: String,
-}
-
-#[utoipa::path(
- post,
- path = "/internal/re_extract_document/{document_id}",
- params(
- ("document_id" = String, Path, description = "Id of the document to re-extract")
- ),
- responses(
- (status = 200, body=String),
- (status = 400, body=String),
- (status = 404, body=String),
- (status = 500, body=String),
- )
-)]
-pub async fn re_extract_document(
- State(sqs_client): State<Arc<sqs_client::SQS>>,
- State(config): State<Arc<crate::Config>>,
- State(db): State<PgPool>,
- Path(Params { document_id: id }): Path<Params>,
-) -> Result<impl IntoResponse, impl IntoResponse> {
- let document = get_document::get_document(&db, id.as_str())
- .await
- .map_err(|e| {
- tracing::error!(error = %e, document_id = %id, "failed to get document");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to get document".to_string(),
- )
- })?
- .ok_or_else(|| {
- (
- StatusCode::NOT_FOUND,
- "could not find document id".to_string(),
- )
- })?;
- if document.file_type != "pdf" {
- return Err((StatusCode::BAD_REQUEST, "document is not a pdf".to_string()));
- }
- let version = document
- .document_version_id
- .ok_or_else(|| (StatusCode::BAD_REQUEST, "no version id".to_string()))?;
-
- let document_location_key = format!("{}/{}/{}.pdf", document.owner, document.id, version);
- let chunk = (
- document.id,
- config.document_storage_bucket.clone(),
- document_location_key,
- );
- sqs_client
- .enqueue_documents_for_extraction(vec![chunk])
- .await
- .map_err(|err| {
- tracing::error!(error = %err, document_id = %id, "failed to enqueue document for extraction");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- "unable to enqueue extraction".to_string(),
- )
- })?;
-
- Ok((StatusCode::OK, "ok".to_string()))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/mod.rs
index 13fad30856..bb5923ad02 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/mod.rs
@@ -14,10 +14,8 @@ use utoipa_swagger_ui::SwaggerUi;
mod citations;
mod completions;
pub mod context;
-mod document_text;
mod health;
mod id_mapping;
-mod internal;
mod models;
mod preview;
pub mod stream;
@@ -26,7 +24,6 @@ pub mod utils;
mod attachments;
mod chats;
-mod notification;
#[tracing::instrument(err, skip(state))]
pub async fn setup_and_serve(state: ApiContext) -> anyhow::Result<()> {
@@ -75,11 +72,6 @@ fn api_router(api_context: ApiContext) -> Router {
let internal_router = Router::new()
.nest("/chats", chats::router(api_context.clone()))
.nest("/stream", stream::router(api_context.clone()))
- .nest(
- "/internal",
- internal::router(api_context.clone()).nest("/notifications", notification::router()),
- )
- .nest("/document_text", document_text::router())
.nest("/attachments", attachments::router())
.nest("/citations", citations::router())
.nest("/preview", preview::router())
diff --git a/rust/cloud-storage/document_cognition_service/src/api/notification/get_chat_notification_users.rs b/rust/cloud-storage/document_cognition_service/src/api/notification/get_chat_notification_users.rs
deleted file mode 100644
index e1b4085b39..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/notification/get_chat_notification_users.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-use axum::Json;
-use axum::extract::State;
-use axum::response::Response;
-use axum::{extract::Path, http::StatusCode, response::IntoResponse};
-use macro_db_client::dcs::get_chat_notification_users::get_chat_notification_users;
-use model::response::GenericErrorResponse;
-use sqlx::PgPool;
-
-#[derive(serde::Deserialize)]
-pub struct Params {
- pub chat_id: String,
-}
-
-/// Gets all users that need to be notified for a chat
-/// Returns an list of strings that are the user ids to be notified
-#[utoipa::path(
- get,
- path = "/internal/notifications/chat/{chat_id}",
- operation_id = "get_chat_notification_users",
- params(
- ("chat_id" = String, Path, description = "Chat id")
- ),
- responses(
- (status = 200, body=Vec<String>),
- (status = 401, body=GenericErrorResponse),
- (status = 500, body=GenericErrorResponse),
- )
- )]
-#[tracing::instrument(skip(db))]
-pub async fn handler(
- State(db): State<PgPool>,
- Path(Params { chat_id }): Path<Params>,
-) -> Result<Response, Response> {
- let users = get_chat_notification_users(&db, &chat_id)
- .await
- .map_err(|e| {
- tracing::error!(error = %e, chat_id = %chat_id, "Failed to get chat notification users");
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(GenericErrorResponse {
- error: true,
- message: "unable to get chat notification users".to_string(),
- }),
- )
- .into_response()
- })?;
-
- Ok((StatusCode::OK, Json(users)).into_response())
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/notification/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/notification/mod.rs
deleted file mode 100644
index a30cf9c61a..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/notification/mod.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use crate::api::context::ApiContext;
-use axum::{Router, routing::get};
-pub(in crate::api) mod get_chat_notification_users;
-
-/// Notifications router is nested under the internal router
-/// This means that the notifications calls are only accessible via internal api key
-pub fn router() -> Router<ApiContext> {
- Router::new().route("/chat/:chat_id", get(get_chat_notification_users::handler))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/stream/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/stream/mod.rs
index 56be1a50f1..b1e3fbd1f6 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/stream/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/stream/mod.rs
@@ -4,7 +4,6 @@
//! that publish to a durable stream. The connection_gateway handles delivery to clients.
pub mod chat_message;
-pub mod simple_completion;
mod util;
use axum::{Router, routing::post};
@@ -16,10 +15,6 @@ use crate::api::context::ApiContext;
pub fn router(state: ApiContext) -> Router<ApiContext> {
Router::new()
.route("/chat/message", post(chat_message::send_chat_message))
- .route(
- "/completion/simple",
- post(simple_completion::simple_completion),
- )
.layer(
ServiceBuilder::new()
.layer(axum::middleware::from_fn(
diff --git a/rust/cloud-storage/document_cognition_service/src/api/stream/simple_completion.rs b/rust/cloud-storage/document_cognition_service/src/api/stream/simple_completion.rs
deleted file mode 100644
index 96f8f7904f..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/api/stream/simple_completion.rs
+++ /dev/null
@@ -1,231 +0,0 @@
-//! HTTP endpoint for simple completions with streaming responses.
-
-use crate::api::context::ApiContext;
-use crate::core::constants::DEFAULT_MAX_TOKENS;
-use crate::model::stream::{ChatStream, GetSimpleCompletionStreamPayload};
-use crate::service::attachment::document::get_document_plaintext_content;
-use ai::chat_stream::get_chat_stream;
-use ai::types::{ChatStreamCompletionResponse, MessageBuilder, Model, RequestBuilder};
-use async_stream::stream;
-use axum::Json;
-use axum::extract::{Extension, State};
-use axum::http::StatusCode;
-use axum::response::IntoResponse;
-use macro_db_client::dcs::get_document;
-use macro_db_client::dcs::get_document_text;
-use model::user::UserContext;
-use model_entity::EntityType;
-use serde::{Deserialize, Serialize};
-use std::fmt;
-use std::sync::Arc;
-use stream::domain::{StreamId, StreamRepoExt};
-use utoipa::ToSchema;
-
-const SIMPLE_COMPLETION_DEFAULT_MODEL: Model = Model::Claude45Haiku;
-
-/// Response for initiating a simple completion stream
-#[derive(Debug, Serialize, Deserialize, ToSchema)]
-pub struct SimpleCompletionResponse {
- /// The completion ID that will receive the response chunks
- pub completion_id: String,
-}
-
-/// Error response for simple completion endpoint
-#[derive(Debug, Serialize, Deserialize, ToSchema)]
-pub struct SimpleCompletionError {
- pub error: String,
- pub completion_id: Option<String>,
-}
-
-impl fmt::Display for SimpleCompletionError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.error)
- }
-}
-
-impl IntoResponse for SimpleCompletionError {
- fn into_response(self) -> axum::response::Response {
- (StatusCode::BAD_REQUEST, Json(self)).into_response()
- }
-}
-
-/// Start a simple completion stream.
-///
-/// This endpoint initiates a completion and streams the response via the stream service.
-/// The client should subscribe to the completion_id stream via connection_gateway to receive chunks.
-#[utoipa::path(
- post,
- path = "/stream/completion/simple",
- request_body = GetSimpleCompletionStreamPayload,
- responses(
- (status = 200, description = "Stream initiated successfully", body = SimpleCompletionResponse),
- (status = 400, description = "Bad request", body = SimpleCompletionError),
- (status = 401, description = "Unauthorized"),
- )
-)]
-#[tracing::instrument(skip(state, user_context, payload), fields(completion_id=?payload.completion_id), err)]
-pub async fn simple_completion(
- State(state): State<ApiContext>,
- Extension(user_context): Extension<UserContext>,
- Json(payload): Json<GetSimpleCompletionStreamPayload>,
-) -> Result<Json<SimpleCompletionResponse>, SimpleCompletionError> {
- let ctx = Arc::new(state);
- let completion_id = payload.completion_id.clone();
-
- // Build system prompt with document content if provided
- let mut system_prompt: String = payload.prompt.clone();
- if let Some(document_ids) = &payload.content_document_ids {
- let db = &ctx.db;
-
- for document_id in document_ids.iter() {
- let document = get_document::get_document(db, document_id)
- .await
- .map_err(|e| {
- tracing::error!(error = %e, document_id, "failed to get document metadata");
- SimpleCompletionError {
- error: format!("Failed to get document: {}", e),
- completion_id: Some(completion_id.clone()),
- }
- })?;
-
- let document_content =
- if ["pdf", "docx"].contains(&document.unwrap().file_type.as_str()) {
- get_document_text::get_pdf_docx_document_text(db.clone(), document_id)
- .await
- .map_err(|e| {
- tracing::error!(error = %e, document_id, "failed to get document text");
- SimpleCompletionError {
- error: format!("Failed to get document text: {}", e),
- completion_id: Some(completion_id.clone()),
- }
- })?
- .content
- } else {
- get_document_plaintext_content(&ctx, document_id)
- .await
- .map_err(|e| {
- tracing::error!(error = %e, document_id, "failed to get document content");
- SimpleCompletionError {
- error: format!("Failed to get document content: {}", e),
- completion_id: Some(completion_id.clone()),
- }
- })?
- .text_content()
- .map_err(|e| {
- tracing::error!(error = %e, document_id, "failed to extract text content");
- SimpleCompletionError {
- error: format!("Failed to extract text content: {}", e),
- completion_id: Some(completion_id.clone()),
- }
- })?
- };
-
- if document_content
- .chars()
- .filter(|c| !c.is_whitespace())
- .count()
- > 0
- {
- system_prompt = format!(
- "{}\n\nDocument Content:\n{}",
- system_prompt, document_content
- );
- }
- }
- }
-
- // Create stream ID for publishing
- let durable_stream_id = StreamId {
- entity_type: EntityType::User,
- entity_id: user_context.user_id.clone(),
- stream_id: completion_id.clone(),
- };
-
- let model = payload.model.unwrap_or(SIMPLE_COMPLETION_DEFAULT_MODEL);
- let max_tokens = payload.max_tokens.unwrap_or(DEFAULT_MAX_TOKENS);
- let user_request = payload.user_request.clone();
- let completion_id_for_stream = completion_id.clone();
-
- // Create the payload stream that yields JSON values
- let payload_stream = stream! {
- let request = RequestBuilder::new()
- .model(model)
- .max_tokens(max_tokens)
- .messages(vec![
- MessageBuilder::new().user().content(user_request).build(),
- ])
- .system_prompt(system_prompt)
- .build();
-
- match get_chat_stream(request).await {
- Ok(mut ai_stream) => {
- use futures::StreamExt;
- let mut cumulative_content = String::new();
-
- while let Some(response) = ai_stream.next().await {
- match response {
- Ok(parts) => {
- for part in parts {
- let ChatStreamCompletionResponse::Content(content) = part;
- cumulative_content.push_str(&content.content);
-
- let message = ChatStream::CompletionStreamChunk {
- completion_id: completion_id_for_stream.clone(),
- content: cumulative_content.clone(),
- done: false,
- };
-
- if let Ok(json) = serde_json::to_value(&message) {
- yield json;
- }
- }
- }
- Err(e) => {
- tracing::error!(error=?e, "error in AI stream");
- let error_msg = ChatStream::CompletionStreamChunk {
- completion_id: completion_id_for_stream.clone(),
- content: format!("Error: {}", e),
- done: true,
- };
- if let Ok(json) = serde_json::to_value(&error_msg) {
- yield json;
- }
- return;
- }
- }
- }
-
- // Send final message with done: true
- let final_message = ChatStream::CompletionStreamChunk {
- completion_id: completion_id_for_stream.clone(),
- content: cumulative_content,
- done: true,
- };
- if let Ok(json) = serde_json::to_value(&final_message) {
- yield json;
- }
- }
- Err(e) => {
- tracing::error!(error=?e, "failed to create AI stream");
- let error_msg = ChatStream::CompletionStreamChunk {
- completion_id: completion_id_for_stream.clone(),
- content: format!("Error: {}", e),
- done: true,
- };
- if let Ok(json) = serde_json::to_value(&error_msg) {
- yield json;
- }
- }
- }
- };
-
- // Use the extension trait to handle spawning and stream management
- ctx.stream_repo.clone().from_async_stream(
- durable_stream_id,
- Box::pin(payload_stream),
- None,
- None,
- );
-
- Ok(Json(SimpleCompletionResponse { completion_id }))
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/swagger.rs b/rust/cloud-storage/document_cognition_service/src/api/swagger.rs
index 698d961605..16a400be24 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/swagger.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/swagger.rs
@@ -1,47 +1,32 @@
use crate::{
api::{
- attachments::{
- get_chats_for_attachment,
- get_models_for_attachments::{
- self, GetModelsForAttachmentsRequest, GetModelsForAttachmentsResponse,
- },
- verify_attachments::{self, VerifyAttachmentsRequest, VerifyAttachmentsResponse},
- },
+ attachments::get_chats_for_attachment,
chats::{
chat_history, chat_history_batch_messages, copy_chat, create_user_chat, delete_chat,
- get_chat, get_chat_permissions, get_chats, revert_delete_chat,
+ get_chat, get_chat_permissions, revert_delete_chat,
},
citations,
- completions::get_completion::{self, GetCompletionRequest, GetCompletionResponse},
completions::structured_output::{
self, StructedOutputCompletionRequest, StructedOutputCompletionResponse,
},
- document_text::upsert_document_text,
health,
models::get_models,
preview::get_batch_preview,
stream::chat_message::{
self, ChatMessageError, HttpSendChatMessageRequest, SendChatMessageResponse,
},
- stream::simple_completion::{self, SimpleCompletionError, SimpleCompletionResponse},
},
model::{
- request::{
- chats::{
- CopyChatRequest, CreateChatRequest, GetChatPathParams, NewAttachment,
- PatchChatRequest, PatchChatRequestV2,
- },
- document_text::{CreateTextRequestBody, CreateTextRequestParams},
+ request::chats::{
+ CopyChatRequest, CreateChatRequest, GetChatPathParams, NewAttachment, PatchChatRequest,
+ PatchChatRequestV2,
},
response::{
attachments::GetChatsForAttachmentResponse,
chats::{GetChatPermissionsResponseV2, GetChatResponse, GetModelsResponse},
models::AIModel,
},
- stream::{
- ChatStream, GetSimpleCompletionStreamPayload, SendChatMessagePayload, StreamError,
- ToolSet,
- },
+ stream::{ChatStream, SendChatMessagePayload, StreamError, ToolSet},
},
};
@@ -49,7 +34,7 @@ use crate::api::preview::get_batch_preview::{GetBatchPreviewRequest, GetBatchPre
use ai::types::{ModelMetadata, Provider};
-use crate::model::chats::{ChatResponse, ChatsResponse};
+use crate::model::chats::ChatResponse;
use model::{
chat::{
@@ -84,20 +69,14 @@ use utoipa::OpenApi;
delete_chat::delete_chat_handler,
delete_chat::permanently_delete_chat_handler,
get_models::get_models_handler,
- get_chats::get_chats_handler,
- upsert_document_text::upsert_text_handler,
get_chats_for_attachment::get_chats_for_attachment_handler,
- verify_attachments::verify_attachments_handler,
citations::get_citation_handler,
get_batch_preview::handler,
structured_output::handler,
- get_models_for_attachments::get_models_for_attachments_handler,
- get_completion::get_completion_handler,
revert_delete_chat::handler,
chat_history::get_chat_history_handler,
chat_history_batch_messages::get_chat_history_batch_messages_handler,
chat_message::send_chat_message,
- simple_completion::simple_completion,
),
components(
schemas(
@@ -141,15 +120,9 @@ use utoipa::OpenApi;
PatchChatRequestV2,
AttachmentMetadata,
CopyChatRequest,
- GetModelsForAttachmentsResponse,
// Chat Response
GetChatPermissionsResponseV2,
GetChatResponse,
- ChatsResponse,
-
- // Document Text
- CreateTextRequestBody,
- CreateTextRequestParams,
// Share Permission
UpdateOperation,
@@ -162,10 +135,6 @@ use utoipa::OpenApi;
// Attachments
GetChatsForAttachmentResponse,
NewAttachment,
- VerifyAttachmentsRequest,
- VerifyAttachmentsResponse,
- GetModelsForAttachmentsResponse,
- GetModelsForAttachmentsRequest,
// Preview
GetBatchPreviewRequest,
@@ -174,16 +143,11 @@ use utoipa::OpenApi;
// Completions
StructedOutputCompletionRequest,
StructedOutputCompletionResponse,
- GetCompletionRequest,
- GetCompletionResponse,
// Stream HTTP API
HttpSendChatMessageRequest,
SendChatMessageResponse,
ChatMessageError,
- SimpleCompletionResponse,
- SimpleCompletionError,
- GetSimpleCompletionStreamPayload,
StreamError,
ToolSet,
diff --git a/rust/cloud-storage/document_cognition_service/src/model/chats.rs b/rust/cloud-storage/document_cognition_service/src/model/chats.rs
index 3cc9edf30d..dad39604db 100644
--- a/rust/cloud-storage/document_cognition_service/src/model/chats.rs
+++ b/rust/cloud-storage/document_cognition_service/src/model/chats.rs
@@ -1,6 +1,6 @@
#![allow(deprecated)]
use ai::types::Model;
-use model::chat::{Chat, ChatAttachmentWithName, ChatMessageWithAttachments};
+use model::chat::{ChatAttachmentWithName, ChatMessageWithAttachments};
use serde::{Deserialize, Serialize};
use unfurl_service::GetUnfurlResponse;
use utoipa::ToSchema;
@@ -36,8 +36,3 @@ pub struct ChatResponse {
/// whether the chat is persistent or not
pub is_persistent: bool,
}
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-pub struct ChatsResponse {
- pub chats: Vec<Chat>,
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/model/internal/mod.rs b/rust/cloud-storage/document_cognition_service/src/model/internal/mod.rs
deleted file mode 100644
index b21e11e1d8..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/model/internal/mod.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-use utoipa::ToSchema;
-
-#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, ToSchema)]
-pub struct ExtractTextFromAllDocumentsQueryParams {
- /// Force even documents with existing text to be extracted
- pub force: Option<bool>,
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/model/mod.rs b/rust/cloud-storage/document_cognition_service/src/model/mod.rs
index e0d27faddf..f15f451161 100644
--- a/rust/cloud-storage/document_cognition_service/src/model/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/model/mod.rs
@@ -1,5 +1,4 @@
pub mod chats;
-pub mod internal;
pub mod request;
pub mod response;
pub mod stream;
diff --git a/rust/cloud-storage/document_cognition_service/src/model/request/document_text.rs b/rust/cloud-storage/document_cognition_service/src/model/request/document_text.rs
deleted file mode 100644
index 6c767f38b4..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/model/request/document_text.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-use serde::{Deserialize, Serialize};
-use utoipa::ToSchema;
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-pub struct CreateTextRequestBody {
- pub content: String,
-}
-
-#[derive(Serialize, Deserialize, Debug, ToSchema)]
-pub struct CreateTextRequestParams {
- pub document_id: String,
-}
diff --git a/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs b/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs
index 6710743086..cf49dac7aa 100644
--- a/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/model/request/mod.rs
@@ -1,2 +1 @@
pub mod chats;
-pub mod document_text;
diff --git a/rust/cloud-storage/document_cognition_service/src/model/stream.rs b/rust/cloud-storage/document_cognition_service/src/model/stream.rs
index 8067a0eaab..8dad31b755 100644
--- a/rust/cloud-storage/document_cognition_service/src/model/stream.rs
+++ b/rust/cloud-storage/document_cognition_service/src/model/stream.rs
@@ -40,23 +40,6 @@ pub struct SendChatMessagePayload {
pub jwt: JwtPayload,
}
-#[derive(Deserialize, Serialize, ToSchema, Debug, Clone)]
-pub struct GetSimpleCompletionStreamPayload {
- /// system prompt
- pub prompt: String,
- /// user request
- pub user_request: String,
- /// model to use for the completion
- #[schema(value_type = Option<String>)]
- pub model: Option<Model>,
- /// max tokens
- pub max_tokens: Option<u32>,
- /// Optional document ID to provide context
- pub content_document_ids: Option<Vec<String>>,
- /// client provided id, returned in responses
- pub completion_id: String,
-}
-
#[derive(Deserialize, Serialize, ToSchema, Debug, Clone, PartialEq, Copy)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum ExtractionStatusEnum {
diff --git a/rust/cloud-storage/document_cognition_service/src/service/attachment/document/mod.rs b/rust/cloud-storage/document_cognition_service/src/service/attachment/document/mod.rs
index ece8c92b3e..488f9c6c30 100644
--- a/rust/cloud-storage/document_cognition_service/src/service/attachment/document/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/service/attachment/document/mod.rs
@@ -1,5 +1,3 @@
-mod plaintext_content;
mod token_count;
-pub use plaintext_content::*;
pub use token_count::*;
diff --git a/rust/cloud-storage/document_cognition_service/src/service/attachment/document/plaintext_content.rs b/rust/cloud-storage/document_cognition_service/src/service/attachment/document/plaintext_content.rs
deleted file mode 100644
index 8fca9ecfc2..0000000000
--- a/rust/cloud-storage/document_cognition_service/src/service/attachment/document/plaintext_content.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-use crate::api::context::ApiContext;
-use anyhow::{Context, Result};
-use scribe::document::types::DocumentContent;
-
-#[tracing::instrument(err, skip(ctx))]
-pub async fn get_document_plaintext_content(
- ctx: &ApiContext,
- document_id: &str,
-) -> Result<DocumentContent> {
- let document = ctx
- .scribe
- .document
- .fetch(document_id)
- .document_content()
- .await
- .context("Failed to fetch document content")?;
-
- if !document.metadata().is_text_content() {
- anyhow::bail!("Document is not text content");
- }
-
- Ok(document.content)
-}
diff --git a/rust/cloud-storage/document_cognition_service_client/src/chat.rs b/rust/cloud-storage/document_cognition_service_client/src/chat.rs
index bc5d7d4f73..f694e4ef51 100644
--- a/rust/cloud-storage/document_cognition_service_client/src/chat.rs
+++ b/rust/cloud-storage/document_cognition_service_client/src/chat.rs
@@ -4,8 +4,6 @@ use model::chat::ChatHistory;
use models_dcs::api::ChatHistoryBatchMessagesRequest;
impl DocumentCognitionServiceClient {
- // External routes - require JWT authentication and perform permission checks
-
#[tracing::instrument(skip(self, jwt_token))]
pub async fn get_chat_history_external(
&self,
@@ -58,55 +56,4 @@ impl DocumentCognitionServiceClient {
Self::handle_response(res, "chat history batch messages retrieval").await
}
-
- // Internal routes - no authentication, used for service-to-service communication
-
- #[tracing::instrument(skip(self))]
- pub async fn get_chat_history_internal(
- &self,
- chat_id: &str,
- ) -> Result<ChatHistory, DcsClientError> {
- tracing::info!(
- "dcs get chat history request (internal) for chat_id: {}",
- chat_id
- );
-
- let res = self
- .client
- .get(format!("{}/internal/history/{}", self.url, chat_id))
- .send()
- .await
- .map_err(|e| DcsClientError::RequestBuildError {
- details: e.to_string(),
- })?;
-
- Self::handle_response(res, "chat history retrieval").await
- }
-
- #[tracing::instrument(skip(self))]
- pub async fn get_chat_history_for_messages_internal(
- &self,
- message_ids: &[String],
- ) -> Result<ChatHistory, DcsClientError> {
- let request = ChatHistoryBatchMessagesRequest {
- message_ids: message_ids.to_vec(),
- };
-
- tracing::info!(
- "dcs get chat history for messages request (internal): {:?}",
- request
- );
-
- let res = self
- .client
- .post(format!("{}/internal/history_batch_messages", self.url))
- .json(&request)
- .send()
- .await
- .map_err(|e| DcsClientError::RequestBuildError {
- details: e.to_string(),
- })?;
-
- Self::handle_response(res, "chat history batch messages retrieval").await
- }
}
diff --git a/rust/cloud-storage/document_cognition_service_client/src/lib.rs b/rust/cloud-storage/document_cognition_service_client/src/lib.rs
index 6f458dcf9c..811db4de68 100644
--- a/rust/cloud-storage/document_cognition_service_client/src/lib.rs
+++ b/rust/cloud-storage/document_cognition_service_client/src/lib.rs
@@ -1,7 +1,6 @@
pub mod chat;
pub(crate) mod constants;
pub mod error;
-pub mod notification;
use constants::INTERNAL_AUTH_HEADER_KEY;
use error::DcsClientError;
@@ -12,6 +11,7 @@ pub struct DocumentCognitionServiceClient {
client: reqwest::Client,
}
+//bals
impl DocumentCognitionServiceClient {
pub fn new(internal_auth_key: String, url: String) -> Self {
let mut headers = reqwest::header::HeaderMap::new();
diff --git a/rust/cloud-storage/document_cognition_service_client/src/notification.rs b/rust/cloud-storage/document_cognition_service_client/src/notification.rs
deleted file mode 100644
index f25ea21cd9..0000000000
--- a/rust/cloud-storage/document_cognition_service_client/src/notification.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-use super::DocumentCognitionServiceClient;
-use crate::error::DcsClientError;
-
-impl DocumentCognitionServiceClient {
- /// Gets the users that need to be notified for a given chat
- #[tracing::instrument(skip(self))]
- pub async fn get_chat_notification_users(
- &self,
- chat_id: &str,
- ) -> Result<Vec<String>, DcsClientError> {
- let res = self
- .client
- .get(format!(
- "{}/internal/notifications/chat/{chat_id}",
- self.url
- ))
- .send()
- .await
- .map_err(|e| DcsClientError::RequestBuildError {
- details: e.to_string(),
- })?;
-
- Self::handle_response(res, "chat notification users retrieval").await
- }
-}
diff --git a/rust/cloud-storage/scribe/src/dcs/client.rs b/rust/cloud-storage/scribe/src/dcs/client.rs
index fd115b76ab..c3da7b3188 100644
--- a/rust/cloud-storage/scribe/src/dcs/client.rs
+++ b/rust/cloud-storage/scribe/src/dcs/client.rs
@@ -16,42 +16,22 @@ impl DcsClient {
impl DcsClient {
#[tracing::instrument(skip(self, jwt_token), err)]
- pub async fn get_chat_history(
- &self,
- chat_id: &str,
- jwt_token: Option<&str>,
- ) -> Result<ChatHistory> {
- match jwt_token {
- Some(token) => self
- .inner
- .get_chat_history_external(chat_id, token)
- .await
- .map_err(Error::from),
- None => self
- .inner
- .get_chat_history_internal(chat_id)
- .await
- .map_err(Error::from),
- }
+ pub async fn get_chat_history(&self, chat_id: &str, jwt_token: &str) -> Result<ChatHistory> {
+ self.inner
+ .get_chat_history_external(chat_id, jwt_token)
+ .await
+ .map_err(Error::from)
}
#[tracing::instrument(skip(self, jwt_token), err)]
pub async fn get_chat_history_for_messages(
&self,
message_ids: &[String],
- jwt_token: Option<&str>,
+ jwt_token: &str,
) -> Result<ChatHistory> {
- match jwt_token {
- Some(token) => self
- .inner
- .get_chat_history_for_messages_external(message_ids, token)
- .await
- .map_err(Error::from),
- None => self
- .inner
- .get_chat_history_for_messages_internal(message_ids)
- .await
- .map_err(Error::from),
- }
+ self.inner
+ .get_chat_history_for_messages_external(message_ids, jwt_token)
+ .await
+ .map_err(Error::from)
}
}