Skip to content
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

[BUG]: API endpoint for workspace chats and thread chats are inconsistent and reversed #2990

Open
mayzyo opened this issue Jan 19, 2025 · 1 comment
Assignees
Labels
investigating Core team or maintainer will or is currently looking into this issue possible bug Bug was reported but is not confirmed or is unable to be replicated.

Comments

@mayzyo
Copy link

mayzyo commented Jan 19, 2025

How are you running AnythingLLM?

Docker (local)

What happened?

When fetching chat history from api/v1/workspace/slug/chats (so the "default" thread) the array is reversed. Additionally, the order of "assistant" and "user" is reversed on top of the whole array being reversed.

Example api/v1/workspace/slug/chats:
The history displayed in the web UI start with me asking "quick test" and assistant replying "How can I assist you?" which is correct.

[
    {
        "attachments": [],
        "chatId": 417,
        "content": "Give me a brief intr",
        "role": "user",
        "sentAt": 1735077496
    },
    {
        "chatId": 417,
        "content": " I am a text-based A",
        "feedbackScore": null,
        "metrics": {
            "completion_tokens": 163,
            "duration": 18.376,
            "outputTps": 8.870265563778842,
            "prompt_tokens": 5,
            "total_tokens": 168
        },
        "role": "assistant",
        "sentAt": 1735077496,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 372,
        "content": "How much water shoul",
        "role": "user",
        "sentAt": 1734609844
    },
    {
        "chatId": 372,
        "content": "The general recommen",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1734609844,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 362,
        "content": "quick test",
        "role": "user",
        "sentAt": 1734470476
    },
    {
        "chatId": 362,
        "content": " How can I assist yo",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1734470476,
        "sources": [],
        "type": "chat"
    }
]

Example api/v1/workspace/slug/threads/tslug/chats:
I believe this is endpoint is the correct one.

[
    {
        "attachments": [],
        "chatId": 341,
        "content": "Hi there!",
        "role": "user",
        "sentAt": 1733646403
    },
    {
        "chatId": 341,
        "content": " Hello! How can I as",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1733646403,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 342,
        "content": "What do you know abo",
        "role": "user",
        "sentAt": 1733649565
    },
    {
        "chatId": 342,
        "content": " \"Gundam SEED\" is an",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1733649565,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 346,
        "content": "Compare seed destiny",
        "role": "user",
        "sentAt": 1733702408
    },
    {
        "chatId": 346,
        "content": "When comparing \"Gund",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1733702408,
        "sources": [],
        "type": "chat"
    }
]

Are there known steps to reproduce?

No response

@mayzyo mayzyo added the possible bug Bug was reported but is not confirmed or is unable to be replicated. label Jan 19, 2025
@mayzyo
Copy link
Author

mayzyo commented Jan 19, 2025

Additionally, it seems like the default thread endpoint is returning history that was already deleted and no longer visible in the web UI. I only noticed this while I was filing this bug report.

@timothycarambat timothycarambat added the investigating Core team or maintainer will or is currently looking into this issue label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating Core team or maintainer will or is currently looking into this issue possible bug Bug was reported but is not confirmed or is unable to be replicated.
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants