fix: clean up threads persistence and fix assistant update issue
This commit is contained in:
parent
c4ae61dd75
commit
eda0d639f0
@ -465,7 +465,7 @@ pub async fn modify_thread_assistant<R: Runtime>(
|
||||
{
|
||||
if let Some(index) = assistants
|
||||
.iter()
|
||||
.position(|a| a.get("id").and_then(|v| v.as_str()) == Some(assistant_id))
|
||||
.position(|a| a.get("assistant_id").and_then(|v| v.as_str()) == Some(assistant_id))
|
||||
{
|
||||
assistants[index] = assistant.clone();
|
||||
let data = serde_json::to_string_pretty(&thread).map_err(|e| e.to_string())?;
|
||||
|
||||
@ -239,26 +239,6 @@ const ModelDropdown = ({
|
||||
stopModel()
|
||||
|
||||
if (activeThread) {
|
||||
// Change assistand tools based on model support RAG
|
||||
updateThreadMetadata({
|
||||
...activeThread,
|
||||
assistants: [
|
||||
{
|
||||
...activeAssistant,
|
||||
tools: [
|
||||
{
|
||||
type: 'retrieval',
|
||||
enabled: model?.engine === InferenceEngine.cortex,
|
||||
settings: {
|
||||
...(activeAssistant.tools &&
|
||||
activeAssistant.tools[0]?.settings),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const contextLength = model?.settings.ctx_len
|
||||
? Math.min(8192, model?.settings.ctx_len ?? 8192)
|
||||
: undefined
|
||||
@ -280,11 +260,25 @@ const ModelDropdown = ({
|
||||
|
||||
// Update model parameter to the thread file
|
||||
if (model)
|
||||
updateModelParameter(activeThread, {
|
||||
params: modelParams,
|
||||
modelId: model.id,
|
||||
engine: model.engine,
|
||||
})
|
||||
updateModelParameter(
|
||||
activeThread,
|
||||
{
|
||||
params: modelParams,
|
||||
modelId: model.id,
|
||||
engine: model.engine,
|
||||
},
|
||||
// Update tools
|
||||
[
|
||||
{
|
||||
type: 'retrieval',
|
||||
enabled: model?.engine === InferenceEngine.cortex,
|
||||
settings: {
|
||||
...(activeAssistant.tools &&
|
||||
activeAssistant.tools[0]?.settings),
|
||||
},
|
||||
},
|
||||
]
|
||||
)
|
||||
}
|
||||
},
|
||||
[
|
||||
|
||||
@ -180,7 +180,7 @@ export const useCreateNewThread = () => {
|
||||
updateThreadCallback(thread)
|
||||
if (thread.assistants && thread.assistants?.length > 0) {
|
||||
setActiveAssistant(thread.assistants[0])
|
||||
updateAssistantCallback(thread.id, thread.assistants[0])
|
||||
return updateAssistantCallback(thread.id, thread.assistants[0])
|
||||
}
|
||||
},
|
||||
[
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { useCallback } from 'react'
|
||||
|
||||
import {
|
||||
AssistantTool,
|
||||
ConversationalExtension,
|
||||
ExtensionTypeEnum,
|
||||
InferenceEngine,
|
||||
@ -51,7 +52,11 @@ export default function useUpdateModelParameters() {
|
||||
)
|
||||
|
||||
const updateModelParameter = useCallback(
|
||||
async (thread: Thread, settings: UpdateModelParameter) => {
|
||||
async (
|
||||
thread: Thread,
|
||||
settings: UpdateModelParameter,
|
||||
tools?: AssistantTool[]
|
||||
) => {
|
||||
if (!activeAssistant) return
|
||||
|
||||
const toUpdateSettings = processStopWords(settings.params ?? {})
|
||||
@ -70,6 +75,7 @@ export default function useUpdateModelParameters() {
|
||||
const settingParams = extractModelLoadParams(updatedModelParams)
|
||||
const assistantInfo = {
|
||||
...activeAssistant,
|
||||
tools: tools ?? activeAssistant.tools,
|
||||
model: {
|
||||
...activeAssistant?.model,
|
||||
parameters: runtimeParams,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user