pbek / QOwnNotes

QOwnNotes is a plain-text file notepad and todo-list manager with Markdown support and Nextcloud / ownCloud integration.
https://www.qownnotes.org/
GNU General Public License v2.0
4.64k stars 411 forks source link

[BUG] Errors out with "Protocol "" is unknown" when using the AI feature from an ollama instance #3052

Closed mystery-z closed 2 months ago

mystery-z commented 3 months ago

Whenever I try to use the AI feature, it just responds with Protocol "" is unknown

I've tried this with both Llama3 and dolphin-phi (which works better on my craptop), and it errors out either way.

Here's a video of what I mean:

https://github.com/pbek/QOwnNotes/assets/53719487/95d86380-b416-4e44-887a-bf59f53eb549

I've installed Ollama AI backend integration,AI text tool and AI autocompletion tool. These are the settings that I've put in from the scripting panel:

스크린샷 2024-07-06 오전 12 36 22

I have an instance of ollama running with ollama serve and it can respond to queries that I send it via curl, which means that this shouldn't be an issue on ollama's side. For example, I can ask it why the sky is blue and it will respond:

스크린샷 2024-07-06 오전 12 32 29
mystery-z commented 3 months ago

update: I tried with llama3, the same error occurs T_T

pbek commented 3 months ago

Hm, what you did looks ok.

Can you please post the output from the Debug settings in the settings dialog? You just need to paste it here. And is there any useful log output if you enable the log panel (see Window / Panels)? Please make sure you also enable debug logging in the log panel by right-clicking on the panel and selecting Debug in Options. The issue dialog in the help menu can help you with all of that.

mystery-z commented 3 months ago

Hi, so here's the debug info.

I just realised that some of the words in the debug info are in Korean (because my laptop is set to korean). This is mostly just dates or things like "default", but I have no idea how to make it not do this, but it shouldn't really be an issue.

So I've enabled debug logging and this is the useful output (I cleared it right before):

At the very start, this is the log of the scripts being loaded:

[7월 06 15:16:53] [warning]: "Removed log file: " "/Users/juwonc/Library/Application Support/PBE/QOwnNotes/QOwnNotes.log"
[7월 06 15:17:00] [debug]: Set proxy configuration to use NO proxy
[7월 06 15:17:01] [scripting]: loading script file: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ollama-integration/ollama-integration.qml
[7월 06 15:17:01] [scripting]: loading script file: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ai-text-tool/ai-text-tool.qml
[7월 06 15:17:01] [scripting]: loading script file: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ai-autocompletion/ai-autocompletion.qml
[7월 06 15:17:01] [debug]: initializeBackends  - 'id':  "ollama"
[7월 06 15:17:01] [debug]: Set proxy configuration to use NO proxy
[7월 06 15:17:02] [scripting]: loading script file: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ollama-integration/ollama-integration.qml
[7월 06 15:17:02] [scripting]: loading script file: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ai-text-tool/ai-text-tool.qml
[7월 06 15:17:02] [scripting]: loading script file: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ai-autocompletion/ai-autocompletion.qml
[7월 06 15:17:02] [debug]: initializeBackends  - 'id':  "ollama"
[7월 06 15:17:02] [debug]: currentLocalPath  - 'currentLocalPath':  "/Users/juwonc/Documents/notes"
[7월 06 15:17:02] [debug]: cloudConnection:  CloudConnection: <id>1 <name>"기본값" <serverUrl>"" <username>"" <accountId>"" <priority>1
[7월 06 15:17:02] [debug]: buildNotesIndex  - 'noteSubFolderId':  0

After this, it just lists my file names and does more buildnotesindex stuff

And this is where the keyboard trigger is registered:

[7월 06 15:17:03] [debug]: reload
[7월 06 15:17:03] [debug]: currentLocalPath  - 'currentLocalPath':  "/Users/juwonc/Documents/notes"
[7월 06 15:17:03] [debug]: filterNotesByNoteSubFolders  - 'noteSubFolderIds':  QVector(0)
[7월 06 15:17:08] [debug]: Global shortcut action triggered:  "customAction_run-ai-text-tool"
[7월 06 15:17:14] [debug]: completeSync  - 'json':  QJsonObject({"messages":[{"content":"Summarize text to 3 sentences:\n\nThroughout the poem, the woman is never described as a human being; rather, she is described as a beast, a monster. Nevertheless, Duffy emphasises that the woman has not always been this way.","role":"user"}],"model":"dolphin-phi:latest"})
[7월 06 15:18:57] [debug]: getDiskDatabasePath  - 'databaseFileName':  "/Users/juwoncha/Library/Application Support/PBE/QOwnNotes/QOwnNotes.sqlite"
[7월 06 15:19:45] [debug]: storing note file:  "Note 2024-07-06T15.19.45.md"
[7월 06 15:19:45] [status]: Stored current note to disk

This doesn't seem all that useful because it doesn't seem to say what exactly it means by protocol being unknown...

Here's my debug info (I have no idea how much of it is actually relevant so here's the whole thing): QOwnNotes Debug Information

General Info

Current Date: 토 7월 6 15:18:57 2024 Version: 24.7.0 Build date: Jul 1 2024 Build number: 1111 Platform: macosx (cocoa) Operating System: macOS 12.6 Build architecture: x86_64 Current architecture: x86_64 Release: GitHub Actions Qt Version (build): 5.15.2 Qt Version (runtime): 5.15.2 Portable mode: no Settings path / key: /Users/juwonc/Library/Preferences/com.pbe.QOwnNotes.plist Application database path: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/QOwnNotes.sqlite Application arguments: /Applications/QOwnNotes.app/Contents/MacOS/QOwnNotes Qt Debug: 0 Locale (system): ko_KR Locale (interface): en Primary screen resolution: 1440x900 Icon theme: breeze-dark-qownnotes Notes in current note folder: 51 Calendar items: 0 Enabled scripts: 3 Database drivers: QSQLITE, QODBC, QODBC3, QPSQL, QPSQL7

Server Info

serverUrl: empty appIsValid: no notesPathExists: empty connectionErrorMessage: empty

Spellchecking

Enabled: false Selected language: empty Language codes: empty Language names: empty Application dictionaries path: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/dicts

Note folders

currentNoteFolderId: 1

Note folder 기본값

id: 1 isCurrent: yes activeTagId: -1 localPath: /Users/juwonc/Documents/notes remotePath: Notes cloudConnectionId: 1 isShowSubfolders: yes isUseGit: no allowDifferentNoteFileName: no activeNoteSubFolder name: empty database file: /Users/juwonc/Documents/notes/notes.sqlite

Note folder 새 폴더

id: 2 isCurrent: no activeTagId: 0 localPath: /Users/juwonc/Documents/notes remotePath: Notes cloudConnectionId: 1 isShowSubfolders: no isUseGit: no allowDifferentNoteFileName: no activeNoteSubFolder name: empty database file: /Users/juwonc/Documents/notes/notes.sqlite

Cloud connections

Cloud connection 기본값

id: 1 isCurrent: yes serverUrl: empty username: empty accountId: empty

Enabled scripts

Script Ollama AI backend integration

id: 1 path: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ollama-integration/ollama-integration.qml variablesJson:

{
    "apiBaseUrl": "http://localhost:11434/v1/chat/completions",
    "models": "dolphin-phi:latest"
}

identifier: ollama-integration version: 0.1.2 minAppVersion: 24.6.3

Script AI Text Tool

id: 2 path: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ai-text-tool/ai-text-tool.qml variablesJson: empty identifier: ai-text-tool version: 0.1.0 minAppVersion: 24.5.7

Script AI Autocompletion

id: 3 path: /Users/juwonc/Library/Application Support/PBE/QOwnNotes/scripts/ai-autocompletion/ai-autocompletion.qml variablesJson: empty identifier: ai-autocompletion version: 0.0.1 minAppVersion: 24.5.3

Settings

AKLastIDMSEnvironment (qlonglong): 0 AboutDialog/geometry (QByteArray): <binary data> ActiveNoteHistoryItem (NoteHistoryItem): <binary data> AttachmentDialog/geometry (QByteArray): <binary data> Country (QString): SG Debug/fakeOldVersionNumber (bool): false Debug/fileLogging (bool): true DistractionFreeMode/isEnabled (bool): false DistractionFreeMode/menuBarGeometry (QByteArray): <binary data> DistractionFreeMode/menuBarHeight (qlonglong): 0 DistractionFreeMode/menuBarVisible (bool): false DistractionFreeMode/windowState (QByteArray): <binary data> Editor/CurrentSchemaKey (QString): EditorColorSchema-d239b269-8440-4d31-b0e7-78da882d0ac7 Editor/autoBracketClosing (bool): true Editor/autoBracketRemoval (bool): true Editor/centerCursor (bool): false Editor/disableCursorBlinking (bool): false Editor/editorWidthInDFMOnly (bool): true Editor/highlightCurrentLine (bool): true Editor/indentSize (qlonglong): 4 Editor/removeTrailingSpaces (bool): false Editor/showLineNumbers (bool): false Editor/useTabIndent (bool): false Editor/vimMode (bool): false FileDialog/LastPath (QString): /Users/juwonc/Downloads FileDialog/LastPath-InsertAttachment (QString): /Users/juwonc/Downloads FileDialog/LastPath-InsertImage (QString): /Users/juwonc/Downloads GlobalShortcuts/MainWindow-customAction_run-ai-text-tool (QString): ⌥Space ImageDialog/disableCopying (bool): false ImageDialog/geometry (QByteArray): <binary data> LastUpdateCheck (QDateTime): 2024-07-06T15:14:46.024 LinkDialog/geometry (QByteArray): <binary data> LinkDialog/lastSelectedFileUrl (QString): file:///Users/juwonc/Documents/notes/media/SUMAC.pdf MainWindow/geometry (QByteArray): <binary data> MainWindow/mainToolBar.iconSize (qlonglong): 14 MainWindow/menuBarGeometry (QByteArray): <binary data> MainWindow/noteSubFolderTreeWidgetExpandState-1 (QStringList): IGCSE MainWindow/noteTextEdit.code.font (QString): Menlo,16,-1,5,50,0,0,0,0,0 MainWindow/noteTextEdit.font (QString): Nanum Gothic,16,-1,5,50,0,0,0,0,0,Regular MainWindow/noteTextView.code.font (QString): Menlo,10,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.font (QString): .AppleSystemUIFont,13,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.ignoreCodeFontSize (bool): true MainWindow/noteTextView.refreshDebounceTime (qlonglong): 600 MainWindow/noteTextView.rtl (bool): false MainWindow/noteTextView.underline (bool): true MainWindow/noteTextView.useEditorStyles (bool): true MainWindow/noteTextView.useInternalExportStyling (bool): true MainWindow/showNotesFromAllNoteSubFolders (bool): false NoteDialog/geometry (QByteArray): <binary data> NoteDialog/tabWidgetIndex (qlonglong): 1 NoteFolder-1/NoteTabNameList (QStringList): new note NoteFolder-1/NoteTabStickinessList (QStringList): empty NoteFolder-1/NoteTabSubFolderPathDataList (QStringList): empty NoteHistory-1 (QVariantList): <variant list with 165 item(s)> NoteHistoryCurrentIndex-1 (qlonglong): 164 PKSecureElementAvailableFlagsByHostSome (qlonglong): 3 PMPrintingExpandedStateForPrint2 (bool): false PasswordDialog/geometry (QByteArray): <binary data> PiwikClientId (QString): <hidden> Printer/NotePrinting (QByteArray): <binary data> ScriptRepositoryDialog/geometry (QByteArray): <binary data> ScriptRepositoryDialog/mainSplitterState (QByteArray): <binary data> SearchEngineId (qlonglong): 2 SettingsDialog/geometry (QByteArray): <binary data> SettingsDialog/mainSplitterState (QByteArray): <binary data> ShareDialog/geometry (QByteArray): <binary data> Shortcuts/MainWindow-actionEnable_AI (QString): ⌥⌘↑ Shortcuts/MainWindow-actionFind_action (QString): ⌘K Shortcuts/MainWindow-customAction_run-ai-text-tool (QString): ⌥Space ShowSystemTray (bool): false StartHidden (bool): false StoredAttachmentsDialog/geometry (QByteArray): <binary data> StoredImagesDialog/geometry (QByteArray): <binary data> TISRomanSwitchState (qlonglong): 0 TableDialog/geometry (QByteArray): <binary data> UpdateDialog/geometry (QByteArray): <binary data> WebAutomaticSpellingCorrectionEnabled (bool): true WelcomeDialog/geometry (QByteArray): <binary data> acceptAllExternalModifications (bool): false ai/currentBackend (QString): ollama ai/enabled (bool): true ai/groq/apiKey (QString): <hidden> ai/ollama/currentModel (QString): dolphin-phi:latest ai/openai/apiKey (QString): <hidden> allowNoteEditing (bool): true allowOnlyOneAppInstance (bool): false appMetrics/disableAppHeartbeat (bool): false appMetrics/disableTracking (bool): false appMetrics/notificationShown (bool): true autoReadOnlyMode (bool): false autoReadOnlyModeTimeout (qlonglong): 30 automaticNoteFolderDatabaseClosing (bool): false checkSpelling (bool): false closeTodoListAfterSave (bool): false cryptoKey (qlonglong): <hidden> currentNoteFolderId (qlonglong): 1 currentWorkspace (QString): 927c451d-89e1-4751-9f8d-4f1b27179f0c cursorWidth (qlonglong): 1 darkMode (bool): false darkModeColors (bool): false darkModeIconTheme (bool): true darkModeTrayIcon (bool): false defaultNoteFileExtension (QString): md demoNotesCreated (bool): true disableAutomaticUpdateDialog (bool): true disableSavedSearchesAutoCompletion (bool): false dockWasInitializedOnce (bool): true enableNoteTree (bool): false enableSocketServer (bool): true enableWebAppSupport (bool): false externalEditorPath (QString): empty fullyHighlightedBlockquotes (bool): false gitCommitInterval (qlonglong): 30 gitExecutablePath (QString): empty gitLogCommand (QString): empty guiFirstRunInit (bool): true ignoreAllExternalModifications (bool): false ignoreAllExternalNoteFolderChanges (bool): false ignoreNoteSubFolders (QString): ^\. ignoredNoteFiles (QString): empty imageScaleDown (bool): false imageScaleDownMaximumHeight (qlonglong): 1024 imageScaleDownMaximumWidth (qlonglong): 1024 initialLayoutIdentifier (QString): full insertTimeFormat (QString): empty interfaceFontSize (qlonglong): 11 interfaceLanguage (QString): en interfaceStyle (QString): macintosh internalIconTheme (bool): false itemHeight (qlonglong): 18 legacyLinking (bool): false localTrash/autoCleanupDays (qlonglong): 30 localTrash/autoCleanupEnabled (bool): true localTrash/supportEnabled (bool): true markdownHighlightingEnabled (bool): true navigationPanelAutoSelect (bool): true navigationPanelHideSearch (bool): false networking/ignoreSSLErrors (bool): true networking/proxyType (qlonglong): 2 newNoteAskHeadline (bool): false noteEditIsCentralWidget (bool): true noteFileExtensionList (QStringList): md, txt noteListPreview (bool): false noteSaveIntervalTime (qlonglong): 10 noteSubfoldersPanelDisplayAsFullTree (bool): true noteSubfoldersPanelHideSearch (bool): false noteSubfoldersPanelOrder (qlonglong): 0 noteSubfoldersPanelShowFullPath (bool): false noteSubfoldersPanelShowNotesRecursively (bool): false noteSubfoldersPanelShowRootFolderName (bool): true noteSubfoldersPanelSort (qlonglong): 0 noteSubfoldersPanelTabsUnsetAllNotesSelection (bool): false notesPanelOrder (qlonglong): 0 notesPanelSort (qlonglong): 1 notesPath (QString): /Users/juwonc/Documents/notes notifyAllExternalModifications (bool): false overrideInterfaceFontSize (bool): false ownCloud/ignoreNonTodoCalendars (bool): false ownCloud/supportEnabled (bool): false ownCloud/todoCalendarBackend (qlonglong): 2 ownCloud/todoCalendarCalDAVPassword (QString): <hidden> ownCloud/todoCalendarCalDAVServerUrl (QString): empty ownCloud/todoCalendarCalDAVUsername (QString): 07juwonc ownCloud/todoCalendarCloudConnectionId (qlonglong): 1 ownCloud/todoCalendarDisplayNameList (QStringList): empty ownCloud/todoCalendarEnabledList (QStringList): empty ownCloud/todoCalendarEnabledUrlList (QStringList): empty ownCloud/todoCalendarUrlList (QStringList): empty ownCloudInfo/appIsValid (bool): false ownCloudInfo/connectionErrorMessage (QString): empty ownCloudInfo/notesPathExistsText (QString): empty ownCloudInfo/serverVersion (QString): empty previousWorkspace (QString): initial restoreCursorPosition (bool): false restoreLastNoteAtStartup (bool): true restoreNoteTabs (bool): true savedSearches/noteFolder-1 (QStringList): Note 2024-07-06T00.40.20, Note 2024-05-24T16.33.16, Note 2024-05-22T13.20.02, Note 2024-05-12T17.37.42, Note 2024-05-12T15.40.01, Note 2024-04-25T17.42.25, Note 2024-03-30T22.44.33, Note 2024-03-17T13.31.24, Note 2024-03-14T20.04.58, Note 2024-03-14T18.35.22, Note 2024-03-08T18.05.32, Note 2024-03-08T18.05.23, Note 2024-03-08T01.31.45, Note 2024-03-02T18.10.15, hobby, Note 2024-02-29T16.54.50, rsi application, rsi, Note 2024-02-28T22.59.03, Note 2024-02-26T17.43.33, Note 2024-02-23T01.38.29, Note 2024-02-22T00.53.40, Note 2024-02-22T00.53.32, Note 2024-02-18T18.24.03, Note 2024-02-18T00.27.26, Note 2024-02-17T02.13.00, Note 2024-02-17T02.07.28, Note 2024-02-17T02.05.12, Note 2024-02-17T02.04.52, investing, Note 2024-02-13T15.29.40, Note 2024-02-10T18.36.09, Note 2024-02-10T18.19.12, ib, sumac, tok , Note 2024-02-01T22.48.02, Note 2024-01-31T21.55.42, Note 2024-01-31T21.22.18, Note 2023-12-12T21.41.48, Note 2023-12-04T12.37.37, Note 2023-12-04T00.15.53, Note 2023-12-04T00.15.25, Note 2023-12-04T00.15.08, Note 2023-11-23T12.21.15, Note 2023-11-22T10.25.00, Note 2023-11-20T08.49.42, Note 2023-11-16T14.32.03, Note 2023-11-16T10.59.26, Note 2023-11-14T20.01.00, Note 2023-11-04T14.06.51, Note 2023-10-31T18.01.07, Note 2023-10-30T12.35.30, Note 2023-10-23T21.43.22, Note 2023-10-16T00.51.21, Note 2023-10-05T12.25.35, Note 2023-10-01T22.03.40, Note 2023-09-26T01.25.09, Note 2023-09-24T18.43.23, Note 2023-09-24T17.59.57, Note 2023-09-24T17.56.37, Note 2023-09-24T17.37.05, Note 2023-09-17T11.49.31 showMatches (bool): true showMenuBar (bool): false showStatusBar (bool): true showStatusBarNotePath (bool): true showStatusBarRelativeNotePath (bool): false startInReadOnlyMode (bool): false systemIconTheme (bool): false tagWasAddedToNote (bool): true taggingShowNotesRecursively (bool): false tagsPanelHideNoteCount (bool): false tagsPanelHideSearch (bool): false tagsPanelOrder (qlonglong): 0 tagsPanelSort (qlonglong): 0 todoCalendarSupport (bool): false toolbar/1/items (QStringList): action_New_note, action_Find_note, action_Remove_note, action_Open_note_in_external_editor, actionShow_local_trash, actionAllow_note_editing, , action_Back_in_note_history, action_Forward_in_note_history, , action_Find_text_in_note, actionReplace_in_current_note, , actionShow_versions, actionShow_trash, actionShare_note, , actionShow_Todo_List toolbar/1/name (QString): mainToolBar toolbar/1/title (QString): main toolbar toolbar/2/items (QStringList): actionFormat_text_bold, actionFormat_text_italic, actionStrike_out_text, actionInsert_code_block, actionInsert_block_quote toolbar/2/name (QString): formattingToolbar toolbar/2/title (QString): formatting toolbar toolbar/3/items (QStringList): actionInsert_text_link, actionInsert_image, actionInsert_current_time toolbar/3/name (QString): insertingToolbar toolbar/3/title (QString): inserting toolbar toolbar/4/items (QStringList): action_Encrypt_note, actionEdit_encrypted_note, actionDecrypt_note toolbar/4/name (QString): encryptionToolbar toolbar/4/title (QString): encryption toolbar toolbar/5/items (QStringList): actionEnable_AI, actionAiBackendComboBox, actionAiModelComboBox toolbar/5/name (QString): aiToolbar toolbar/5/title (QString): AI toolbar toolbar/6/items (QStringList): actionWorkspaceComboBox, actionStore_as_new_workspace, actionRemove_current_workspace, actionRename_current_workspace, actionSwitch_to_previous_workspace, actionUnlock_panels, , actionToggle_distraction_free_mode, action_Increase_note_text_size, action_Decrease_note_text_size, action_Reset_note_text_size toolbar/6/name (QString): windowToolbar toolbar/6/title (QString): window toolbar toolbar/7/items (QStringList): action_Quit toolbar/7/name (QString): quitToolbar toolbar/7/title (QString): quit toolbar toolbar/size (qlonglong): 7 useNoteFolderButtons (bool): false useSoftWrapInNoteEditor (bool): true useUNIXNewline (bool): false webAppClientService/serverUrl (QString): wss://app.qownnotes.org webAppClientService/token (QString): <hidden> webSocketServerService/bookmarksNoteName (QString): Bookmarks webSocketServerService/bookmarksTag (QString): bookmarks webSocketServerService/commandSnippetsNoteName (QString): Commands webSocketServerService/commandSnippetsTag (QString): commands webSocketServerService/port (qlonglong): 22222 workspace-927c451d-89e1-4751-9f8d-4f1b27179f0c/noteSubFolderDockWidgetVisible (bool): true workspace-927c451d-89e1-4751-9f8d-4f1b27179f0c/windowState (QByteArray): <binary data> workspace-957498ff-fb02-41c6-9a5e-9e22ec02e988/name (QString): 1 workspace-957498ff-fb02-41c6-9a5e-9e22ec02e988/noteSubFolderDockWidgetVisible (bool): true workspace-957498ff-fb02-41c6-9a5e-9e22ec02e988/windowState (QByteArray): <binary data> workspace-Y2fkm37kR2y4/name (QString): 전체 수직 workspace-Y2fkm37kR2y4/noteSubFolderDockWidgetVisible (bool): true workspace-Y2fkm37kR2y4/windowState (QByteArray): <binary data> workspace-initial/name (QString): 최소 workspace-initial/noteSubFolderDockWidgetVisible (bool): true workspace-initial/windowState (QByteArray): <binary data> workspace-qDBKMTmg2FRG/name (QString): 전체 workspace-qDBKMTmg2FRG/noteSubFolderDockWidgetVisible (bool): true workspace-qDBKMTmg2FRG/windowState (QByteArray): <binary data> workspace-vKn3dWnHhzw6/name (QString): 미리보기만 workspace-vKn3dWnHhzw6/noteSubFolderDockWidgetVisible (bool): true workspace-vKn3dWnHhzw6/windowState (QByteArray): <binary data> workspaces (QStringList): initial, Y2fkm37kR2y4, vKn3dWnHhzw6, qDBKMTmg2FRG

System environment

USER: juwonc __CFBundleIdentifier: com.PBE.QOwnNotes COMMAND_MODE: unix2003 LOGNAME: juwonc PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin SSH_AUTH_SOCK: /private/tmp/com.apple.launchd.3RIhBOaKum/Listeners SHELL: /bin/zsh HOME: /Users/juwonc __CF_USER_TEXT_ENCODING: 0x1F5:0x3:0x33 TMPDIR: /var/folders/fk/xj0lkkxj2hl56nyr2s9n4v7r0000gn/T/ XPC_SERVICE_NAME: application.com.PBE.QOwnNotes.29228450.50886055 OLLAMA_HOST: 0.0.0.0 XPC_FLAGS: 0x0 QT_LOGGING_RULES: qt.network.ssl.warning=false

pbek commented 3 months ago

I've never tested what happens on macosx, Windows and Linux seem to work fine. 🤔

[7월 06 15:17:14] [debug]: completeSync - 'json': QJsonObject({"messages":[{"content":"Summarize text to 3 sentences:\n\nThroughout the poem, the woman is never described as a human being; rather, she is described as a beast, a monster. Nevertheless, Duffy emphasises that the woman has not always been this way.","role":"user"}],"model":"dolphin-phi:latest"})

At least the request was made... What result do you get when you turn ollama off?

Could you maybe try to test signing up for Groq (which is free, as in beer) and try a request there? There is a link in the AI Settings.

mystery-z commented 3 months ago

Hmm, this is interesting.

Groq seems to work, I think this is a problem with my ollama instance. I'll do some debugging and update you.

Also, when I try it with ollama turned off, the debug logs are exactly the same. The request is made and nothing happens after that.

pbek commented 3 months ago

Maybe your ollama instance is old? Openai api support was only added recently.

mystery-z commented 3 months ago

I don't think that's the issue, I'm using version 0.1.48 which is the latest stable release from last week.

May I know which version you're using to test this?

Also, I did some further testing and here's what I found out:

What do you think about this?

pbek commented 3 months ago

I was also (and am still) using 0.1.48. Did QOwnNotes detect what models you have installed? Because I implemented that ollama API call into the script (and that also works for me).

"apiBaseUrl": "http://localhost:11434/v1/chat/completions",

You are not supposed to add the path, it's just the baseUrl! for me that's http://127.0.0.1:11434 (the default value of the script).

pbek commented 3 months ago

The path is predefined by OpenAI...

mystery-z commented 2 months ago
스크린샷 2024-07-10 오후 3 35 16

Tried with the base url without the /v1 etc... as you suggested, same issue persists.

I was also (and am still) using 0.1.48. Did QOwnNotes detect what models you have installed? Because I implemented that ollama API call into the script (and that also works for me).

No it does not, this is really weird as well. It isn't listing the models that I have installed in the dropdown menu even though I have a lot of models installed

스크린샷 2024-07-10 오후 3 36 49 스크린샷 2024-07-10 오후 3 37 32

Is there anything different that you're doing?

Would it be helpful to you if I tried this in a linux VM and told you the results?

pbek commented 2 months ago

No it does not, this is really weird as well. It isn't listing the models that I have installed in the dropdown menu even though I have a lot of models installed

It's really strange. Do you have any other network errors? For example, if you insert a link with Cmd + L, is the title fetched automatically?

Would it be helpful to you if I tried this in a linux VM and told you the results?

Yes, you could try that, please.

syntheticbit commented 2 months ago

I came across this issue as well, I added script.log(this.apiBaseUrl) into the init function of the ollama-integration and it prints out undefined.

It looks like the apiBaseUrl value is not being set before the init function is called.

pbek commented 2 months ago

That's strange. Have you tried setting it manually?

pbek commented 2 months ago

Everything working fine for me in QOwnNotes:

image

What ollama did:

image

syntheticbit commented 2 months ago

That's strange. Have you tried setting it manually?

Yes, when I replace apiBaseUrl with http://127.0.0.1:11434 it works fine. Ollama never shows any network activity until I replaceapiBaseUrl with http://127.0.0.1:11434. I added models setting to the logs too, so now using script.log(this.apiBaseUrl) and script.log(this.models). I find that they are both blank, and that they also aren't set in the hook.

This was tried on Windows, previously it was on Linux(AppImage), the log shows the following:

[Aug 01 08:11:58] [scripting]: loading script file: C:/Users/User/AppData/Roaming/PBE/QOwnNotes/scripts/ollama-integration/ollama-integration.qml
[Aug 01 08:11:58] [scripting]: ollama init()
[Aug 01 08:11:58] [scripting]: 
[Aug 01 08:11:58] [scripting]: 
[Aug 01 08:11:58] [scripting]: ollama openAiBackendsHook()
[Aug 01 08:11:58] [scripting]: 
[Aug 01 08:11:58] [scripting]: 
[Aug 01 08:11:58] [debug]: initializeBackends  - 'id':  "ollama"

The two blank lines after the functions are this.apiBaseUrl and this.models

I have tried changing the values to plain text strings to see if that would change anything in the logs without success.

pbek commented 2 months ago

Is the apiBaseUrl actually stored in your settings? I never saw a settings dump... And what operating system are you using?

Can you please post the output from the debug settings that you can copy when you get to the settings dialog in QOwnNotes and head over to the Debug section of it?

syntheticbit commented 2 months ago

Yes, the settings are stored. I'll post a dump if this last bit of information doesn't help.

For some reason the Ollama script uses this.apiBaseUrl and this.models when it should be without this., it works without issue when I replace them with simply apiBaseUrl and models.

pbek commented 2 months ago

The settingsVariables are registered before init() :

https://github.com/pbek/QOwnNotes/blob/de1cfcbe806c726ab9969c9d04cf161270f0c70b/src/services/scriptingservice.cpp#L139-L148

syntheticbit commented 2 months ago

QOwnNotes Debug Information

General Info

Current Date: Thu Aug 1 08:45:49 2024 Version: 24.8.0 Build date: Jul 31 2024 Build number: 1115 Platform: linux (xcb) Operating System: Debian GNU/Linux 12 (bookworm) Build architecture: x86_64 Current architecture: x86_64 Release: AppImage Qt Version (build): 5.15.2 Qt Version (runtime): 5.15.2 Portable mode: no Settings path / key: /home/user/.config/PBE/QOwnNotes.conf Application database path: /home/user/.local/share/PBE/QOwnNotes/QOwnNotes.sqlite Application arguments: /tmp/.mount_QOwnNoB0hbck/AppRun.wrapped Qt Debug: 0 Locale (system): en_US Locale (interface): empty Primary screen resolution: 1440x900 Icon theme: breeze-dark-qownnotes Notes in current note folder: 2 Calendar items: 0 Enabled scripts: 1 Database drivers: QSQLITE, QODBC, QODBC3, QPSQL, QPSQL7

Server Info

serverUrl: empty appIsValid: no notesPathExists: empty connectionErrorMessage: empty

Spellchecking

Enabled: true Selected language: en_US Language codes: en_US Language names: American English (United States) Application dictionaries path: /home/user/.local/share/PBE/QOwnNotes/dicts

Note folders

currentNoteFolderId: 1

Note folder default

id: 1 isCurrent: yes activeTagId: 0 localPath: /home/user/Notes remotePath: Notes cloudConnectionId: 1 isShowSubfolders: no isUseGit: no allowDifferentNoteFileName: no activeNoteSubFolder name: empty database file: /home/user/Notes/notes.sqlite

Cloud connections

Cloud connection Default

id: 1 isCurrent: yes serverUrl: empty username: empty accountId: empty

Enabled scripts

Script Ollama AI backend integration

id: 1 path: /home/user/.local/share/PBE/QOwnNotes/scripts/ollama-integration/ollama-integration.qml variablesJson:

{
    "apiBaseUrl": "http://127.0.0.1:11434",
    "models": "llama3,gemma:2b"
}

identifier: ollama-integration version: 0.1.2 minAppVersion: 24.6.3

Settings

ActiveNoteHistoryItem (NoteHistoryItem): <binary data> Debug/fakeOldVersionNumber (bool): false Debug/fileLogging (bool): true Editor/CurrentSchemaKey (QString): EditorColorSchema-cdbf28fc-1ddc-4d13-bb21-6a4043316a2f Editor/autoBracketClosing (bool): true Editor/autoBracketRemoval (bool): true Editor/disableCursorBlinking (bool): false Editor/editorWidthInDFMOnly (bool): true Editor/highlightCurrentLine (bool): true Editor/indentSize (int): 4 Editor/removeTrailingSpaces (bool): false Editor/showLineNumbers (bool): false Editor/useTabIndent (bool): false Editor/vimMode (bool): false LastUpdateCheck (QDateTime): 2024-08-01T08:42:04.878 MainWindow/geometry (QByteArray): <binary data> MainWindow/mainToolBar.iconSize (int): 24 MainWindow/menuBarGeometry (QByteArray): <binary data> MainWindow/noteTextEdit.code.font (QString): monospace,9,-1,2,50,0,0,0,0,0 MainWindow/noteTextEdit.font (QString): Sans Serif,9,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.code.font (QString): monospace,9,-1,2,50,0,0,0,0,0 MainWindow/noteTextView.font (QString): Sans Serif,9,-1,5,50,0,0,0,0,0 MainWindow/noteTextView.ignoreCodeFontSize (bool): true MainWindow/noteTextView.refreshDebounceTime (int): 600 MainWindow/noteTextView.rtl (bool): false MainWindow/noteTextView.underline (bool): true MainWindow/noteTextView.useEditorStyles (bool): true MainWindow/noteTextView.useInternalExportStyling (bool): true NoteFolder-1/NoteTabNameList (QStringList): Markdown Cheatsheet NoteFolder-1/NoteTabStickinessList (QStringList): empty NoteFolder-1/NoteTabSubFolderPathDataList (QStringList): empty NoteHistory-1 (QVariantList): <variant list with 1 item(s)> NoteHistoryCurrentIndex-1 (int): 0 PiwikClientId (QString): <hidden> ScriptRepositoryDialog/geometry (QByteArray): <binary data> ScriptRepositoryDialog/mainSplitterState (QByteArray): <binary data> SearchEngineId (int): 2 SettingsDialog/geometry (QByteArray): <binary data> SettingsDialog/mainSplitterState (QByteArray): <binary data> ShowSystemTray (bool): false StartHidden (bool): false WelcomeDialog/geometry (QByteArray): <binary data> acceptAllExternalModifications (bool): false ai/currentBackend (QString): ollama ai/enabled (QString): true ai/groq/apiKey (QString): <hidden> ai/openai/apiKey (QString): <hidden> allowNoteEditing (bool): true allowOnlyOneAppInstance (bool): true appMetrics/disableAppHeartbeat (bool): false appMetrics/disableTracking (bool): false appMetrics/notificationShown (QString): true autoReadOnlyMode (bool): false autoReadOnlyModeTimeout (int): 30 automaticNoteFolderDatabaseClosing (bool): false checkSpelling (bool): true closeTodoListAfterSave (bool): false cryptoKey (QString): <hidden> currentNoteFolderId (QString): 1 currentWorkspace (QString): initial cursorWidth (int): 1 darkMode (bool): true darkModeColors (bool): true darkModeIconTheme (bool): true darkModeTrayIcon (bool): true defaultNoteFileExtension (QString): md demoNotesCreated (QString): true disableAutomaticUpdateDialog (bool): false disableSavedSearchesAutoCompletion (bool): false dockWasInitializedOnce (QString): true enableNoteTree (bool): false enableSocketServer (bool): true enableWebAppSupport (bool): false externalEditorPath (QString): empty fullyHighlightedBlockquotes (bool): false gitCommitInterval (int): 30 gitExecutablePath (QString): empty gitLogCommand (QString): empty guiFirstRunInit (bool): true ignoreAllExternalModifications (bool): false ignoreAllExternalNoteFolderChanges (bool): false ignoreNoteSubFolders (QString): ^\. ignoredNoteFiles (QString): empty imageScaleDown (bool): false imageScaleDownMaximumHeight (int): 1024 imageScaleDownMaximumWidth (int): 1024 initialLayoutIdentifier (QString): minimal insertTimeFormat (QString): empty interfaceFontSize (int): 11 interfaceLanguage (QString): empty internalIconTheme (bool): false itemHeight (int): 17 legacyLinking (bool): false localTrash/autoCleanupDays (int): 30 localTrash/autoCleanupEnabled (bool): true localTrash/supportEnabled (bool): true markdownHighlightingEnabled (bool): true navigationPanelAutoSelect (bool): true navigationPanelHideSearch (bool): false networking/ignoreSSLErrors (bool): true networking/proxyType (int): 2 newNoteAskHeadline (bool): false noteEditIsCentralWidget (bool): true noteFileExtensionList (QStringList): md, txt noteListPreview (bool): false noteSaveIntervalTime (int): 10 noteSubfoldersPanelDisplayAsFullTree (bool): true noteSubfoldersPanelHideSearch (bool): false noteSubfoldersPanelOrder (int): 0 noteSubfoldersPanelShowFullPath (bool): false noteSubfoldersPanelShowNotesRecursively (bool): false noteSubfoldersPanelShowRootFolderName (bool): true noteSubfoldersPanelSort (int): 0 noteSubfoldersPanelTabsUnsetAllNotesSelection (bool): false notesPanelOrder (int): 0 notesPanelSort (int): 1 notesPath (QString): /home/user/Notes notifyAllExternalModifications (bool): false overrideInterfaceFontSize (bool): false ownCloud/supportEnabled (bool): false ownCloud/todoCalendarBackend (int): 3 ownCloud/todoCalendarCalDAVPassword (QString): <hidden> ownCloud/todoCalendarCalDAVServerUrl (QString): empty ownCloud/todoCalendarCalDAVUsername (QString): empty ownCloud/todoCalendarCloudConnectionId (int): 1 ownCloud/todoCalendarDisplayNameList (QStringList): empty ownCloud/todoCalendarEnabledList (QStringList): empty ownCloud/todoCalendarEnabledUrlList (QStringList): empty ownCloud/todoCalendarUrlList (QStringList): empty ownCloudInfo/appIsValid (bool): false ownCloudInfo/connectionErrorMessage (QString): empty ownCloudInfo/notesPathExistsText (QString): empty ownCloudInfo/serverVersion (QString): empty restoreCursorPosition (bool): true restoreLastNoteAtStartup (bool): true restoreNoteTabs (bool): true showMatches (bool): true showMenuBar (bool): true showStatusBar (bool): true showStatusBarNotePath (bool): true showStatusBarRelativeNotePath (bool): false spellCheckLanguage (QString): en_US startInReadOnlyMode (bool): false systemIconTheme (bool): false taggingShowNotesRecursively (bool): false tagsPanelHideNoteCount (bool): false tagsPanelHideSearch (bool): false tagsPanelOrder (int): 0 tagsPanelSort (int): 0 todoCalendarSupport (bool): true toolbar/1/items (QStringList): action_New_note, action_Find_note, action_Remove_note, action_Open_note_in_external_editor, actionShow_local_trash, actionAllow_note_editing, , action_Back_in_note_history, action_Forward_in_note_history, , action_Find_text_in_note, actionReplace_in_current_note, , actionShow_versions, actionShow_trash, actionShare_note, , actionShow_Todo_List toolbar/1/name (QString): mainToolBar toolbar/1/title (QString): main toolbar toolbar/2/items (QStringList): actionFormat_text_bold, actionFormat_text_italic, actionStrike_out_text, actionInsert_code_block, actionInsert_block_quote toolbar/2/name (QString): formattingToolbar toolbar/2/title (QString): formatting toolbar toolbar/3/items (QStringList): actionInsert_text_link, actionInsert_image, actionInsert_current_time toolbar/3/name (QString): insertingToolbar toolbar/3/title (QString): inserting toolbar toolbar/4/items (QStringList): action_Encrypt_note, actionEdit_encrypted_note, actionDecrypt_note toolbar/4/name (QString): encryptionToolbar toolbar/4/title (QString): encryption toolbar toolbar/5/items (QStringList): actionEnable_AI, actionAiBackendComboBox, actionAiModelComboBox toolbar/5/name (QString): aiToolbar toolbar/5/title (QString): AI toolbar toolbar/6/items (QStringList): actionWorkspaceComboBox, actionStore_as_new_workspace, actionRemove_current_workspace, actionRename_current_workspace, actionSwitch_to_previous_workspace, actionUnlock_panels, , actionToggle_distraction_free_mode, action_Increase_note_text_size, action_Decrease_note_text_size, action_Reset_note_text_size toolbar/6/name (QString): windowToolbar toolbar/6/title (QString): window toolbar toolbar/7/items (QStringList): action_Quit toolbar/7/name (QString): quitToolbar toolbar/7/title (QString): quit toolbar toolbar/size (int): 7 useNoteFolderButtons (bool): false useUNIXNewline (bool): false webAppClientService/serverUrl (QString): wss://app.qownnotes.org webAppClientService/token (QString): <hidden> webSocketServerService/bookmarksNoteName (QString): Bookmarks webSocketServerService/bookmarksTag (QString): bookmarks webSocketServerService/commandSnippetsNoteName (QString): Commands webSocketServerService/commandSnippetsTag (QString): commands webSocketServerService/port (int): 22222 workspace-initial/name (QString): Minimal workspace-initial/noteSubFolderDockWidgetVisible (QString): true workspace-initial/windowState (QByteArray): <binary data> workspaces (QString): initial

System environment

SHELL: /bin/bash SESSION_MANAGER: local/debian:@/tmp/.ICE-unix/811,unix/debian:/tmp/.ICE-unix/811 QT_ACCESSIBILITY: 1 XDG_CONFIG_DIRS: /home/user/.config/kdedefaults:/etc/xdg:/usr/share/desktop-base/kf5-settings XDG_SESSION_PATH: /org/freedesktop/DisplayManager/Session0 SSH_AUTH_SOCK: /tmp/ssh-XXXXXX8wgwLp/agent.704 ARGV0: /home/user/Downloads/QOwnNotes-x86_64.AppImage DESKTOP_SESSION: plasma SSH_AGENT_PID: 751 GTK_RC_FILES: /etc/gtk/gtkrc:/home/user/.gtkrc:/home/user/.config/gtkrc XCURSOR_SIZE: 24 XDG_SEAT: seat0 PWD: /home/user/Downloads XDG_SESSION_DESKTOP: KDE LOGNAME: user XDG_SESSION_TYPE: x11 GPG_AGENT_INFO: /run/user/1000/gnupg/S.gpg-agent:0:1 SYSTEMD_EXEC_PID: 854 XAUTHORITY: /home/user/.Xauthority GTK2_RC_FILES: /etc/gtk-2.0/gtkrc:/home/user/.gtkrc-2.0:/home/user/.config/gtkrc-2.0 HOME: /home/user LANG: en_US.UTF-8 XDG_CURRENT_DESKTOP: KDE XDG_SEAT_PATH: /org/freedesktop/DisplayManager/Seat0 INVOCATION_ID: af06e703119e4e369bf5d75615dcc013 QTWEBENGINE_DICTIONARIES_PATH: /usr/share/hunspell-bdic/ MANAGERPID: 686 APPDIR: /tmp/.mount_QOwnNoB0hbck KDE_SESSION_UID: 1000 XDG_SESSION_CLASS: user USER: user OWD: /home/user/Downloads KDE_SESSION_VERSION: 5 DISPLAY: :0 SHLVL: 0 XDG_VTNR: 7 XDG_SESSION_ID: 1 APPIMAGE: /home/user/Downloads/QOwnNotes-x86_64.AppImage XDG_RUNTIME_DIR: /run/user/1000 QT_AUTO_SCREEN_SCALE_FACTOR: 0 JOURNAL_STREAM: 8:16989 XCURSOR_THEME: breeze_cursors XDG_DATA_DIRS: /home/user/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share KDE_FULL_SESSION: true PATH: /home/user/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/user/.local/bin DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus KDE_APPLICATIONS_AS_SCOPE: 1

pbek commented 2 months ago

For some reason the Ollama script uses this.apiBaseUrl and this.models when it should be without this., it works without issue when I replace them with simply apiBaseUrl and models.

That would be my bad, then! I just looked at other scripts, and they also use no this. 🤔

pbek commented 2 months ago

I published a version 0.1.3!

pbek commented 2 months ago

But I have no idea why it even worked out for me and others. 🤔

syntheticbit commented 2 months ago

Looks good, thank you! Yes, it's very odd that it was working for some and not others.

pbek commented 2 months ago

Thank you for pointing the this. out!