fix: clean up threads persistence and fix assistant update issue
This commit is contained in:
parent
0bb04e59d3
commit
2b732bc976
@ -465,7 +465,7 @@ pub async fn modify_thread_assistant<R: Runtime>(
|
|||||||
{
|
{
|
||||||
if let Some(index) = assistants
|
if let Some(index) = assistants
|
||||||
.iter()
|
.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();
|
assistants[index] = assistant.clone();
|
||||||
let data = serde_json::to_string_pretty(&thread).map_err(|e| e.to_string())?;
|
let data = serde_json::to_string_pretty(&thread).map_err(|e| e.to_string())?;
|
||||||
|
|||||||
@ -232,26 +232,6 @@ const ModelDropdown = ({
|
|||||||
stopModel()
|
stopModel()
|
||||||
|
|
||||||
if (activeThread) {
|
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
|
const contextLength = model?.settings.ctx_len
|
||||||
? Math.min(8192, model?.settings.ctx_len ?? 8192)
|
? Math.min(8192, model?.settings.ctx_len ?? 8192)
|
||||||
: undefined
|
: undefined
|
||||||
@ -273,11 +253,25 @@ const ModelDropdown = ({
|
|||||||
|
|
||||||
// Update model parameter to the thread file
|
// Update model parameter to the thread file
|
||||||
if (model)
|
if (model)
|
||||||
updateModelParameter(activeThread, {
|
updateModelParameter(
|
||||||
params: modelParams,
|
activeThread,
|
||||||
modelId: model.id,
|
{
|
||||||
engine: model.engine,
|
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)
|
updateThreadCallback(thread)
|
||||||
if (thread.assistants && thread.assistants?.length > 0) {
|
if (thread.assistants && thread.assistants?.length > 0) {
|
||||||
setActiveAssistant(thread.assistants[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 { useCallback } from 'react'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AssistantTool,
|
||||||
ConversationalExtension,
|
ConversationalExtension,
|
||||||
ExtensionTypeEnum,
|
ExtensionTypeEnum,
|
||||||
InferenceEngine,
|
InferenceEngine,
|
||||||
@ -51,7 +52,11 @@ export default function useUpdateModelParameters() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const updateModelParameter = useCallback(
|
const updateModelParameter = useCallback(
|
||||||
async (thread: Thread, settings: UpdateModelParameter) => {
|
async (
|
||||||
|
thread: Thread,
|
||||||
|
settings: UpdateModelParameter,
|
||||||
|
tools?: AssistantTool[]
|
||||||
|
) => {
|
||||||
if (!activeAssistant) return
|
if (!activeAssistant) return
|
||||||
|
|
||||||
const toUpdateSettings = processStopWords(settings.params ?? {})
|
const toUpdateSettings = processStopWords(settings.params ?? {})
|
||||||
@ -70,6 +75,7 @@ export default function useUpdateModelParameters() {
|
|||||||
const settingParams = extractModelLoadParams(updatedModelParams)
|
const settingParams = extractModelLoadParams(updatedModelParams)
|
||||||
const assistantInfo = {
|
const assistantInfo = {
|
||||||
...activeAssistant,
|
...activeAssistant,
|
||||||
|
tools: tools ?? activeAssistant.tools,
|
||||||
model: {
|
model: {
|
||||||
...activeAssistant?.model,
|
...activeAssistant?.model,
|
||||||
parameters: runtimeParams,
|
parameters: runtimeParams,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user