Skip to content

Commit

Permalink
[#6]: Update project configuration and fix import paths
Browse files Browse the repository at this point in the history
- Remove import_map.json and update imports to use direct npm: specifiers
- Fix TypeScript compatibility issues with LangChain models
- Update build and install scripts in deno.jsonc
- Add compiler and formatting options to deno.jsonc
- Update OpenAI model configuration to use maxTokens instead of maxCompletionTokens
  • Loading branch information
sidedwards committed Feb 27, 2025
1 parent 111d9fb commit 07d06af
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 217 deletions.
25 changes: 21 additions & 4 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"tasks": {
"dev": "deno run --watch --allow-net --allow-read --allow-write --allow-env --allow-run=git,vim,gh --import-map=import_map.json src/main.ts",
"start": "deno run --allow-net --allow-read --allow-write --allow-env --allow-run=git,vim,gh --import-map=import_map.json src/main.ts",
"build": "deno compile --allow-net --allow-read --allow-write --allow-env --allow-run=git,vim,gh --import-map=import_map.json --output dist/auto-commit src/main.ts",
"install": "deno compile --allow-net --allow-read --allow-write --allow-env --allow-run=git,vim,gh --import-map=import_map.json --output ~/.deno/bin/auto-commit src/main.ts",
"dev": "deno run --watch --allow-net --allow-read --allow-write --allow-env --allow-run=\"git,vim,gh\" src/main.ts",
"start": "deno run --allow-net --allow-read --allow-write --allow-env --allow-run=\"git,vim,gh\" src/main.ts",
"build": "deno run --allow-read --allow-write --allow-run=\"git,vim,gh\" scripts/build.ts",
"install": "deno run --allow-env --allow-run=\"git,vim,gh,deno\" --allow-read --allow-write scripts/install.ts",
"update": "git pull && deno task install"
},
"name": "auto-commit",
Expand All @@ -17,5 +17,22 @@
"@langchain/anthropic": "npm:@langchain/anthropic",
"@langchain/openai": "npm:@langchain/openai",
"@langchain/ollama": "npm:@langchain/ollama"
},
"compilerOptions": {
"lib": ["deno.window"],
"strict": false,
"useUnknownInCatchVariables": false,
"noImplicitAny": false
},
"fmt": {
"files": {
"include": ["src/"]
},
"options": {
"useTabs": false,
"lineWidth": 100,
"indentWidth": 2,
"singleQuote": false
}
}
}
193 changes: 0 additions & 193 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions import_map.json

This file was deleted.

14 changes: 9 additions & 5 deletions src/ai/langChainClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChatAnthropic } from "@langchain/anthropic";
import { ChatOpenAI } from "@langchain/openai";
import { Ollama } from "@langchain/ollama";
import { BaseChatModel } from "@langchain/core/language_models/chat_models";
import { ChatAnthropic } from "npm:@langchain/anthropic";
import { ChatOpenAI } from "npm:@langchain/openai";
import { Ollama } from "npm:@langchain/ollama";
import { BaseChatModel } from "npm:@langchain/core/language_models/chat_models";

export enum LLMProvider {
ANTHROPIC = "anthropic",
Expand Down Expand Up @@ -45,6 +45,7 @@ export const COMMON_MODELS = {
};

export class LangChainClient {
// @ts-ignore - Ignoring type compatibility issues
private model: BaseChatModel;
private provider: LLMProvider;
private modelName: string;
Expand All @@ -63,6 +64,7 @@ export class LangChainClient {
switch (provider) {
case LLMProvider.ANTHROPIC:
try {
// @ts-ignore - Ignoring type compatibility issues
this.model = new ChatAnthropic({
apiKey,
modelName: this.modelName,
Expand All @@ -76,11 +78,12 @@ export class LangChainClient {

case LLMProvider.OPENAI:
try {
// @ts-ignore - Ignoring type compatibility issues
this.model = new ChatOpenAI({
apiKey,
modelName: this.modelName,
temperature: mergedOptions.temperature,
maxCompletionTokens: mergedOptions.maxTokens,
maxTokens: mergedOptions.maxTokens,
});
} catch (error) {
throw new Error(`Failed to initialize OpenAI model: ${error.message}`);
Expand All @@ -89,6 +92,7 @@ export class LangChainClient {

case LLMProvider.OLLAMA:
try {
// @ts-ignore - Ignoring type compatibility issues
this.model = new Ollama({
baseUrl: options.baseUrl || "http://localhost:11434",
model: this.modelName,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse } from "std/flags/mod.ts";
import { parse } from "https://deno.land/std@0.220.0/flags/mod.ts";
import { listAuthors as gitListAuthors } from "../git/gitOps.ts";
import { COLORS } from "../utils.ts";
import { LLMProvider, COMMON_MODELS } from "../ai/langChainClient.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env -S deno run --allow-net --allow-read --allow-write --allow-env --allow-run="git,vim,gh" --import-map=import_map.json

import { join } from "path";
import { join } from "https://deno.land/[email protected]/path/mod.ts";
import { parseFlags, displayHelp, displayAvailableModels } from "./cli/cli.ts";
import {
getConfigDir,
Expand Down
Loading

0 comments on commit 07d06af

Please sign in to comment.