Skip to content

Commit

Permalink
changed plugin-image-gen tsconfig.json & added error handling ollama …
Browse files Browse the repository at this point in the history
…initialization
  • Loading branch information
o-on-x committed Nov 7, 2024
1 parent 5b79da6 commit d4268b3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 41 deletions.
25 changes: 15 additions & 10 deletions packages/core/src/services/OllamaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,21 @@ class OllamaService {
private isProcessing: boolean = false;

private constructor() {
debug('Constructing OllamaService');
dotenv.config();
this.modelName = process.env.OLLAMA_MODEL || 'llama3.2';
this.openai = new OpenAI({
baseURL: process.env.OLLAMA_SERVER_URL || 'http://localhost:11434/v1',
apiKey: 'ollama',
dangerouslyAllowBrowser: true
});
debug(`Using model: ${this.modelName}`);
debug('OpenAI client initialized');
try {
debug('Constructing OllamaService');
dotenv.config();
this.modelName = process.env.OLLAMA_MODEL || 'llama3.2';
this.openai = new OpenAI({
baseURL: process.env.OLLAMA_SERVER_URL || 'http://localhost:11434/v1',
apiKey: 'ollama',
dangerouslyAllowBrowser: true
});
debug(`Using model: ${this.modelName}`);
debug('OpenAI client initialized');
} catch (error) {
debug('Failed to initialize OllamaService:', error);
throw new Error(`Failed to initialize Ollama service: ${error}`);
}
}

public static getInstance(): OllamaService {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/services/llama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LlamaService implements ILlamaService {
private constructor() {
const provider = process.env.LOCAL_LLAMA_PROVIDER;
console.log("provider: ", provider)
if (true){//provider === ModelProvider.OLLAMA) {
if (provider === ModelProvider.OLLAMA) {
console.log("running ollama")
this.delegate = OllamaService.getInstance();
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "src/**/*.d.ts", "types/**/*.test.ts"]
}
}
15 changes: 11 additions & 4 deletions packages/plugin-image-generation/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src"
"outDir": "dist",
"rootDir": ".",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
},
"include": ["src"]
}
"include": ["src"],
"references": [
{ "path": "../core" }
]
}

50 changes: 25 additions & 25 deletions pnpm-lock.yaml

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

0 comments on commit d4268b3

Please sign in to comment.