Skip to content

Commit

Permalink
fix: openai needs an auth header to get the models
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdjohnson committed Jun 25, 2024
1 parent 6b90a17 commit 8055fd5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/features/connections/servers/OpenAiServerConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SnapshotIn } from 'mobx-state-tree'
import { IObservableArray, makeObservable, observable } from 'mobx'
import axios from 'axios'
import camelcaseKeys from 'camelcase-keys'
import _ from 'lodash'

import { SortType as SelectionPanelSortType } from '~/components/SelectionTablePanel'
import ServerConnection from '~/features/connections/servers/ServerConnection'
Expand Down Expand Up @@ -65,9 +66,11 @@ class OpenAiServerConnection extends ServerConnection<IOpenAiModel> {
})

async _fetchLmModels(host: string): Promise<OpenAiLanguageModel[]> {
const apiKey = _.find(this.parameters, { field: 'apiKey' })?.parsedValue() || 'not-needed'

const {
data: { data },
} = await axios.get(`${host}/models`)
} = await axios.get(`${host}/models`, { headers: { Authorization: `Bearer ${apiKey}` } })

type IOpenAiModelResponse = Omit<IOpenAiModel, '_id' | 'owned_by'> & {
id: string
Expand Down

0 comments on commit 8055fd5

Please sign in to comment.