Skip to content

Fix stateless conversation — chat history not passed to API #3

@JiwaniZakir

Description

@JiwaniZakir

Problem

Each message sends only messages: [{ role: 'user', content: prompt }] to the OpenAI API — a single-element array. The messages state in React holds the displayed conversation, but it is never passed to the API call. Follow-up questions have no context from previous answers.

Proposed Solution

  • Pass the accumulated messages array (converted to OpenAI message format) as conversation history
  • Inject the legal knowledge base as a system message once rather than prepending it to every user message
  • This also reduces token usage — the 15K-token prompt is currently re-sent on every single message

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions