Skip to content

Commit 1505a3e

Browse files
authored
Merge pull request #93 from oramasearch/fix/integration-ui-components-orama-core
Integration of orama-core to the ui components
2 parents e96d5cc + 8e0aa1c commit 1505a3e

File tree

29 files changed

+16410
-13152
lines changed

29 files changed

+16410
-13152
lines changed

apps/demo-angular/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"tslib": "^2.6.3",
2424
"@orama/wc-components": "workspace:*",
2525
"@orama/angular-components": "workspace:*",
26+
"@orama/core": "^0.1.3",
2627
"zone.js": "~0.14.7"
2728
},
2829
"devDependencies": {

apps/demo-angular/src/app/app.component.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ <h1>App Angular</h1>
66
<section>
77
<h2>Stencil Components</h2>
88
<orama-chat-box
9-
[index]="{
10-
api_key: 'yl2JSnjLNBV6FVfUWEyadpjFr6KzPiDR',
11-
endpoint: 'https://cloud.orama.run/v1/indexes/recipes-m7w9mm',
12-
}"
9+
[clientInstance]="clientInstance"
1310
></orama-chat-box>
1411
</section>
1512
</main>

apps/demo-angular/src/app/app.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
import { Component } from '@angular/core'
2+
import { CollectionManager } from '@orama/core'
3+
4+
const clientInstance = new CollectionManager({
5+
url:'https://oramacore.orama.foo',
6+
collectionID: 'cxlenmho72jp3qpbdphbmfdn',
7+
readAPIKey: 'caTS1G81uC8uBoWICSQYzmGjGVBCqxrf',
8+
})
29

310
@Component({
411
selector: 'app-root',
@@ -7,4 +14,5 @@ import { Component } from '@angular/core'
714
})
815
export class AppComponent {
916
title = 'demo-angular'
17+
clientInstance = clientInstance
1018
}

apps/demo-nextjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@orama/core": "^0.1.3",
1213
"@orama/react-components": "workspace:*",
1314
"next": "15.1.4",
1415
"radix-ui": "^1.1.2",

apps/demo-nextjs/src/app/Orama.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
'use client'
22
import React from 'react'
33
import { Tabs } from 'radix-ui'
4+
import { CollectionManager } from '@orama/core'
45
import { OramaChatBox, OramaSearchBox, OramaSearchButton } from '@orama/react-components'
56

6-
const API_KEY = 'LerNlbp6379jVKaPs4wt2nZT4MJZbU1J'
7-
const ENDPOINT = 'https://cloud.orama.run/v1/indexes/docs-orama-b3f5xd'
7+
const clientInstance = new CollectionManager({
8+
url: 'https://oramacore.orama.foo',
9+
collectionID: 'cxlenmho72jp3qpbdphbmfdn',
10+
readAPIKey: 'caTS1G81uC8uBoWICSQYzmGjGVBCqxrf',
11+
})
812

913
const Orama = () => {
1014
const [initialPrompt, setInitialPrompt] = React.useState('')
1115

1216
return (
1317
<div>
1418
<OramaSearchButton style={{ marginBottom: '24px' }} />
15-
<OramaSearchBox index={{ api_key: API_KEY, endpoint: ENDPOINT }} colorScheme={'light'} />
19+
<OramaSearchBox oramaCoreClientInstance={clientInstance} colorScheme={'light'} />
1620
<Tabs.Root className="TabsRoot" defaultValue="tab1">
1721
<Tabs.List className="TabsList" aria-label="Manage your account">
1822
<Tabs.Trigger className="TabsTrigger" value="tab1">
@@ -29,7 +33,7 @@ const Orama = () => {
2933
<p className="Text">Tab with chatbox here</p>
3034
<div style={{ height: '400px' }}>
3135
<OramaChatBox
32-
index={{ api_key: API_KEY, endpoint: ENDPOINT }}
36+
oramaCoreClientInstance={clientInstance}
3337
clearChatOnDisconnect={false}
3438
onClearChat={() => setInitialPrompt('')}
3539
onStartConversation={(e: Event) => console.log('onStartConversation', e)}

apps/demo-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"preview": "vite preview"
1212
},
1313
"dependencies": {
14+
"@orama/core": "^0.1.3",
1415
"@orama/react-components": "workspace:*",
1516
"@oramacloud/client": "^2.1.4",
1617
"react": "^19",

apps/demo-react/src/App.tsx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { OramaChatBox, OramaSearchBox, OramaSearchButton } from '@orama/react-components'
22
import './App.css'
3-
43
import { BrowserRouter, Routes, Route, NavLink, Navigate } from 'react-router'
4+
import { CollectionManager } from '@orama/core'
5+
6+
const ORAMACORE_ENDPOINT = 'https://oramacore.orama.foo'
7+
const ORAMACORE_COLLECTION_ID = 'cxlenmho72jp3qpbdphbmfdn'
8+
const ORAMACORE_READ_API_KEY = 'caTS1G81uC8uBoWICSQYzmGjGVBCqxrf'
9+
10+
// Create a CollectionManager instance
11+
const collectionManager = new CollectionManager({
12+
url: ORAMACORE_ENDPOINT,
13+
collectionID: ORAMACORE_COLLECTION_ID,
14+
readAPIKey: ORAMACORE_READ_API_KEY,
15+
})
516

6-
const API_KEY = 'LerNlbp6379jVKaPs4wt2nZT4MJZbU1J'
7-
const ENDPOINT = 'https://cloud.orama.run/v1/indexes/docs-orama-b3f5xd'
817

918
function App() {
1019
return (
@@ -35,15 +44,13 @@ const ChatBoxPage = () => {
3544
<h2 style={{ textAlign: 'center' }}>CHAT BOX</h2>
3645
<div className="component-row">
3746
<OramaChatBox
38-
index={{
39-
api_key: API_KEY,
40-
endpoint: ENDPOINT,
41-
}}
47+
sourcesMap={{description: "content"}}
48+
oramaCoreClientInstance={collectionManager}
4249
style={{ height: '600px' }}
4350
onAnswerSourceClick={(e: Event) => console.log(e)}
4451
onAnswerGenerated={(e: Event) => console.log(e)}
45-
chatMarkdownLinkTitle={({ text }) => text?.toUpperCase()}
46-
chatMarkdownLinkHref={({ href }) => href}
52+
chatMarkdownLinkTitle={({ text }: { text: string; href: string }) => text?.toUpperCase()}
53+
chatMarkdownLinkHref={({ href }: { text: string; href: string }) => href}
4754
onChatMarkdownLinkClicked={(e: Event) => {
4855
console.log(e)
4956
e.preventDefault()
@@ -61,19 +68,17 @@ const SearchBoxPage = () => {
6168
<main>
6269
<h2 style={{ textAlign: 'center' }}>SEARCH BOX</h2>
6370
<div className="component-row">
64-
<OramaSearchButton colorScheme="system">Search</OramaSearchButton>
71+
<OramaSearchButton colorScheme="system">Search</OramaSearchButton>
6572
<OramaSearchBox
73+
resultMap={{description: "content"}}
6674
onModalClosed={() => {
6775
console.log('closed')
6876
}}
69-
onModalStatusChanged={(e) => {
77+
onModalStatusChanged={(e: CustomEvent) => {
7078
console.log('Status changed to: ', e.detail.open)
7179
}}
7280
colorScheme="system"
73-
index={{
74-
api_key: API_KEY,
75-
endpoint: ENDPOINT,
76-
}}
81+
oramaCoreClientInstance={collectionManager}
7782
suggestions={['Suggestion 1', 'Suggestion 2', 'Suggestion 3']}
7883
onSearchCompleted={(e: Event) => console.log(e)}
7984
onSearchResultClick={(e) => {
@@ -85,8 +90,8 @@ const SearchBoxPage = () => {
8590
console.log(e)
8691
e.preventDefault()
8792
}}
88-
chatMarkdownLinkTitle={({ text }) => text?.toUpperCase()}
89-
chatMarkdownLinkHref={({ href }) => href}
93+
chatMarkdownLinkTitle={({ text }: { text: string; href: string }) => text?.toUpperCase()}
94+
chatMarkdownLinkHref={({ href }: { text: string; href: string }) => href}
9095
onChatMarkdownLinkClicked={(e) => {
9196
alert('Callback on client side')
9297
e.preventDefault()

apps/demo-vue/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@orama/core": "^0.1.3",
1314
"@orama/vue-components": "workspace:*",
1415
"vue": "^3.4.30"
1516
},

apps/demo-vue/src/App.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<script setup>
2+
import { CollectionManager } from '@orama/core'
3+
4+
const clientInstance = new CollectionManager({
5+
url:'https://oramacore.orama.foo',
6+
collectionID: 'cxlenmho72jp3qpbdphbmfdn',
7+
readAPIKey: 'caTS1G81uC8uBoWICSQYzmGjGVBCqxrf',
8+
})
9+
</script>
110
<template>
211
<main>
312
<section>
@@ -7,10 +16,7 @@
716
<section>
817
<h2>Stencil Components</h2>
918
<div class="component-row">
10-
<orama-chat-box .index="{
11-
api_key: 'yl2JSnjLNBV6FVfUWEyadpjFr6KzPiDR',
12-
endpoint: 'https://cloud.orama.run/v1/indexes/recipes-m7w9mm',
13-
}" />
19+
<orama-chat-box .clientInstance="clientInstance" />
1420
</div>
1521
</section>
1622
</main>

apps/demo-vue/src/vite-env.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
/// <reference types="vite/client" />
1+
// <reference types="vite/client" />
2+
3+
declare module '*.vue' {
4+
import type { DefineComponent } from 'vue'
5+
const component: DefineComponent<{}, {}, any>
6+
export default component
7+
}

0 commit comments

Comments
 (0)