diff --git a/chatapi/.eslintrc b/chatapi/.eslintrc index 7fbeed6617..41b0bc7bde 100644 --- a/chatapi/.eslintrc +++ b/chatapi/.eslintrc @@ -78,6 +78,7 @@ "@typescript-eslint/semi": ["error", "always"], "@typescript-eslint/triple-slash-reference": "error", "@typescript-eslint/type-annotation-spacing": "error", + "array-bracket-spacing": ["error", "always"], "arrow-body-style": "error", "arrow-parens": ["error", "always"], "camelcase": "off", @@ -90,6 +91,7 @@ "guard-for-in": "error", "id-blacklist": ["error", "any", "number", "string", "boolean", "undefined"], "id-match": "error", + "keyword-spacing": ["error", { "before": true, "after": true }], "max-len": ["error", { "code": 140 }], "new-parens": "error", "no-array-constructor": "error", diff --git a/chatapi/src/services/chat.service.ts b/chatapi/src/services/chat.service.ts index 34e93b968d..c60eafc070 100644 --- a/chatapi/src/services/chat.service.ts +++ b/chatapi/src/services/chat.service.ts @@ -26,7 +26,7 @@ export async function chat(data: any, stream?: boolean, callback?: (response: st throw new Error('"data.content" is a required non-empty string field'); } - if(stream && aiProvider.name === 'gemini') { + if (stream && aiProvider.name === 'gemini') { throw new Error('Streaming not supported on Gemini'); } diff --git a/chatapi/src/utils/chat-assistant.utils.ts b/chatapi/src/utils/chat-assistant.utils.ts index fe91ec237d..6905085502 100644 --- a/chatapi/src/utils/chat-assistant.utils.ts +++ b/chatapi/src/utils/chat-assistant.utils.ts @@ -10,7 +10,7 @@ export async function createAssistant(model: string) { return await keys.openai.beta.assistants.create({ 'name': assistant?.name, 'instructions': assistant?.instructions, - 'tools': [{ 'type': 'code_interpreter' }], + 'tools': [ { 'type': 'code_interpreter' } ], model, }); } diff --git a/chatapi/src/utils/chat-helpers.utils.ts b/chatapi/src/utils/chat-helpers.utils.ts index 57e91cc369..a146c063af 100644 --- a/chatapi/src/utils/chat-helpers.utils.ts +++ b/chatapi/src/utils/chat-helpers.utils.ts @@ -15,8 +15,6 @@ import { } from './chat-assistant.utils'; import { extractTextFromDocument } from './text-extraction.utils'; -// const getProviders = async () => await initializeProviderModels(); - /** * Uses geminis's multimodal endpoint to generate chat completions * @param messages - Array of chat messages @@ -33,7 +31,7 @@ async function handleGemini( const geminiMessages: GeminiMessage[] = messages.map((message) => ({ 'role': message.role === 'assistant' ? 'model' : message.role, - 'parts': [{ 'text': message.content }], + 'parts': [ { 'text': message.content } ], })); geminiMessages.pop(); @@ -132,8 +130,8 @@ export async function aiChatNonStream( } const model = aiProvider.model ?? provider.defaultModel; - if(context.resource) { - for (const [attachmentName, attachment] of Object.entries(context.resource.attachments)) { + if (context.resource) { + for (const [ attachmentName, attachment ] of Object.entries(context.resource.attachments)) { const typedAttachment = attachment as Attachment; const contentType = typedAttachment.content_type; @@ -145,7 +143,7 @@ export async function aiChatNonStream( } } - if(assistant) { + if (assistant) { try { const asst = await createAssistant(model); const thread = await createThread(); diff --git a/git-hooks/pre-push b/git-hooks/pre-push index abb7ea855a..d612bf990c 100755 --- a/git-hooks/pre-push +++ b/git-hooks/pre-push @@ -53,12 +53,22 @@ git stash -k # Check if vagrant is running vagrant_status=$(vagrant status dev --machine-readable | grep state,running) -echo "Running Linters:" -if [ "$vagrant_status" = "" ]; then - tslint=$(npm run lint) -else - tslint=$(vagrant ssh dev -- -t 'cd /vagrant;npm run lint') -fi +run_lint() { + local dir=$1 + + if [ "$vagrant_status" = "" ]; then + cd $dir + tslint=$(npm run lint) + else + tslint=$(vagrant ssh dev -- -t `cd /vagrant/$dir;npm run lint`) + fi +} + +echo "Running ng linters" +run_lint . + +echo "Running chatapi linters" +run_lint chatapi ret_code_tslint=$? output_result $ret_code_tslint "tslint" $tslint