Skip to content

Commit

Permalink
refactor(plugin-knowledge-bases): change api endpoint and response
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru89 committed Aug 1, 2024
1 parent 14d758a commit 3e0fc7e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/botonic-plugin-knowledge-bases/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@babel/runtime": "^7.23.9",
"@botonic/core": "^0.28.1",
"@botonic/core": "^0.28.2",
"axios": "^1.7.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ export class HubtypeApiService {
answer: string
has_knowledge: boolean
is_faithful: boolean
sources: {
knowledge_base_id: string
knowledge_source_id: string
knowledge_chunk_id: string
}[]
chunk_ids: string[]
}>
> {
return await axios({
method: 'POST',
url: `${this.host}/external/v1/ai/knowledge_bases/inference/`,
url: `${this.host}/external/v1/ai/knowledge_base/inference/`,
headers: {
Authorization: `Bearer ${authToken}`,
'Content-Type': 'application/json',
Expand Down
10 changes: 1 addition & 9 deletions packages/botonic-plugin-knowledge-bases/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,13 @@ export default class BotonicPluginKnowledgeBases implements Plugin {
sources
)

const responseSources = response.data.sources.map(source => {
return {
knowledgeBaseId: source.knowledge_base_id,
knowledgeSourceId: source.knowledge_source_id,
knowledgeChunkId: source.knowledge_chunk_id,
}
})

return {
inferenceId: response.data.inference_id,
question: response.data.question,
answer: response.data.answer,
hasKnowledge: response.data.has_knowledge,
isFaithuful: response.data.is_faithful,
sources: responseSources,
chunkIds: response.data.chunk_ids,
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions packages/botonic-plugin-knowledge-bases/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,5 @@ export interface KnowledgeBaseResponse {
answer: string
hasKnowledge: boolean
isFaithuful: boolean
sources: {
knowledgeBaseId: string
knowledgeSourceId: string
knowledgeChunkId: string
}[]
chunkIds: string[]
}

0 comments on commit 3e0fc7e

Please sign in to comment.