logancyang / obsidian-copilot

A ChatGPT Copilot in Obsidian
https://www.obsidiancopilot.com/
GNU Affero General Public License v3.0
2.28k stars 153 forks source link

OpenRouter API setting does not work #429

Open wenlzhang opened 2 months ago

wenlzhang commented 2 months ago

In the section OpenRouter.ai API Settings, I set an API Key and model. However, when chatting with a long note, it did not work. The output given by Copilot is empty. However, I can see three requests to OpenRouter on its website and the costs are deducted. I also the following messages repeated by three times in the console:

Failed to calculate number of tokens, falling back to approximate count Error: Unknown model
    at getEncodingNameForModel (plugin:copilot:19507:13)
    at encodingForModel (plugin:copilot:19655:22)
    at ProxyChatOpenAI.getNumTokens (plugin:copilot:20175:36)
    at eval (plugin:copilot:86391:36)
    at Array.map (<anonymous>)
    at ProxyChatOpenAI.getNumTokensFromMessages (plugin:copilot:86389:57)
    at ProxyChatOpenAI.getEstimatedTokenCountFromPrompt (plugin:copilot:86348:30)
    at ProxyChatOpenAI._generate (plugin:copilot:86300:43)
    at async Promise.allSettled (index 0)
    at async ProxyChatOpenAI._generateUncached (plugin:copilot:85542:21)

I also tried to set the following:

image

However, the long note chat did not work either. On the other hand, in pure chat mode, it works as expected.