Skip to content

Commit

Permalink
plugin-knowledge-bases: update api endpoint to use source ids #BLT-983 (
Browse files Browse the repository at this point in the history
#2880)

## Description

Update endpoint to `/knowledge_base/inference/` 
This endpoint use source ids instead of source names
  • Loading branch information
Iru89 authored Aug 13, 2024
1 parent 14d758a commit 36aea4c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,31 @@ All notable changes to Botonic will be documented in this file.
Click to see more.
</summary>

## [0.29.X] - aaaa-mm-dd
## [0.30.X] - aaaa-mm-dd

### Added

### Changed

### Fixed

</details>

## [0.29.0] - 2024-08-14

### Added

### Changed

- [@botonic/plugin-knowledge-bases](https://www.npmjs.com/package/@botonic/plugin-knowledge-bases)

- [Update inference endpoint to use source ids instead of source names](https://github.com/hubtype/botonic/pull/2880)

### Fixed

## [0.28.0] - 2024-07-09

### Added
### Added

- [Project](https://github.com/hubtype/botonic)

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 36aea4c

Please sign in to comment.