Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/refine chat window #192

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export const FILE_EDITORS = [
export const LERNER_ID = "01acc3e5-0af7-49e6-ad7a-a760bd12dc40";
export const TRAINING_MODE = "training";

export const KNOWLEDGE_COLLECTION = "BotSharp";
export const DEFAULT_KNOWLEDGE_COLLECTION = "BotSharp";
10 changes: 5 additions & 5 deletions src/lib/services/knowledge-base-service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KNOWLEDGE_COLLECTION } from '$lib/helpers/constants.js';
import { DEFAULT_KNOWLEDGE_COLLECTION } from '$lib/helpers/constants.js';
import { replaceUrl } from '$lib/helpers/http.js';
import { endpoints } from './api-endpoints.js';
import axios from 'axios';
Expand All @@ -19,7 +19,7 @@ export async function getKnowledgeCollections() {
*/
export async function searchKnowledge(request, collection = null) {
const url = replaceUrl(endpoints.knowledgeBaseSearchUrl, {
collection: collection || KNOWLEDGE_COLLECTION
collection: collection || DEFAULT_KNOWLEDGE_COLLECTION
});

const response = await axios.post(url, { ...request });
Expand All @@ -33,7 +33,7 @@ export async function searchKnowledge(request, collection = null) {
*/
export async function getKnowledgeData(filter, collection = null) {
const url = replaceUrl(endpoints.knowledgeBaseDataListUrl, {
collection: collection || KNOWLEDGE_COLLECTION
collection: collection || DEFAULT_KNOWLEDGE_COLLECTION
});

const response = await axios.post(url, { ...filter });
Expand All @@ -48,7 +48,7 @@ export async function getKnowledgeData(filter, collection = null) {
*/
export async function deleteKnowledgeData(id, collection = null) {
const url = replaceUrl(endpoints.knowledgeBaseDeleteDataUrl, {
collection: collection || KNOWLEDGE_COLLECTION,
collection: collection || DEFAULT_KNOWLEDGE_COLLECTION,
id: id
});

Expand All @@ -66,7 +66,7 @@ export async function deleteKnowledgeData(id, collection = null) {
*/
export async function uploadKnowledge(file, collection = null, startPageNum = null, endPageNum = null) {
const url = replaceUrl(endpoints.knowledgeBaseUploadUrl, {
collection: collection || KNOWLEDGE_COLLECTION
collection: collection || DEFAULT_KNOWLEDGE_COLLECTION
});

const formData = new FormData();
Expand Down
9 changes: 5 additions & 4 deletions src/routes/page/knowledge-base/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Loader from '$lib/common/Loader.svelte';
import LoadingDots from '$lib/common/LoadingDots.svelte';
import LoadingToComplete from '$lib/common/LoadingToComplete.svelte';
import { KNOWLEDGE_COLLECTION } from '$lib/helpers/constants';
import { DEFAULT_KNOWLEDGE_COLLECTION } from '$lib/helpers/constants';
import { getKnowledgeCollections, getKnowledgeData, searchKnowledge } from '$lib/services/knowledge-base-service';
import KnowledgeItem from './knowledge-table/knowledge-item.svelte';

Expand All @@ -20,7 +20,7 @@
const confidence = 0.5;

let show_demo = false;
let selectedCollection = KNOWLEDGE_COLLECTION;
let selectedCollection = DEFAULT_KNOWLEDGE_COLLECTION;
let text = "";
let isSearching = false;
let searchDone = false;
Expand Down Expand Up @@ -96,11 +96,12 @@
function getCollections() {
return new Promise((resolve, reject) => {
getKnowledgeCollections().then(res => {
collections = res || [ KNOWLEDGE_COLLECTION ];
const retCollections = res || [];
collections = retCollections.length === 0 ? [ DEFAULT_KNOWLEDGE_COLLECTION ] : retCollections;
selectedCollection = collections[0];
resolve(res);
}).catch(err => {
collections = [ KNOWLEDGE_COLLECTION ];
collections = [ DEFAULT_KNOWLEDGE_COLLECTION ];
selectedCollection = collections[0];
reject(err);
});
Expand Down
Loading