Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to non-OpenAI providers #43

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface WeaverSettings {
export const DEFAULT_SETTINGS: WeaverSettings = {
activeThreadId: -1,
activeThreadTitle: null,
provider: "https://api.openai.com/v1",
apiKey: "",
engine: "gpt-3.5-turbo",
engineInfo: true,
Expand Down Expand Up @@ -72,13 +73,24 @@ export class WeaverSettingTab extends PluginSettingTab {
containerEl.createEl('h1', { text: 'Weaver Settings' });

containerEl.createEl('h2', {
text: 'OpenAI'
text: 'Text Generation Provider'
});

new Setting(containerEl)
.setName('Provider')
.setDesc('The endpoint URL of a text generation service, such as OpenAI.')
.addText(text => text
.setValue(this.plugin.settings.provider)
.onChange(async (value) => {
this.plugin.settings.provider = value;
await this.plugin.saveSettings();
})
)

let inputEl;
new Setting(containerEl)
.setName('API Key')
.setDesc('In order to generate an API Key, you must first create an OpenAI account.')
.setDesc('In order to generate an API Key, you must first create an account on the providing service.')
.addText(text => text
.setPlaceholder('Enter your API Key')
.setValue(this.plugin.settings.apiKey)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/api/OpenAIRequestFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class OpenAIRequestFormatter {

prepareChatRequestParameters(parameters: WeaverSettings, additionalParameters: any = {}, conversation: IConversation, conversationHistory: IChatMessage[] = []) {
try {
const requestUrlBase = "https://api.openai.com/v1";
const requestUrlBase = parameters.provider;
let requestUrl = `${requestUrlBase}/chat/completions`;

const bodyParameters: BodyParameters = {
Expand Down