Skip to content

Commit

Permalink
fix: replace devMode with answersApiBaseURL param
Browse files Browse the repository at this point in the history
  • Loading branch information
g-francesca committed Jun 21, 2024
1 parent 56ff471 commit e646977
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/answerSession.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Results, AnyDocument, SearchParams, AnyOrama } from '@orama/orama'
import { createId } from '@paralleldrive/cuid2'
import { Collector } from './collector.js'
import { ORAMA_ANSWER_ENDPOINT, ORAMA_ANSWER_ENDPOINT_STAGING } from './constants.js'
import { ORAMA_ANSWER_ENDPOINT } from './constants.js'
import { OramaClient } from './client.js'
import { parseSSE } from './utils.js'

Expand Down Expand Up @@ -38,7 +38,7 @@ export class AnswerSession {

constructor(params: AnswerParams) {
// @ts-expect-error - sorry again TypeScript :-)
const oaramaAnswerHostAddress = params.oramaClient.devMode ? ORAMA_ANSWER_ENDPOINT_STAGING : ORAMA_ANSWER_ENDPOINT
const oaramaAnswerHostAddress = params.oramaClient.answersApiBaseURL || ORAMA_ANSWER_ENDPOINT

this.messages = params.initialMessages || []
this.inferenceType = params.inferenceType
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class OramaClient {
private readonly id = createId()
private readonly api_key: string
private readonly endpoint: string
private readonly devMode: boolean
private readonly answersApiBaseURL: boolean
private readonly collector?: Collector
private readonly cache?: Cache<Results<AnyDocument>>
private searchDebounceTimer?: any // NodeJS.Timer
Expand All @@ -60,7 +60,7 @@ export class OramaClient {
constructor(params: IOramaClient) {
this.api_key = params.api_key
this.endpoint = params.endpoint
this.devMode = !!params.devMode
this.answersApiBaseURL = !!params.answersApiBaseURL

// Telemetry is enabled by default
if (params.telemetry !== false) {
Expand Down
2 changes: 0 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const DEFAULT_TELEMETRY_FLUSH_SIZE = 25

export const ORAMA_ANSWER_ENDPOINT = 'https://answer.api.orama.com'

export const ORAMA_ANSWER_ENDPOINT_STAGING = 'https://staging.answer.api.orama.com'

export const ORAMA_PROXY_ENDPOINT = 'https://secure-proxy.orama.run'
export const ORAMA_PROXY_INIT_ENDPOINT = '/init'
export const ORAMA_PROXY_CHAT_ENDPOINT = '/chat'
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface OramaInitResponse {
export interface IOramaClient {
api_key: string
endpoint: string
devMode?: boolean
answersApiBaseURL?: string
telemetry?: Partial<TelemetryConfig> | false
cache?: Partial<CacheConfig> | false
}
Expand Down

0 comments on commit e646977

Please sign in to comment.