Skip to content

Commit

Permalink
chore: add orama OSS
Browse files Browse the repository at this point in the history
  • Loading branch information
rjborba committed Oct 17, 2024
1 parent 204462e commit 53a204d
Show file tree
Hide file tree
Showing 10 changed files with 438 additions and 198 deletions.
4 changes: 2 additions & 2 deletions packages/ui-stencil/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"types": "dist/types/index.d.ts",
"dependencies": {
"@orama/highlight": "^0.1.6",
"@orama/orama": "3.0.0-rc-1",
"@orama/switch": "3.0.0-rc-1",
"@orama/orama": "3.0.0",
"@orama/switch": "3.0.0",
"@oramacloud/client": "1.3.17",
"@phosphor-icons/webcomponents": "^2.1.5",
"@stencil/core": "^4.19.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/ui-stencil/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import { ButtonProps } from "./components/internal/orama-button/orama-button";
import { CloudIndexConfig, ColorScheme, ResultMap, SearchResult, SearchResultBySection, SourcesMap } from "./types/index";
import { TChatInteraction } from "./context/chatContext";
import { OramaClient } from "@oramacloud/client";
import { AnyOrama, Orama, SearchParams } from "@orama/orama";
import { Facet } from "./components/internal/orama-facets/orama-facets";
import { InputProps } from "./components/internal/orama-input/orama-input";
import { ModalStatus } from "./components/internal/orama-modal/orama-modal";
import { HighlightOptions } from "@orama/highlight";
import { TThemeOverrides } from "./config/theme";
import { AnyOrama, Orama, SearchParams } from "@orama/orama";
import { TThemeOverrides as TThemeOverrides1 } from "./components.d";
import { SearchResultsProps } from "./components/internal/orama-search-results/orama-search-results";
import { TextProps } from "./components/internal/orama-text/orama-text";
export { ButtonProps } from "./components/internal/orama-button/orama-button";
export { CloudIndexConfig, ColorScheme, ResultMap, SearchResult, SearchResultBySection, SourcesMap } from "./types/index";
export { TChatInteraction } from "./context/chatContext";
export { OramaClient } from "@oramacloud/client";
export { AnyOrama, Orama, SearchParams } from "@orama/orama";
export { Facet } from "./components/internal/orama-facets/orama-facets";
export { InputProps } from "./components/internal/orama-input/orama-input";
export { ModalStatus } from "./components/internal/orama-modal/orama-modal";
export { HighlightOptions } from "@orama/highlight";
export { TThemeOverrides } from "./config/theme";
export { AnyOrama, Orama, SearchParams } from "@orama/orama";
export { TThemeOverrides as TThemeOverrides1 } from "./components.d";
export { SearchResultsProps } from "./components/internal/orama-search-results/orama-search-results";
export { TextProps } from "./components/internal/orama-text/orama-text";
Expand Down Expand Up @@ -58,7 +58,7 @@ export namespace Components {
}
interface OramaChatBox {
"autoFocus": boolean;
"clientInstance"?: OramaClient;
"clientInstance"?: OramaClient | Orama<unknown>;
"index"?: CloudIndexConfig;
"linksRel"?: string;
"linksTarget"?: string;
Expand Down Expand Up @@ -138,7 +138,7 @@ export namespace Components {
}
interface OramaSearchBox {
"chatPlaceholder"?: string;
"clientInstance"?: OramaClient;
"clientInstance"?: OramaClient | Orama<unknown>;
"colorScheme"?: ColorScheme;
"disableChat"?: boolean;
"facetProperty"?: string;
Expand Down Expand Up @@ -514,7 +514,7 @@ declare namespace LocalJSX {
}
interface OramaChatBox {
"autoFocus"?: boolean;
"clientInstance"?: OramaClient;
"clientInstance"?: OramaClient | Orama<unknown>;
"index"?: CloudIndexConfig;
"linksRel"?: string;
"linksTarget"?: string;
Expand Down Expand Up @@ -596,7 +596,7 @@ declare namespace LocalJSX {
}
interface OramaSearchBox {
"chatPlaceholder"?: string;
"clientInstance"?: OramaClient;
"clientInstance"?: OramaClient | Orama<unknown>;
"colorScheme"?: ColorScheme;
"disableChat"?: boolean;
"facetProperty"?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { generateRandomID, initOramaClient, validateCloudIndexConfig } from '@/u
import type { CloudIndexConfig, SourcesMap } from '@/types'
import type { OramaClient } from '@oramacloud/client'
import '@phosphor-icons/webcomponents/dist/icons/PhArrowClockwise.mjs'
import type { Orama } from '@orama/orama'
import { Switch } from '@orama/switch'

@Component({
tag: 'orama-chat-box',
Expand All @@ -14,7 +16,7 @@ import '@phosphor-icons/webcomponents/dist/icons/PhArrowClockwise.mjs'
export class ChatBox {
@Element() el: HTMLElement
@Prop() index?: CloudIndexConfig
@Prop() clientInstance?: OramaClient
@Prop() clientInstance?: OramaClient | Orama<unknown>
@Prop() sourceBaseUrl?: string
@Prop() linksTarget?: string
@Prop() linksRel?: string
Expand All @@ -24,7 +26,6 @@ export class ChatBox {
@Prop() autoFocus = true
@Prop() systemPrompts?: string[]

@State() oramaClient: OramaClient
@State() componentID = generateRandomID('chat-box')

@Watch('index')
Expand All @@ -39,9 +40,10 @@ export class ChatBox {

startChatService() {
validateCloudIndexConfig(this.el, this.index, this.clientInstance)
this.oramaClient = this.clientInstance || initOramaClient(this.index)
const oramaClient = this.clientInstance || initOramaClient(this.index)
const switchInstance = new Switch(oramaClient)

chatContext.chatService = new ChatService(this.oramaClient)
chatContext.chatService = new ChatService(switchInstance)
}

render() {
Expand Down
26 changes: 12 additions & 14 deletions packages/ui-stencil/src/components/orama-chat-box/readme.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# orama-chat-box



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ---------------- | ----------------- | ----------- | ---------------------------------------------------------- | ----------- |
| `autoFocus` | `auto-focus` | | `boolean` | `true` |
| `clientInstance` | -- | | `OramaClient` | `undefined` |
| `index` | -- | | `{ api_key: string; endpoint: string; }` | `undefined` |
| `linksRel` | `links-rel` | | `string` | `undefined` |
| `linksTarget` | `links-target` | | `string` | `undefined` |
| `placeholder` | `placeholder` | | `string` | `undefined` |
| `sourceBaseUrl` | `source-base-url` | | `string` | `undefined` |
| `sourcesMap` | -- | | `{ title?: string; path?: string; description?: string; }` | `undefined` |
| `suggestions` | -- | | `string[]` | `undefined` |
| `systemPrompts` | -- | | `string[]` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ---------------- | ----------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `autoFocus` | `auto-focus` | | `boolean` | `true` |
| `clientInstance` | -- | | `FunctionComponents<unknown> & Internals<unknown, Index, DocumentsStore, Sorter> & ArrayCallbackComponents<any> & OramaID & { plugins: OramaPlugin<unknown>[]; } \| OramaClient` | `undefined` |
| `index` | -- | | `{ api_key: string; endpoint: string; }` | `undefined` |
| `linksRel` | `links-rel` | | `string` | `undefined` |
| `linksTarget` | `links-target` | | `string` | `undefined` |
| `placeholder` | `placeholder` | | `string` | `undefined` |
| `sourceBaseUrl` | `source-base-url` | | `string` | `undefined` |
| `sourcesMap` | -- | | `{ title?: string; path?: string; description?: string; }` | `undefined` |
| `suggestions` | -- | | `string[]` | `undefined` |
| `systemPrompts` | -- | | `string[]` | `undefined` |


## Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import type { HighlightOptions } from '@orama/highlight'
import type { OramaClient } from '@oramacloud/client'
import type { CloudIndexConfig, ColorScheme, ResultMap, SourcesMap } from '@/types'
import type { TThemeOverrides } from '@/config/theme'
import { Switch } from '@orama/switch'

// TODO: AI components should be lazyly loaded. In case of Disable AI flag, it should not be loaded at all
// https://linear.app/oramasearch/issue/ORM-1824/ai-components-should-be-lazyly-loaded-in-case-of-disable-ai-flag-they

@Component({
tag: 'orama-search-box',
Expand All @@ -23,7 +27,7 @@ export class SearchBox {
@Prop() themeConfig?: Partial<TThemeOverrides>
@Prop() colorScheme?: ColorScheme = 'light'
@Prop() index?: CloudIndexConfig
@Prop() clientInstance?: OramaClient
@Prop() clientInstance?: OramaClient | Orama<unknown>
@Prop({ mutable: true }) open = false
@Prop() facetProperty?: string
@Prop() resultMap?: Partial<ResultMap> = {}
Expand All @@ -42,7 +46,6 @@ export class SearchBox {
@Prop() suggestions?: string[]
@Prop() searchParams?: SearchParams<Orama<AnyOrama | OramaClient>>

@State() oramaClient: OramaClient
@State() componentID = generateRandomID('search-box')
@State() systemScheme: Omit<ColorScheme, 'system'> = 'light'
@State() windowWidth: number
Expand Down Expand Up @@ -134,10 +137,11 @@ export class SearchBox {

startServices() {
validateCloudIndexConfig(this.htmlElement, this.index, this.clientInstance)
this.oramaClient = this.clientInstance ? this.clientInstance : initOramaClient(this.index)
const oramaClient = this.clientInstance ? this.clientInstance : initOramaClient(this.index)
const switchInstance = new Switch(oramaClient)

searchState.searchService = new SearchService(this.oramaClient)
chatContext.chatService = new ChatService(this.oramaClient)
searchState.searchService = new SearchService(switchInstance)
chatContext.chatService = new ChatService(switchInstance)
}

componentWillLoad() {
Expand Down
Loading

0 comments on commit 53a204d

Please sign in to comment.