Skip to content

Commit

Permalink
all: smoother linting (fixes #7607) (#7608)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Mutugiii and dogi authored Oct 16, 2024
1 parent ffd6f19 commit e3cdb94
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
2 changes: 2 additions & 0 deletions chatapi/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion chatapi/src/services/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion chatapi/src/utils/chat-assistant.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down
10 changes: 4 additions & 6 deletions chatapi/src/utils/chat-helpers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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;

Expand All @@ -145,7 +143,7 @@ export async function aiChatNonStream(
}
}

if(assistant) {
if (assistant) {
try {
const asst = await createAssistant(model);
const thread = await createThread();
Expand Down
22 changes: 16 additions & 6 deletions git-hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.14.90",
"version": "0.14.91",
"myplanet": {
"latest": "v0.20.22",
"min": "v0.19.22"
"latest": "v0.20.38",
"min": "v0.19.38"
},
"scripts": {
"ng": "ng",
Expand Down

0 comments on commit e3cdb94

Please sign in to comment.