mirror of
https://github.com/SillyTavern/SillyTavern-Extras.git
synced 2026-04-30 19:31:20 +00:00
Add arbitrary metadata to message
This commit is contained in:
@@ -333,7 +333,8 @@ WAV audio file.
|
|||||||
"id": "633a4bd1-8350-46b5-9ef2-f5d27acdecb7",
|
"id": "633a4bd1-8350-46b5-9ef2-f5d27acdecb7",
|
||||||
"date": 1684164339877,
|
"date": 1684164339877,
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": "Hello, AI world!"
|
"content": "Hello, AI world!",
|
||||||
|
"meta": "this is meta"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "8a2ed36b-c212-4a1b-84a3-0ffbe0896506",
|
"id": "8a2ed36b-c212-4a1b-84a3-0ffbe0896506",
|
||||||
@@ -367,7 +368,8 @@ WAV audio file.
|
|||||||
"date": 1684164339877,
|
"date": 1684164339877,
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": "Hello, AI world!",
|
"content": "Hello, AI world!",
|
||||||
"distance": 0.31
|
"distance": 0.31,
|
||||||
|
"meta": "this is meta"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "8a2ed36b-c212-4a1b-84a3-0ffbe0896506",
|
"id": "8a2ed36b-c212-4a1b-84a3-0ffbe0896506",
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ def chromadb_add_messages():
|
|||||||
|
|
||||||
documents = [m['content'] for m in data['messages']]
|
documents = [m['content'] for m in data['messages']]
|
||||||
ids = [m['id'] for m in data['messages']]
|
ids = [m['id'] for m in data['messages']]
|
||||||
metadatas = [{'role': m['role'], 'date': m['date']} for m in data['messages']]
|
metadatas = [{'role': m['role'], 'date': m['date'], 'meta': m.get('meta', '')} for m in data['messages']]
|
||||||
|
|
||||||
collection.upsert(
|
collection.upsert(
|
||||||
ids=ids,
|
ids=ids,
|
||||||
@@ -687,6 +687,7 @@ def chromadb_query():
|
|||||||
'id': ids[i],
|
'id': ids[i],
|
||||||
'date': metadatas[i]['date'],
|
'date': metadatas[i]['date'],
|
||||||
'role': metadatas[i]['role'],
|
'role': metadatas[i]['role'],
|
||||||
|
'meta': metadatas[i]['meta'],
|
||||||
'content': documents[i],
|
'content': documents[i],
|
||||||
'distance': distances[i]
|
'distance': distances[i]
|
||||||
} for i in range(len(ids))
|
} for i in range(len(ids))
|
||||||
|
|||||||
Reference in New Issue
Block a user