Skip to content

Commit

Permalink
Merging dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoMolina committed Dec 3, 2024
2 parents b430081 + c91a158 commit c84a8c8
Show file tree
Hide file tree
Showing 605 changed files with 38,989 additions and 11,237 deletions.
Binary file added .DS_Store
Binary file not shown.
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
logs
tmp
logs/
tmp/
shared-uploads/
shared-types/
agent_computer_use/
model_cache/
test_outputs/
.venv
venv
.pytest_cache
.env
.cache
.vscode
__pycache__
shared-uploads
run_script.log
274 changes: 152 additions & 122 deletions README.md

Large diffs are not rendered by default.

Binary file modified backend/.DS_Store
Binary file not shown.
Binary file modified backend/src/.DS_Store
Binary file not shown.
22 changes: 18 additions & 4 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ import LmStudioRoute from './routes/lmStudio.route';
import Logger from './utils/logger';
import FileRoutes from './routes/file.route';
import MessageRoutes from './routes/message.route';
import URLReferenceRoutes from './routes/urlReference.route';
import EntityReferenceRoutes from './routes/entityReference.route';
import UserCheckpointRoutes from './routes/userCheckpoint.route';
import UserInteractionRoutes from './routes/userInteraction.route';
import EmbeddingChunkRoutes from './routes/embeddingChunk.route';
import DataClusterRoutes from './routes/dataCluster.route';
import ToolCallRoutes from './routes/toolCall.route';
import CodeExecutionRoutes from './routes/codeExecution.route';
import APIConfigRoutes from './routes/apiConfig.route';

import './models';

dotenv.config();
Expand Down Expand Up @@ -51,7 +59,7 @@ app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));

// Health route should be registered before other routes
app.use('/lm-studio', LmStudioRoute);
app.use('/lm_studio', LmStudioRoute);
app.use('/api/health', HealthRoutes);
app.use('/api/apis', APIRoutes);
app.use('/api/agents', AgentRoutes);
Expand All @@ -65,6 +73,12 @@ app.use('/api/users', UserRoutes);
app.use('/api/parameters', ParametersRoutes);
app.use('/api/files', FileRoutes);
app.use('/api/messages', MessageRoutes);
app.use('/api/urlreferences', URLReferenceRoutes)

app.use('/api/entityreferences', EntityReferenceRoutes)
app.use('/api/usercheckpoints', UserCheckpointRoutes);
app.use('/api/userinteractions', UserInteractionRoutes);
app.use('/api/embeddingchunks', EmbeddingChunkRoutes);
app.use('/api/dataclusters', DataClusterRoutes);
app.use('/api/toolcalls', ToolCallRoutes);
app.use('/api/codeexecutions', CodeExecutionRoutes);
app.use('/api/apiconfigs', APIConfigRoutes);
export default app;
31 changes: 23 additions & 8 deletions backend/src/interfaces/agent.interface.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import { Model, Types, Document } from 'mongoose';
import { ModelType } from './model.interface';
import { IModelDocument, ModelType } from './model.interface';
import { IUserDocument } from './user.interface';
import { IPromptDocument } from './prompt.interface';

export enum ToolPermission {
DISABLED = 0,
NORMAL = 1,
WITH_PERMISSION = 2,
DRY_RUN = 3
}

export enum CodePermission {
DISABLED = 0,
NORMAL = 1,
WITH_PERMISSION = 2,
TAGGED_ONLY = 3
}

export interface IAgent {
name: string;
system_message: Types.ObjectId | string;
has_functions: boolean;
has_code_exec: boolean;
system_message: Types.ObjectId | IPromptDocument;
has_tools: ToolPermission;
has_code_exec: CodePermission;
max_consecutive_auto_reply: number;
models: Map<ModelType, Types.ObjectId>;
created_by: Types.ObjectId;
updated_by: Types.ObjectId;
models: Map<ModelType, Types.ObjectId | IModelDocument>;
created_by: Types.ObjectId | IUserDocument;
updated_by: Types.ObjectId | IUserDocument;
}


export interface IAgentMethods {
apiRepresentation(): any;
}
Expand Down
61 changes: 25 additions & 36 deletions backend/src/interfaces/api.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Types, Model, Document } from 'mongoose';
import { IUserDocument } from './user.interface';
import { IAPIConfigDocument } from './apiConfig.interface';

export enum ApiType {
LLM_MODEL = 'llm_api',
Expand All @@ -8,59 +10,46 @@ export enum ApiType {
EXA_SEARCH = 'exa_search',
ARXIV_SEARCH = 'arxiv_search',
GOOGLE_KNOWLEDGE_GRAPH = 'google_knowledge_graph',
WOLFRAM_ALPHA = 'wolfram_alpha',
IMG_VISION = 'img_vision',
IMG_GENERATION = 'img_generation',
SPEECH_TO_TEXT = 'speech_to_text',
TEXT_TO_SPEECH = 'text_to_speech',
EMBEDDINGS = 'embeddings',
REQUESTS = 'requests',
}

export enum ApiName {
OPENAI = 'openai_llm',
OPENAI_VISION = 'openai_vision',
OPENAI_IMG_GENERATION = 'openai_img_gen',
OPENAI_EMBEDDINGS = 'openai_embeddings',
OPENAI_TTS = 'openai_tts',
OPENAI_STT = 'openai_stt',
OPENAI_ASTT = 'openai_adv_stt',
OPENAI = 'openai',
AZURE = 'azure',
GEMINI = 'gemini_llm',
GEMINI_VISION = 'gemini_vision',
MISTRAL = 'mistral_llm',
MISTRAL_VISION = 'mistral_vision',
MISTRAL_EMBEDDINGS = 'mistral_embeddings',
GEMINI_STT = 'gemini_stt',
GEMINI_EMBEDDINGS = 'gemini_embeddings',
GEMINI_IMG_GEN = 'gemini_img_gen',
COHERE = 'cohere_llm',
GROQ = 'groq_llm',
GROQ_VISION = 'groq_vision',
GROQ_TTS = 'groq_tts',
META = 'meta_llm',
META_VISION = 'meta_vision',
ANTHROPIC = 'anthropic_llm',
ANTHROPIC_VISION = 'anthropic_vision',
LM_STUDIO = 'lm-studio_llm',
LM_STUDIO_VISION = 'lm-studio_vision',
GEMINI = 'gemini',
MISTRAL = 'mistral',
COHERE = 'cohere',
GROQ = 'groq',
LLAMA = 'llama',
ANTHROPIC = 'anthropic',
LM_STUDIO = 'lm_studio',
CUSTOM = 'Custom',
BARK = 'bark',
PIXART_IMG_GEN = 'pixart',
GOOGLE_SEARCH = 'google_search',
REDDIT_SEARCH = 'reddit_search',
WIKIPEDIA_SEARCH = 'wikipedia_search',
EXA_SEARCH = 'exa_search',
ARXIV_SEARCH = 'arxiv_search',
GOOGLE_KNOWLEDGE_GRAPH = 'google_knowledge_graph'
REDDIT_SEARCH = 'reddit',
WIKIPEDIA_SEARCH = 'wikipedia',
EXA_SEARCH = 'exa',
ARXIV_SEARCH = 'arxiv',
GOOGLE_KNOWLEDGE_GRAPH = 'google_knowledge_graph',
WOLFRAM_ALPHA = 'wolfram_alpha',
}

export interface IAPI {
api_type: ApiType;
name: string;
api_name: ApiName;
api_name: ApiName;
is_active: boolean;
health_status: 'healthy' | 'unhealthy' | 'unknown';
default_model?: Types.ObjectId;
api_config?: Map<string, any>;
created_by?: Types.ObjectId;
updated_by?: Types.ObjectId;
default_model?: Types.ObjectId;
api_config?: Types.ObjectId | IAPIConfigDocument;
created_by: Types.ObjectId | IUserDocument;
updated_by: Types.ObjectId | IUserDocument;
}

export interface IAPIMethods {
Expand Down
26 changes: 26 additions & 0 deletions backend/src/interfaces/apiConfig.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Document, Types, Model } from 'mongoose';
import { IUserDocument } from './user.interface';
import { ApiName } from './api.interface';

export interface IAPIConfig {
name: string;
api_name: ApiName;
data: Record<string, any>;
health_status: 'healthy' | 'unhealthy' | 'unknown';
created_by: Types.ObjectId | IUserDocument;
updated_by: Types.ObjectId | IUserDocument;
}

export interface IAPIConfigMethods {
apiRepresentation(): any;
}

export interface IAPIConfigDocument extends IAPIConfig, Document, IAPIConfigMethods {
_id: Types.ObjectId;
createdAt: Date;
updatedAt: Date;
}

export interface IAPIConfigModel extends Model<IAPIConfigDocument> {
// Add any static methods here if needed
}
11 changes: 8 additions & 3 deletions backend/src/interfaces/chat.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { IMessageDocument } from './message.interface';
import { ITaskDocument } from './task.interface';
import { IAgentDocument } from './agent.interface';
import { IUserDocument } from './user.interface';
import { IUserCheckpointDocument } from './userCheckpoint.interface';
import { IDataClusterDocument } from './references.interface';

// ChangeHistory interfaces
export interface IChangeHistory {
previous_agent: Types.ObjectId | null | IAgentDocument;
updated_agent: Types.ObjectId | null | IAgentDocument;
previous_functions: Types.ObjectId[] | ITaskDocument[];
updated_functions: Types.ObjectId[] | ITaskDocument[];
previous_agent_tools: Types.ObjectId[] | ITaskDocument[];
updated_agent_tools: Types.ObjectId[] | ITaskDocument[];
changed_by: Types.ObjectId | IUserDocument;
timestamp: Date;
}
Expand All @@ -24,7 +26,10 @@ export interface IAliceChat {
messages: Types.ObjectId[] | IMessageDocument[];
changeHistory: IChangeHistoryDocument[];
alice_agent: Types.ObjectId | IAgentDocument;
functions: Types.ObjectId[] | ITaskDocument[];
agent_tools: Types.ObjectId[] | ITaskDocument[];
retrieval_tools: Types.ObjectId[] | ITaskDocument[];
data_cluster: Types.ObjectId | IDataClusterDocument;
default_user_checkpoints: Map<string, Types.ObjectId | IUserCheckpointDocument>;
created_by: Types.ObjectId | IUserDocument;
updated_by: Types.ObjectId | IUserDocument;
}
Expand Down
34 changes: 34 additions & 0 deletions backend/src/interfaces/codeExecution.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Document, Types, Model } from 'mongoose';
import { IUserDocument } from './user.interface';
import { Embeddable } from './embeddingChunk.interface';

export interface CodeBlock {
code: string;
language: string;
}

export interface CodeOutput {
output: string;
exit_code: number;
}

export interface ICodeExecution extends Embeddable {
code_block: CodeBlock;
code_output: CodeOutput;
created_by: Types.ObjectId | IUserDocument;
updated_by: Types.ObjectId | IUserDocument;
}

export interface ICodeExecutionMethods {
apiRepresentation(): any;
}

export interface ICodeExecutionDocument extends ICodeExecution, Document, ICodeExecutionMethods {
_id: Types.ObjectId;
createdAt: Date;
updatedAt: Date;
}

export interface ICodeExecutionModel extends Model<ICodeExecutionDocument> {
// Add any static methods here if needed
}
29 changes: 29 additions & 0 deletions backend/src/interfaces/embeddingChunk.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Document, Types, Model } from 'mongoose';
import { IUserDocument } from './user.interface';

export interface IEmbeddingChunk {
vector: number[];
text_content: string;
index: number;
creation_metadata: Record<string, any>;
created_by: Types.ObjectId | IUserDocument;
updated_by: Types.ObjectId | IUserDocument;
}

export interface IEmbeddingChunkMethods {
apiRepresentation(): any;
}

export interface IEmbeddingChunkDocument extends IEmbeddingChunk, Document, IEmbeddingChunkMethods {
_id: Types.ObjectId;
createdAt: Date;
updatedAt: Date;
}

export interface IEmbeddingChunkModel extends Model<IEmbeddingChunkDocument> {
// Add any static methods here if needed
}

export interface Embeddable {
embedding: IEmbeddingChunkDocument[] | Types.ObjectId[];
}
Loading

0 comments on commit c84a8c8

Please sign in to comment.