Skip to content

Commit

Permalink
gemini 1.5 + vision fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nbonamy committed May 15, 2024
1 parent 402f579 commit 41733d9
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 30 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Witsy

Generative AI desktop application:
- OpenAI, Ollama, Anthropic, MistralAI and Groq models supported
- OpenAI, Ollama, Anthropic, MistralAI, Google and Groq models supported
- Chat completion and image generation with Vision models support
- Prompt anywhere allows to generate content directly in any application
- AI commands runnable on highlighted text in almost any application
Expand Down Expand Up @@ -59,10 +59,11 @@ npm start

## Prerequisites

To use OpenAI, Anthropic or Mistral AI models, you need to enter your API key:
To use OpenAI, Anthropic, Google or Mistral AI models, you need to enter your API key:
- [OpenAI](https://platform.openai.com/api-keys)
- [Anthropic](https://console.anthropic.com/settings/keys)
- [MistralAI](https://console.mistral.ai/api-keys/)
- [Google](https://aistudio.google.com/app/apikey)

To use Ollama models, you need to install [Ollama](https://ollama.com) and download some [models](https://ollama.com/library).

Expand All @@ -76,13 +77,13 @@ To use Internet search you need a [Tavily API key](https://app.tavily.com/home).

## TODO

- [ ] Google Gemini API
- [ ] i18n
- [ ] File upload for retrieval (??)
- [ ] Proper database (SQLite3) storage (??)

## DONE

- [x] Google Gemini API
- [x] Prompt anywhere
- [x] Cancel commands
- [x] GPT-4o support
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "witsy",
"productName": "Witsy",
"version": "1.6.2",
"version": "1.7.0",
"description": "Witsy: desktop AI assistant",
"repository": {
"type": "git",
Expand Down
14 changes: 9 additions & 5 deletions src/services/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ export default class LlmEngine {
throw new Error('Not implemented')
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
isVisionModel(model: string): boolean {
return false
}

async getModels(): Promise<any[]> {
throw new Error('Not implemented')
}
Expand Down Expand Up @@ -86,6 +81,15 @@ export default class LlmEngine {
return this.config.engines[this.getName()].models.chat
}

isVisionModel(model: string): boolean {
for (const filter of this.getVisionModels()) {
if (minimatch(model, filter)) {
return true
}
}
return false
}

requiresVisionModelSwitch(thread: Message[], currentModel: string): boolean {

// if we already have a vision or auto switch is disabled
Expand Down
4 changes: 0 additions & 4 deletions src/services/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export default class extends LlmEngine {
return ['gemini-1.5-flash-latest', 'models/gemini-1.5-pro-latest', 'models/gemini-pro-vision', '*vision*']
}

isVisionModel(model: string): boolean {
return this.getVisionModels().includes(model)
}

getRountingModel(): string | null {
return null
}
Expand Down
5 changes: 0 additions & 5 deletions src/services/groq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ export default class extends LlmEngine {
return []
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
isVisionModel(model: string): boolean {
return false
}

getRountingModel(): string|null {
return null
}
Expand Down
4 changes: 0 additions & 4 deletions src/services/mistralai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export default class extends LlmEngine {
return []
}

isVisionModel(model: string): boolean {
return this.getVisionModels().includes(model)
}

getRountingModel(): string|null {
return null
}
Expand Down
4 changes: 0 additions & 4 deletions src/services/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export default class extends LlmEngine {
return ['llava-llama3:latest', 'llava:latest', '*llava*']
}

isVisionModel(model: string): boolean {
return this.getVisionModels().includes(model) || model.includes('llava')
}

getRountingModel(): string|null {
return null
}
Expand Down
4 changes: 0 additions & 4 deletions src/services/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export default class extends LlmEngine {
return [/*'*4o*', */ 'gpt-4-turbo', 'gpt-4-vision', '*vision*']
}

isVisionModel(model: string): boolean {
return this.getVisionModels().includes(model)
}

getRountingModel(): string | null {
return 'gpt-3.5-turbo'
}
Expand Down

0 comments on commit 41733d9

Please sign in to comment.