mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Azure embedding support (#105)
* Upgrade langchain to 0.0.103 * Add abort streaming to QA mode * Add Azure gpt35 16k * Add azure openai as an embedding provider * 2.3.3
This commit is contained in:
parent
b06dba58ef
commit
fe2ba58196
9 changed files with 208 additions and 35 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "copilot",
|
||||
"name": "Copilot",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "A ChatGPT Copilot in Obsidian.",
|
||||
"author": "Logan Yang",
|
||||
|
|
|
|||
171
package-lock.json
generated
171
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "obsidian-copilot",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "obsidian-copilot",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@huggingface/inference": "^1.8.0",
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
"crypto-js": "^4.1.1",
|
||||
"esbuild-plugin-svg": "^0.1.0",
|
||||
"eventsource-parser": "^1.0.0",
|
||||
"langchain": "^0.0.79",
|
||||
"langchain": "^0.0.103",
|
||||
"next-i18next": "^13.2.2",
|
||||
"pouchdb": "^8.0.1",
|
||||
"prop-types": "^15.8.1",
|
||||
|
|
@ -2501,6 +2501,11 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
|
||||
"integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ=="
|
||||
},
|
||||
"node_modules/@types/uuid": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.2.tgz",
|
||||
"integrity": "sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ=="
|
||||
},
|
||||
"node_modules/@types/yargs": {
|
||||
"version": "17.0.24",
|
||||
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz",
|
||||
|
|
@ -2869,9 +2874,7 @@
|
|||
"node_modules/argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||
"dev": true,
|
||||
"peer": true
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
},
|
||||
"node_modules/aria-query": {
|
||||
"version": "5.1.3",
|
||||
|
|
@ -3583,6 +3586,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/decamelize": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
|
||||
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/decimal.js": {
|
||||
"version": "10.4.3",
|
||||
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
|
||||
|
|
@ -5080,7 +5091,7 @@
|
|||
"version": "5.2.4",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",
|
||||
"integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
}
|
||||
|
|
@ -6763,9 +6774,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/js-tiktoken": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.6.tgz",
|
||||
"integrity": "sha512-lxHntEupgjWvSh37WxpAW4XN6UBXBtFJOpZZq5HN5oNjDfN7L/iJhHOKjyL/DFtuYXUwn5jfTciLtOWpgQmHjQ==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.7.tgz",
|
||||
"integrity": "sha512-biba8u/clw7iesNEWLOLwrNGoBP2lA+hTaBLs/D45pJdUPFXyxD6nhcDVtADChghv4GgyAiMKYMiRx7x6h7Biw==",
|
||||
"dependencies": {
|
||||
"base64-js": "^1.5.1"
|
||||
}
|
||||
|
|
@ -6779,8 +6790,6 @@
|
|||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1"
|
||||
},
|
||||
|
|
@ -6895,20 +6904,25 @@
|
|||
}
|
||||
},
|
||||
"node_modules/langchain": {
|
||||
"version": "0.0.79",
|
||||
"resolved": "https://registry.npmjs.org/langchain/-/langchain-0.0.79.tgz",
|
||||
"integrity": "sha512-xpZpb7ZoUm3453+ib6bHbSLtmx1dKhibLa58208gHnWxZ7Gn887VIeEw9sMDkRSYImmnpINoMFoUcY7KZKJeFw==",
|
||||
"version": "0.0.103",
|
||||
"resolved": "https://registry.npmjs.org/langchain/-/langchain-0.0.103.tgz",
|
||||
"integrity": "sha512-vRkDSDPA76dpM23WrSeZr4F616E1EW08Ec+2HX15WFKoiUCd+fmkdfbjeJLXWYwFxKG5iy2jVE3d00nJ/8tqAw==",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.4.3",
|
||||
"ansi-styles": "^5.0.0",
|
||||
"binary-extensions": "^2.2.0",
|
||||
"camelcase": "6",
|
||||
"decamelize": "^1.2.0",
|
||||
"expr-eval": "^2.0.2",
|
||||
"flat": "^5.0.2",
|
||||
"js-tiktoken": "^1.0.6",
|
||||
"js-tiktoken": "^1.0.7",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jsonpointer": "^5.0.1",
|
||||
"langchainplus-sdk": "^0.0.19",
|
||||
"ml-distance": "^4.0.0",
|
||||
"object-hash": "^3.0.0",
|
||||
"openai": "^3.2.0",
|
||||
"openai": "^3.3.0",
|
||||
"openapi-types": "^12.1.3",
|
||||
"p-queue": "^6.6.2",
|
||||
"p-retry": "4",
|
||||
"uuid": "^9.0.0",
|
||||
|
|
@ -6924,30 +6938,45 @@
|
|||
"@aws-sdk/client-lambda": "^3.310.0",
|
||||
"@aws-sdk/client-s3": "^3.310.0",
|
||||
"@aws-sdk/client-sagemaker-runtime": "^3.310.0",
|
||||
"@aws-sdk/client-sfn": "^3.310.0",
|
||||
"@clickhouse/client": "^0.0.14",
|
||||
"@elastic/elasticsearch": "^8.4.0",
|
||||
"@getmetal/metal-sdk": "*",
|
||||
"@getzep/zep-js": "^0.4.1",
|
||||
"@gomomento/sdk": "^1.23.0",
|
||||
"@google-cloud/storage": "^6.10.1",
|
||||
"@huggingface/inference": "^1.5.1",
|
||||
"@notionhq/client": "^2.2.5",
|
||||
"@opensearch-project/opensearch": "*",
|
||||
"@pinecone-database/pinecone": "*",
|
||||
"@qdrant/js-client-rest": "^1.2.0",
|
||||
"@supabase/postgrest-js": "^1.1.1",
|
||||
"@supabase/supabase-js": "^2.10.0",
|
||||
"@tensorflow-models/universal-sentence-encoder": "*",
|
||||
"@tensorflow/tfjs-converter": "*",
|
||||
"@tensorflow/tfjs-core": "*",
|
||||
"@tigrisdata/vector": "^1.1.0",
|
||||
"@upstash/redis": "^1.20.6",
|
||||
"@zilliz/milvus2-sdk-node": ">=2.2.7",
|
||||
"apify-client": "^2.7.1",
|
||||
"axios": "*",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"chromadb": "^1.4.0",
|
||||
"chromadb": "^1.5.2",
|
||||
"cohere-ai": "^5.0.2",
|
||||
"d3-dsv": "^2.0.0",
|
||||
"epub2": "^3.0.1",
|
||||
"faiss-node": "^0.1.1",
|
||||
"faiss-node": "^0.2.1",
|
||||
"google-auth-library": "^8.8.0",
|
||||
"hnswlib-node": "^1.4.2",
|
||||
"html-to-text": "^9.0.5",
|
||||
"ignore": "^5.2.0",
|
||||
"mammoth": "*",
|
||||
"meriyah": "*",
|
||||
"mongodb": "^5.2.0",
|
||||
"mysql2": "^3.3.3",
|
||||
"notion-to-md": "^3.1.0",
|
||||
"pdf-parse": "1.1.1",
|
||||
"peggy": "^3.0.2",
|
||||
"pg": "^8.11.0",
|
||||
"pickleparser": "^0.1.0",
|
||||
"playwright": "^1.32.1",
|
||||
"puppeteer": "^19.7.2",
|
||||
|
|
@ -6955,6 +6984,8 @@
|
|||
"replicate": "^0.9.0",
|
||||
"srt-parser-2": "^1.2.2",
|
||||
"typeorm": "^0.3.12",
|
||||
"typesense": "^1.5.3",
|
||||
"vectordb": "^0.1.4",
|
||||
"weaviate-ts-client": "^1.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
|
|
@ -6970,21 +7001,45 @@
|
|||
"@aws-sdk/client-sagemaker-runtime": {
|
||||
"optional": true
|
||||
},
|
||||
"@aws-sdk/client-sfn": {
|
||||
"optional": true
|
||||
},
|
||||
"@clickhouse/client": {
|
||||
"optional": true
|
||||
},
|
||||
"@elastic/elasticsearch": {
|
||||
"optional": true
|
||||
},
|
||||
"@getmetal/metal-sdk": {
|
||||
"optional": true
|
||||
},
|
||||
"@getzep/zep-js": {
|
||||
"optional": true
|
||||
},
|
||||
"@gomomento/sdk": {
|
||||
"optional": true
|
||||
},
|
||||
"@google-cloud/storage": {
|
||||
"optional": true
|
||||
},
|
||||
"@huggingface/inference": {
|
||||
"optional": true
|
||||
},
|
||||
"@notionhq/client": {
|
||||
"optional": true
|
||||
},
|
||||
"@opensearch-project/opensearch": {
|
||||
"optional": true
|
||||
},
|
||||
"@pinecone-database/pinecone": {
|
||||
"optional": true
|
||||
},
|
||||
"@qdrant/js-client-rest": {
|
||||
"optional": true
|
||||
},
|
||||
"@supabase/postgrest-js": {
|
||||
"optional": true
|
||||
},
|
||||
"@supabase/supabase-js": {
|
||||
"optional": true
|
||||
},
|
||||
|
|
@ -6997,6 +7052,12 @@
|
|||
"@tensorflow/tfjs-core": {
|
||||
"optional": true
|
||||
},
|
||||
"@tigrisdata/vector": {
|
||||
"optional": true
|
||||
},
|
||||
"@upstash/redis": {
|
||||
"optional": true
|
||||
},
|
||||
"@zilliz/milvus2-sdk-node": {
|
||||
"optional": true
|
||||
},
|
||||
|
|
@ -7024,24 +7085,39 @@
|
|||
"faiss-node": {
|
||||
"optional": true
|
||||
},
|
||||
"google-auth-library": {
|
||||
"optional": true
|
||||
},
|
||||
"hnswlib-node": {
|
||||
"optional": true
|
||||
},
|
||||
"html-to-text": {
|
||||
"optional": true
|
||||
},
|
||||
"mammoth": {
|
||||
"ignore": {
|
||||
"optional": true
|
||||
},
|
||||
"meriyah": {
|
||||
"mammoth": {
|
||||
"optional": true
|
||||
},
|
||||
"mongodb": {
|
||||
"optional": true
|
||||
},
|
||||
"mysql2": {
|
||||
"optional": true
|
||||
},
|
||||
"notion-to-md": {
|
||||
"optional": true
|
||||
},
|
||||
"pdf-parse": {
|
||||
"optional": true
|
||||
},
|
||||
"peggy": {
|
||||
"optional": true
|
||||
},
|
||||
"pg": {
|
||||
"optional": true
|
||||
},
|
||||
"pickleparser": {
|
||||
"optional": true
|
||||
},
|
||||
|
|
@ -7063,6 +7139,12 @@
|
|||
"typeorm": {
|
||||
"optional": true
|
||||
},
|
||||
"typesense": {
|
||||
"optional": true
|
||||
},
|
||||
"vectordb": {
|
||||
"optional": true
|
||||
},
|
||||
"weaviate-ts-client": {
|
||||
"optional": true
|
||||
}
|
||||
|
|
@ -7079,6 +7161,40 @@
|
|||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/langchain/node_modules/camelcase": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",
|
||||
"integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/langchainplus-sdk": {
|
||||
"version": "0.0.19",
|
||||
"resolved": "https://registry.npmjs.org/langchainplus-sdk/-/langchainplus-sdk-0.0.19.tgz",
|
||||
"integrity": "sha512-WKMN90E8M/JWO9lajbw8sv32xVHUZM+fN9I4LUveffBoX4qoJFi6uzYeDH0loW2SjnOSh3Tnzlz+Qp6ZenCu6g==",
|
||||
"dependencies": {
|
||||
"@types/uuid": "^9.0.1",
|
||||
"commander": "^10.0.1",
|
||||
"p-queue": "^6.6.2",
|
||||
"p-retry": "4",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"langchain": "dist/cli/main.cjs"
|
||||
}
|
||||
},
|
||||
"node_modules/langchainplus-sdk/node_modules/commander": {
|
||||
"version": "10.0.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",
|
||||
"integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/level": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/level/-/level-6.0.1.tgz",
|
||||
|
|
@ -8348,9 +8464,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/openai": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/openai/-/openai-3.2.1.tgz",
|
||||
"integrity": "sha512-762C9BNlJPbjjlWZi4WYK9iM2tAVAv0uUp1UmI34vb0CN5T2mjB/qM6RYBmNKMh/dN9fC+bxqPwWJZUTWW052A==",
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/openai/-/openai-3.3.0.tgz",
|
||||
"integrity": "sha512-uqxI/Au+aPRnsaQRe8CojU0eCR7I0mBiKjD3sNMzY6DaC1ZVrc85u98mtJW6voDug8fgGN+DIZmTDxTthxb7dQ==",
|
||||
"dependencies": {
|
||||
"axios": "^0.26.0",
|
||||
"form-data": "^4.0.0"
|
||||
|
|
@ -8364,6 +8480,11 @@
|
|||
"follow-redirects": "^1.14.8"
|
||||
}
|
||||
},
|
||||
"node_modules/openapi-types": {
|
||||
"version": "12.1.3",
|
||||
"resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz",
|
||||
"integrity": "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw=="
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-copilot",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"description": "ChatGPT integration for Obsidian",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
"crypto-js": "^4.1.1",
|
||||
"esbuild-plugin-svg": "^0.1.0",
|
||||
"eventsource-parser": "^1.0.0",
|
||||
"langchain": "^0.0.79",
|
||||
"langchain": "^0.0.103",
|
||||
"next-i18next": "^13.2.2",
|
||||
"pouchdb": "^8.0.1",
|
||||
"prop-types": "^15.8.1",
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import {
|
|||
} from "langchain/prompts";
|
||||
import { ContextualCompressionRetriever } from "langchain/retrievers/contextual_compression";
|
||||
import { LLMChainExtractor } from "langchain/retrievers/document_compressors/chain_extract";
|
||||
import { AIChatMessage, HumanChatMessage, SystemChatMessage } from 'langchain/schema';
|
||||
import { AIMessage, HumanMessage, SystemMessage } from 'langchain/schema';
|
||||
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
|
||||
import { MemoryVectorStore } from "langchain/vectorstores/memory";
|
||||
import { Notice } from 'obsidian';
|
||||
|
|
@ -70,6 +70,7 @@ export interface LangChainParams {
|
|||
azureOpenAIApiInstanceName: string,
|
||||
azureOpenAIApiDeploymentName: string,
|
||||
azureOpenAIApiVersion: string,
|
||||
azureOpenAIApiEmbeddingDeploymentName: string,
|
||||
model: string,
|
||||
modelDisplayName: string,
|
||||
temperature: number,
|
||||
|
|
@ -239,12 +240,21 @@ class AIState {
|
|||
}
|
||||
|
||||
getEmbeddingsAPI(): Embeddings {
|
||||
const {
|
||||
openAIApiKey,
|
||||
azureOpenAIApiKey,
|
||||
azureOpenAIApiInstanceName,
|
||||
azureOpenAIApiVersion,
|
||||
azureOpenAIApiEmbeddingDeploymentName,
|
||||
} = this.langChainParams;
|
||||
|
||||
const OpenAIEmbeddingsAPI = new OpenAIEmbeddings({
|
||||
openAIApiKey: this.langChainParams.openAIApiKey,
|
||||
openAIApiKey,
|
||||
maxRetries: 3,
|
||||
maxConcurrency: 3,
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
switch(this.langChainParams.embeddingProvider) {
|
||||
case OPENAI:
|
||||
// Every OpenAIEmbedding call is giving a 'refused to set header user-agent'
|
||||
|
|
@ -264,6 +274,15 @@ class AIState {
|
|||
maxRetries: 3,
|
||||
maxConcurrency: 3,
|
||||
});
|
||||
case AZURE_OPENAI:
|
||||
return new OpenAIEmbeddings({
|
||||
azureOpenAIApiKey,
|
||||
azureOpenAIApiInstanceName,
|
||||
azureOpenAIApiDeploymentName: azureOpenAIApiEmbeddingDeploymentName,
|
||||
azureOpenAIApiVersion,
|
||||
maxRetries: 3,
|
||||
maxConcurrency: 3,
|
||||
});
|
||||
default:
|
||||
console.error('No embedding provider set. Using OpenAI.');
|
||||
return OpenAIEmbeddingsAPI;
|
||||
|
|
@ -461,13 +480,13 @@ class AIState {
|
|||
|
||||
const systemMessage = this.langChainParams.systemMessage || DEFAULT_SYSTEM_PROMPT;
|
||||
const messages = [
|
||||
new SystemChatMessage(systemMessage),
|
||||
new SystemMessage(systemMessage),
|
||||
...chatContext.map((chatMessage) => {
|
||||
return chatMessage.sender === USER_SENDER
|
||||
? new HumanChatMessage(chatMessage.message)
|
||||
: new AIChatMessage(chatMessage.message);
|
||||
? new HumanMessage(chatMessage.message)
|
||||
: new AIMessage(chatMessage.message);
|
||||
}),
|
||||
new HumanChatMessage(userMessage.message),
|
||||
new HumanMessage(userMessage.message),
|
||||
];
|
||||
|
||||
let fullAIResponse = '';
|
||||
|
|
@ -539,6 +558,7 @@ class AIState {
|
|||
await AIState.retrievalChain.call(
|
||||
{
|
||||
query: userMessage,
|
||||
signal: abortController.signal,
|
||||
},
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ const ChatIcons: React.FC<ChatIconsProps> = ({
|
|||
<option value={ChatModelDisplayNames.CLAUDE_INSTANT_1}>{ChatModelDisplayNames.CLAUDE_INSTANT_1}</option>
|
||||
<option value={ChatModelDisplayNames.CLAUDE_INSTANT_1_100K}>{ChatModelDisplayNames.CLAUDE_INSTANT_1_100K}</option> */}
|
||||
<option value={ChatModelDisplayNames.AZURE_GPT_35_TURBO}>{ChatModelDisplayNames.AZURE_GPT_35_TURBO}</option>
|
||||
<option value={ChatModelDisplayNames.AZURE_GPT_35_TURBO_16K}>{ChatModelDisplayNames.AZURE_GPT_35_TURBO_16K}</option>
|
||||
<option value={ChatModelDisplayNames.AZURE_GPT_4}>{ChatModelDisplayNames.AZURE_GPT_4}</option>
|
||||
<option value={ChatModelDisplayNames.AZURE_GPT_4_32K}>{ChatModelDisplayNames.AZURE_GPT_4_32K}</option>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export enum ChatModels {
|
|||
CLAUDE_INSTANT_1 = 'claude-instant-1',
|
||||
CLAUDE_INSTANT_1_100K = 'claude-instant-1-100k',
|
||||
AZURE_GPT_35_TURBO = 'gpt-35-turbo',
|
||||
AZURE_GPT_35_TURBO_16K = 'gpt-35-turbo-16k',
|
||||
}
|
||||
|
||||
export enum ChatModelDisplayNames {
|
||||
|
|
@ -27,6 +28,7 @@ export enum ChatModelDisplayNames {
|
|||
CLAUDE_INSTANT_1 = 'CLAUDE-INSTANT',
|
||||
CLAUDE_INSTANT_1_100K = 'CLAUDE-INSTANT-100K',
|
||||
AZURE_GPT_35_TURBO = 'AZURE GPT-3.5',
|
||||
AZURE_GPT_35_TURBO_16K = 'AZURE GPT-3.5-16K',
|
||||
AZURE_GPT_4 = 'AZURE GPT-4',
|
||||
AZURE_GPT_4_32K = 'AZURE GPT-4 32K',
|
||||
}
|
||||
|
|
@ -40,6 +42,7 @@ export const OPENAI_MODELS = new Set([
|
|||
|
||||
export const AZURE_MODELS = new Set([
|
||||
ChatModelDisplayNames.AZURE_GPT_35_TURBO,
|
||||
ChatModelDisplayNames.AZURE_GPT_35_TURBO_16K,
|
||||
ChatModelDisplayNames.AZURE_GPT_4,
|
||||
ChatModelDisplayNames.AZURE_GPT_4_32K,
|
||||
]);
|
||||
|
|
@ -61,6 +64,7 @@ export const DISPLAY_NAME_TO_MODEL: Record<string, string> = {
|
|||
[ChatModelDisplayNames.CLAUDE_INSTANT_1]: ChatModels.CLAUDE_INSTANT_1,
|
||||
[ChatModelDisplayNames.CLAUDE_INSTANT_1_100K]: ChatModels.CLAUDE_INSTANT_1_100K,
|
||||
[ChatModelDisplayNames.AZURE_GPT_35_TURBO]: ChatModels.AZURE_GPT_35_TURBO,
|
||||
[ChatModelDisplayNames.AZURE_GPT_35_TURBO_16K]: ChatModels.AZURE_GPT_35_TURBO_16K,
|
||||
[ChatModelDisplayNames.AZURE_GPT_4]: ChatModels.GPT_4,
|
||||
[ChatModelDisplayNames.AZURE_GPT_4_32K]: ChatModels.GPT_4_32K,
|
||||
};
|
||||
|
|
@ -92,6 +96,7 @@ export const DEFAULT_SETTINGS: CopilotSettings = {
|
|||
azureOpenAIApiInstanceName: '',
|
||||
azureOpenAIApiDeploymentName: '',
|
||||
azureOpenAIApiVersion: '',
|
||||
azureOpenAIApiEmbeddingDeploymentName: '',
|
||||
defaultModel: ChatModels.GPT_35_TURBO_16K,
|
||||
defaultModelDisplayName: ChatModelDisplayNames.GPT_35_TURBO_16K,
|
||||
temperature: 0.7,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export interface CopilotSettings {
|
|||
azureOpenAIApiInstanceName: string;
|
||||
azureOpenAIApiDeploymentName: string;
|
||||
azureOpenAIApiVersion: string;
|
||||
azureOpenAIApiEmbeddingDeploymentName: string;
|
||||
defaultModel: string;
|
||||
defaultModelDisplayName: string;
|
||||
temperature: number;
|
||||
|
|
@ -421,6 +422,7 @@ export default class CopilotPlugin extends Plugin {
|
|||
azureOpenAIApiInstanceName,
|
||||
azureOpenAIApiDeploymentName,
|
||||
azureOpenAIApiVersion,
|
||||
azureOpenAIApiEmbeddingDeploymentName,
|
||||
temperature,
|
||||
maxTokens,
|
||||
contextTurns,
|
||||
|
|
@ -435,6 +437,7 @@ export default class CopilotPlugin extends Plugin {
|
|||
azureOpenAIApiInstanceName,
|
||||
azureOpenAIApiDeploymentName,
|
||||
azureOpenAIApiVersion,
|
||||
azureOpenAIApiEmbeddingDeploymentName,
|
||||
model: this.settings.defaultModel,
|
||||
modelDisplayName: this.settings.defaultModelDisplayName,
|
||||
temperature: Number(temperature),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
AZURE_OPENAI,
|
||||
COHEREAI,
|
||||
ChatModelDisplayNames,
|
||||
DEFAULT_SETTINGS,
|
||||
|
|
@ -47,6 +48,7 @@ export class CopilotSettingTab extends PluginSettingTab {
|
|||
// ChatModelDisplayNames.CLAUDE_INSTANT_1,
|
||||
// ChatModelDisplayNames.CLAUDE_INSTANT_1_100K,
|
||||
ChatModelDisplayNames.AZURE_GPT_35_TURBO,
|
||||
ChatModelDisplayNames.AZURE_GPT_35_TURBO_16K,
|
||||
ChatModelDisplayNames.AZURE_GPT_4,
|
||||
ChatModelDisplayNames.AZURE_GPT_4_32K,
|
||||
];
|
||||
|
|
@ -198,6 +200,25 @@ export class CopilotSettingTab extends PluginSettingTab {
|
|||
}
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Your Azure OpenAI embedding model deployment name (Optional)")
|
||||
.setDesc(
|
||||
createFragment((frag) => {
|
||||
frag.appendText("Only if you'd like to use Azure as the embedding provider.");
|
||||
})
|
||||
)
|
||||
.addText((text) => {
|
||||
text.inputEl.style.width = "100%";
|
||||
text
|
||||
.setPlaceholder("Azure OpenAI embedding model deployment name")
|
||||
.setValue(this.plugin.settings.azureOpenAIApiEmbeddingDeploymentName)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.azureOpenAIApiEmbeddingDeploymentName = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
containerEl.createEl(
|
||||
'h6',
|
||||
{
|
||||
|
|
@ -304,6 +325,7 @@ export class CopilotSettingTab extends PluginSettingTab {
|
|||
dropdown
|
||||
.addOption(OPENAI, 'OpenAI')
|
||||
.addOption(COHEREAI, 'CohereAI')
|
||||
.addOption(AZURE_OPENAI, 'Azure OpenAI')
|
||||
.addOption(HUGGINGFACE, 'Huggingface')
|
||||
.setValue(this.plugin.settings.embeddingProvider)
|
||||
.onChange(async (value: string) => {
|
||||
|
|
|
|||
|
|
@ -16,5 +16,6 @@
|
|||
"2.2.4": "0.15.0",
|
||||
"2.3.0": "0.15.0",
|
||||
"2.3.1": "0.15.0",
|
||||
"2.3.2": "0.15.0"
|
||||
"2.3.2": "0.15.0",
|
||||
"2.3.3": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue