Skip to content

Commit

Permalink
feat: Support Ollama
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Mar 2, 2024
1 parent e227e3f commit 77fd005
Show file tree
Hide file tree
Showing 14 changed files with 1,317 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/i18n/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@
"prompt_description": "By customizing the Prompt, you can customize the behavior of AI. $text $from $to $detect will be replaced with the text to be translated, source language, target language and detected language.",
"add": "Add Prompt"
},
"ollama_polish": {
"title": "Ollama Polish"
},
"ollama_summary": {
"title": "Ollama Summary"
},
"ollama_custom": {
"title": "Ollama Custom"
},
"openai": {
"title": "OpenAI",
"service": "Service Provider",
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@
"prompt_description": "通过自定义Prompt自定义AI的行为, $text $from $to $detect 将会被替换为 待翻译文本,源语言,目标语言和检测到的语言。",
"add": "添加 Prompt"
},
"ollama_polish": {
"title": "Ollama 润色"
},
"ollama_summary": {
"title": "Ollama 总结"
},
"ollama_custom": {
"title": "Ollama 自定义"
},
"openai": {
"title": "OpenAI",
"service": "服务提供商",
Expand Down
6 changes: 6 additions & 0 deletions src/services/translate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import * as _geminipro_summary from './geminipro_summary';
import * as _geminipro_polish from './geminipro_polish';
import * as _geminipro_custom from './geminipro_custom';
import * as _ollama from './ollama';
import * as _ollama_summary from './ollama_summary';
import * as _ollama_polish from './ollama_polish';
import * as _ollama_custom from './ollama_custom';

export const deepl = _deepl;
export const bing = _bing;
Expand Down Expand Up @@ -55,3 +58,6 @@ export const geminipro_summary = _geminipro_summary;
export const geminipro_polish = _geminipro_polish;
export const geminipro_custom = _geminipro_custom;
export const ollama = _ollama;
export const ollama_summary = _ollama_summary;
export const ollama_polish = _ollama_polish;
export const ollama_custom = _ollama_custom;
2 changes: 1 addition & 1 deletion src/services/translate/ollama/Config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import toast, { Toaster } from 'react-hot-toast';
import { useTranslation } from 'react-i18next';
import { open } from '@tauri-apps/api/shell';
import React, { useEffect, useState } from 'react';
import { Ollama } from 'ollama';
import { Ollama } from 'ollama/browser';

import { useConfig } from '../../../hooks/useConfig';
import { useToastStyle } from '../../../hooks';
Expand Down
3 changes: 1 addition & 2 deletions src/services/translate/ollama/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fetch, Body } from '@tauri-apps/api/http';
import { store } from '../../../utils/store';
import { Language } from './info';
import { Ollama } from 'ollama';
import { Ollama } from 'ollama/browser';

export async function translate(text, from, to, options = {}) {
const { config, setResult, detect } = options;
Expand Down
Loading

0 comments on commit 77fd005

Please sign in to comment.