-
Notifications
You must be signed in to change notification settings - Fork 11
No longer hardcoding models #31
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| # Copy this file to .env and add your OpenAI API key | ||
| VITE_OPENAI_API_KEY=your_openai_api_key_here | ||
| # Optional: only set for Azure or other custom OpenAI-compatible endpoints. | ||
| # Omit for standard OpenAI API usage. | ||
| VITE_OPENAI_BASE_URL=your_openai_base_url_here | ||
| # Optional: API version is typically Azure-specific/custom-endpoint specific. | ||
| # Omit for standard OpenAI API usage. | ||
| VITE_OPENAI_API_VERSION=2024-12-01-preview | ||
| VITE_OPENAI_MODEL=gpt-4.1-mini | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ interface ChatMessage { | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export class ChatService { | ||||||||||||||||||||||||||||||||
| private client: OpenAI; | ||||||||||||||||||||||||||||||||
| private model: string; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| constructor() { | ||||||||||||||||||||||||||||||||
| // In a real application, you'd want to handle the API key more securely | ||||||||||||||||||||||||||||||||
|
|
@@ -19,8 +20,15 @@ export class ChatService { | |||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const baseURL = import.meta.env.VITE_OPENAI_BASE_URL || process.env.OPENAI_BASE_URL; | ||||||||||||||||||||||||||||||||
| const apiVersion = import.meta.env.VITE_OPENAI_API_VERSION || process.env.OPENAI_API_VERSION; | ||||||||||||||||||||||||||||||||
| this.model = import.meta.env.VITE_OPENAI_MODEL || process.env.OPENAI_MODEL || "gpt-4.1"; | ||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+25
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| this.client = new OpenAI({ | ||||||||||||||||||||||||||||||||
| apiKey, | ||||||||||||||||||||||||||||||||
| ...(baseURL ? { baseURL } : {}), | ||||||||||||||||||||||||||||||||
| ...(apiVersion ? { defaultQuery: { "api-version": apiVersion } } : {}), | ||||||||||||||||||||||||||||||||
| ...(baseURL ? { defaultHeaders: { "api-key": apiKey } } : {}), | ||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+31
|
||||||||||||||||||||||||||||||||
| this.model = import.meta.env.VITE_OPENAI_MODEL || process.env.OPENAI_MODEL || "gpt-4.1"; | |
| this.client = new OpenAI({ | |
| apiKey, | |
| ...(baseURL ? { baseURL } : {}), | |
| ...(apiVersion ? { defaultQuery: { "api-version": apiVersion } } : {}), | |
| ...(baseURL ? { defaultHeaders: { "api-key": apiKey } } : {}), | |
| const isAzureOpenAI = Boolean(apiVersion); | |
| this.model = import.meta.env.VITE_OPENAI_MODEL || process.env.OPENAI_MODEL || "gpt-4.1"; | |
| this.client = new OpenAI({ | |
| apiKey, | |
| ...(baseURL ? { baseURL } : {}), | |
| ...(isAzureOpenAI ? { defaultQuery: { "api-version": apiVersion } } : {}), | |
| ...(isAzureOpenAI ? { defaultHeaders: { "api-key": apiKey } } : {}), |
Uh oh!
There was an error while loading. Please reload this page.