forked from deepset-ai/haystack-home
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* integrations page * tutorial search modal * Add tutorial search backend (deepset-ai#119) * Add tutorial-search api for requests * Debug code * Fetch env variable * Check node version * Add more env variables * see error info to get * return error message * Remove console log and improve error handling * Improve error handling for dc request * Improve api calls * use search api * error state, anchor links, increase title size * disable searching empty query * fix * Remove low scored results * Remove "powered by" text from the logo --------- Co-authored-by: Bilge Yücel <[email protected]>
- Loading branch information
1 parent
bcb59fb
commit def9885
Showing
9 changed files
with
814 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export default async function tutorialSearch(request, response) { | ||
const DC_API_URL = "https://api.cloud.deepset.ai/api/v1/workspaces" | ||
const options = { | ||
method: 'POST', | ||
headers: { | ||
accept: 'application/json', | ||
'content-type': 'application/json', | ||
authorization: `Bearer ${process.env.DC_API_KEY}` | ||
}, | ||
body: JSON.stringify({debug: false, queries: [request.query.query]}) | ||
}; | ||
|
||
try { | ||
const dcResponse = await fetch(`${DC_API_URL}/${process.env.DC_WORKSPACE_NAME}/pipelines/${process.env.DC_PIPELINE_NAME}/search`, options); | ||
|
||
if (dcResponse.status === 200) { | ||
const result = await dcResponse.text(); | ||
response.status(200).send(result) | ||
} else { | ||
response.status(dcResponse.status).send(dcResponse.statusText) | ||
} | ||
} catch (error) { | ||
console.error("Error:", error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"engines": { | ||
"node": ">=18.13.0" | ||
}, | ||
"devDependencies": { | ||
"autoprefixer": "^10.4.12", | ||
"axios": "^0.27.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
// Modal container | ||
.search-modal-container { | ||
position: fixed; | ||
inset: 0; | ||
z-index: 999; | ||
background-color: rgba(0, 0, 0, 0.35); | ||
|
||
pointer-events: none; | ||
opacity: 0; | ||
transition: opacity var(--transition-fast) var(--ease); | ||
|
||
@include sm { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
&.is-active { | ||
pointer-events: auto; | ||
opacity: 1; | ||
|
||
@include sm { | ||
.search-modal { | ||
transform: translateY(0); | ||
} | ||
} | ||
} | ||
|
||
// Inner modal | ||
.search-modal { | ||
position: relative; | ||
width: 100%; | ||
height: 100vh; | ||
height: 100svh; | ||
background-color: var(--color-white); | ||
|
||
@include sm { | ||
max-width: 43.75rem; | ||
margin: 0 1.5rem; | ||
height: auto; | ||
max-height: 75vh; | ||
border-radius: 0.375rem; | ||
transform: translateY(2rem); | ||
transition: transform var(--transition-fast) var(--ease); | ||
} | ||
|
||
// Modal header / search bar | ||
.search-modal-header { | ||
display: flex; | ||
align-items: center; | ||
gap: 1rem; | ||
padding: 1rem; | ||
border-bottom: 1px solid #ebeced; | ||
|
||
height: 4.625rem; | ||
|
||
@include sm { | ||
padding: 1rem 1.5rem; | ||
} | ||
|
||
> .search-wrapper { | ||
width: 80%; | ||
|
||
> input { | ||
width: calc(100% - 3.125rem); | ||
height: 2.5rem !important; | ||
padding: 1rem; | ||
|
||
&::-webkit-search-cancel-button { | ||
-webkit-appearance: none; | ||
appearance: none; | ||
height: 1rem; | ||
width: 1rem; | ||
background-image: url(data:image/svg+xml;base64,PH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Ljg1MTJDMTEuMDQ4IDEwLjkyODUgMTAuOTg0OCAxMC45OTE4IDEwLjkwNzQgMTAuOTkxOFoiIGZpbGw9IiM5MDkwYjIiLz4KPC9zdmc+Cg==); | ||
background-size: 1rem 1rem; | ||
cursor: pointer; | ||
} | ||
|
||
&:focus { | ||
box-shadow: inset 0px 0px 0px 1px var(--color-green); | ||
} | ||
} | ||
|
||
> .search-icon { | ||
height: 2.5rem !important; | ||
cursor: pointer; | ||
transition: background-color var(--transition-fast) var(--ease); | ||
|
||
&:hover { | ||
background-color: var(--color-bg-light-grey); | ||
} | ||
} | ||
} | ||
|
||
.modal-close-btn { | ||
all: unset; | ||
margin-left: auto; | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
// Modal content / search results | ||
.search-modal-content { | ||
height: calc(100vh - 9.25rem); | ||
height: calc(100svh - 9.25rem); | ||
overflow-y: auto; | ||
|
||
@include sm { | ||
height: auto; | ||
max-height: calc(75vh - 9.25rem); | ||
} | ||
|
||
.search-modal-info { | ||
> div { | ||
display: none; | ||
padding: 2.5rem 1.5rem; | ||
flex-direction: column; | ||
gap: 0.5rem; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
max-width: 32rem; | ||
margin: 0 auto; | ||
height: calc(100vh - 9.25rem); | ||
height: calc(100svh - 9.25rem); | ||
|
||
@include sm { | ||
height: auto; | ||
padding: 4.5rem 1.5rem; | ||
} | ||
|
||
> svg { | ||
flex-shrink: 0; | ||
display: block; | ||
} | ||
|
||
h2 { | ||
margin: 1rem 0 0; | ||
font-size: var(--h3-size); | ||
} | ||
|
||
p { | ||
font-size: var(--text-base); | ||
} | ||
|
||
.search-text { | ||
color: var(--color-dark-grey); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Modal footer / powered by Haystack | ||
.search-modal-footer { | ||
padding: 1.5rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 0.5rem; | ||
border-top: 1px solid #ebeced; | ||
|
||
height: 4.625rem; | ||
|
||
> span { | ||
font-size: var(--text-label); | ||
color: var(--color-dark-grey); | ||
} | ||
|
||
> svg { | ||
width: 100%; | ||
max-width: 9rem; | ||
flex-shrink: 0; | ||
} | ||
} | ||
|
||
&.default .search-modal-info > .default { | ||
display: flex; | ||
} | ||
|
||
&.not-found .search-modal-info > .not-found { | ||
display: flex; | ||
} | ||
|
||
&.loading .search-modal-info > .loading { | ||
display: flex; | ||
} | ||
|
||
&.error .search-modal-info > .error { | ||
display: flex; | ||
} | ||
|
||
// Cards | ||
.search-modal-card { | ||
display: flex; | ||
gap: 1rem; | ||
padding: 1.5rem; | ||
text-decoration: none; | ||
transition: background-color var(--transition-fast) var(--ease); | ||
|
||
&:not(:last-child) { | ||
border-bottom: 1px solid #ebeced; | ||
} | ||
|
||
&:hover { | ||
background-color: var(--color-bg-light-grey); | ||
} | ||
|
||
> svg { | ||
flex-shrink: 0; | ||
} | ||
|
||
h3 { | ||
font-size: var(--text-body); | ||
margin-bottom: 0.125rem; | ||
} | ||
|
||
p { | ||
font-size: var(--text-base); | ||
margin-bottom: 0.125rem; | ||
} | ||
|
||
.card-tags { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 0.25rem; | ||
margin-top: 0.25rem; | ||
} | ||
|
||
.card-tags > div { | ||
font-size: 0.75rem; | ||
padding: 0.25rem 0.45rem; | ||
background-color: var(--color-light-grey); | ||
color: var(--color-dark-blue); | ||
text-transform: capitalize; | ||
border-radius: 2px; | ||
display: flex; | ||
align-items: center; | ||
gap: 0.25rem; | ||
|
||
&.featured { | ||
background-color: var(--color-yellow); | ||
} | ||
|
||
.icon { | ||
flex-shrink: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-items: center; | ||
padding-bottom: 1px; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.