-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Obs AI Assistant] Add uuid to knowledge base entries to avoid overwriting accidentally #191043
Changes from 5 commits
e627b85
ede9593
4f5cb94
bafa18b
14854d2
f6b8303
f88d826
f42f1ec
b718ae5
59a9362
51cb688
51495d2
5fdcc4d
d470e39
fb7370b
c63a8f9
a6d55ed
b3f7d3a
b20bd1b
0f531e4
63b171d
08aa578
ad425be
6da17f3
90b5484
923681c
03e8fe6
9b2cf9b
5ea4ac2
91c84d2
b7d2f8e
1d6beef
fc0a970
0aaf657
b0e2781
035a054
6091e81
996e3d8
94996c8
e1ae033
993745e
4022dab
3671085
5708359
6e448b8
3114e7d
094f94c
744a279
55e5800
3f715be
efa7bf2
732f4ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,9 +79,10 @@ export type ConversationUpdateRequest = ConversationRequestBase & { | |
|
||
export interface KnowledgeBaseEntry { | ||
'@timestamp': string; | ||
id: string; | ||
id: string; // unique ID | ||
doc_id?: string; // human readable ID generated by the LLM and used by the LLM to lookup and update existing entries. TODO: rename `doc_id` to `lookup_id` | ||
title?: string; | ||
text: string; | ||
doc_id: string; | ||
confidence: 'low' | 'medium' | 'high'; | ||
is_correction: boolean; | ||
type?: 'user_instruction' | 'contextual'; | ||
|
@@ -94,12 +95,12 @@ export interface KnowledgeBaseEntry { | |
} | ||
|
||
export interface Instruction { | ||
doc_id: string; | ||
id: string; | ||
text: string; | ||
} | ||
|
||
export interface AdHocInstruction { | ||
doc_id?: string; | ||
id?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
text: string; | ||
instruction_type: 'user_instruction' | 'application_instruction'; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { v4 } from 'uuid'; | ||
import { KnowledgeBaseType } from '../../common/types'; | ||
import type { FunctionRegistrationParameters } from '.'; | ||
import { KnowledgeBaseEntryRole } from '../../common'; | ||
|
@@ -31,7 +32,7 @@ export function registerSummarizationFunction({ | |
id: { | ||
type: 'string', | ||
description: | ||
'An id for the document. This should be a short human-readable keyword field with only alphabetic characters and underscores, that allow you to update it later.', | ||
'A lookup id for the document. This should be a short human-readable keyword field with only alphabetic characters and underscores, that allow you to find and update it later.', | ||
}, | ||
text: { | ||
type: 'string', | ||
|
@@ -62,16 +63,21 @@ export function registerSummarizationFunction({ | |
], | ||
}, | ||
}, | ||
( | ||
{ arguments: { id, text, is_correction: isCorrection, confidence, public: isPublic } }, | ||
async ( | ||
{ arguments: { id: docId, text, is_correction: isCorrection, confidence, public: isPublic } }, | ||
signal | ||
) => { | ||
// The LLM should be able to update an existing entry by providing the same doc_id | ||
// if no existing entry is found, we generate a uuid | ||
const id = await client.getUuidFromDocId(docId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The LLM will (blindly) suggest a doc_id, without any information about existing entries. With the A better approach might be to get rid of |
||
|
||
return client | ||
.addKnowledgeBaseEntry({ | ||
entry: { | ||
doc_id: id, | ||
id: id ?? v4(), | ||
title: docId, // use doc_id as title for now | ||
doc_id: docId, | ||
role: KnowledgeBaseEntryRole.AssistantSummarization, | ||
id, | ||
text, | ||
is_correction: isCorrection, | ||
type: KnowledgeBaseType.Contextual, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ const chatCompleteBaseRt = t.type({ | |
]), | ||
instructions: t.array( | ||
t.intersection([ | ||
t.partial({ doc_id: t.string }), | ||
t.partial({ id: t.string }), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still possible to overwrite existing instructions by specifying the |
||
t.type({ | ||
text: t.string, | ||
instruction_type: t.union([ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
is globally unique,doc_id
is only unique per user. Multiple entries can be assigned the samedoc_id
if they are created for different users.