fix: fetch threads and messages without limiting (#4304)
* fix: threads and messages are cutoff * fix: threads sorting * chore: bump cortex latest release and app version
This commit is contained in:
parent
1acbb33677
commit
4e43f9798d
@ -40,7 +40,7 @@ export default class CortexConversationalExtension extends ConversationalExtensi
|
|||||||
async listThreads(): Promise<Thread[]> {
|
async listThreads(): Promise<Thread[]> {
|
||||||
return this.queue.add(() =>
|
return this.queue.add(() =>
|
||||||
ky
|
ky
|
||||||
.get(`${API_URL}/v1/threads`)
|
.get(`${API_URL}/v1/threads?limit=-1`)
|
||||||
.json<ThreadList>()
|
.json<ThreadList>()
|
||||||
.then((e) => e.data)
|
.then((e) => e.data)
|
||||||
) as Promise<Thread[]>
|
) as Promise<Thread[]>
|
||||||
@ -133,7 +133,7 @@ export default class CortexConversationalExtension extends ConversationalExtensi
|
|||||||
async listMessages(threadId: string): Promise<ThreadMessage[]> {
|
async listMessages(threadId: string): Promise<ThreadMessage[]> {
|
||||||
return this.queue.add(() =>
|
return this.queue.add(() =>
|
||||||
ky
|
ky
|
||||||
.get(`${API_URL}/v1/threads/${threadId}/messages?order=asc`)
|
.get(`${API_URL}/v1/threads/${threadId}/messages?order=asc&limit=-1`)
|
||||||
.json<MessageList>()
|
.json<MessageList>()
|
||||||
.then((e) => e.data)
|
.then((e) => e.data)
|
||||||
) as Promise<ThreadMessage[]>
|
) as Promise<ThreadMessage[]>
|
||||||
@ -147,7 +147,7 @@ export default class CortexConversationalExtension extends ConversationalExtensi
|
|||||||
*/
|
*/
|
||||||
async getThreadAssistant(threadId: string): Promise<ThreadAssistantInfo> {
|
async getThreadAssistant(threadId: string): Promise<ThreadAssistantInfo> {
|
||||||
return this.queue.add(() =>
|
return this.queue.add(() =>
|
||||||
ky.get(`${API_URL}/v1/assistants/${threadId}`).json<ThreadAssistantInfo>()
|
ky.get(`${API_URL}/v1/assistants/${threadId}?limit=-1`).json<ThreadAssistantInfo>()
|
||||||
) as Promise<ThreadAssistantInfo>
|
) as Promise<ThreadAssistantInfo>
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
1.0.5-rc2
|
1.0.5
|
||||||
|
|||||||
@ -53,7 +53,7 @@ export class CortexAPI implements ICortexAPI {
|
|||||||
*/
|
*/
|
||||||
getModels(): Promise<Model[]> {
|
getModels(): Promise<Model[]> {
|
||||||
return this.queue
|
return this.queue
|
||||||
.add(() => ky.get(`${API_URL}/v1/models`).json<ModelList>())
|
.add(() => ky.get(`${API_URL}/v1/models?limit=-1`).json<ModelList>())
|
||||||
.then((e) =>
|
.then((e) =>
|
||||||
typeof e === 'object' ? e.data.map((e) => this.transformModel(e)) : []
|
typeof e === 'object' ? e.data.map((e) => this.transformModel(e)) : []
|
||||||
)
|
)
|
||||||
|
|||||||
@ -244,6 +244,7 @@ export default function ModelHandler() {
|
|||||||
const metadata = {
|
const metadata = {
|
||||||
...thread.metadata,
|
...thread.metadata,
|
||||||
...(messageContent && { lastMessage: messageContent }),
|
...(messageContent && { lastMessage: messageContent }),
|
||||||
|
updated_at: Date.now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
updateThread({
|
updateThread({
|
||||||
|
|||||||
@ -153,6 +153,7 @@ export const useCreateNewThread = () => {
|
|||||||
updated: createdAt,
|
updated: createdAt,
|
||||||
metadata: {
|
metadata: {
|
||||||
title: 'New Thread',
|
title: 'New Thread',
|
||||||
|
updated_at: Date.now(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,12 @@ const useThreads = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getThreads = async () => {
|
const getThreads = async () => {
|
||||||
const localThreads = await getLocalThreads()
|
const localThreads = (await getLocalThreads()).sort((a, b) => {
|
||||||
|
return ((a.metadata?.updated_at as number) ?? 0) >
|
||||||
|
((b.metadata?.updated_at as number) ?? 0)
|
||||||
|
? -1
|
||||||
|
: 1
|
||||||
|
})
|
||||||
const localThreadStates: Record<string, ThreadState> = {}
|
const localThreadStates: Record<string, ThreadState> = {}
|
||||||
const threadModelParams: Record<string, ModelParams> = {}
|
const threadModelParams: Record<string, ModelParams> = {}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@janhq/web",
|
"name": "@janhq/web",
|
||||||
"version": "0.5.11",
|
"version": "0.5.12",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "./",
|
"homepage": "./",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user