nsbradford / SemanticSearch

Minimal RAG (Retrieval Augmented Generation) website with Pinecone, FastAPI, NextJS, MongoDB
https://semantic-search-six.vercel.app
9 stars 3 forks source link

Add session ID to llm request metadata #43

Open nsbradford opened 12 months ago

nsbradford commented 12 months ago

Get sessionId from the frontend, pass it all the way through existing endpoints to the llm request metadata

ellipsis-dev[bot] commented 12 months ago

To have BitBuilder create a Pull Request with the implementation, the user who created the issue (@nsbradford) can comment below with "LGTM". If the plan is inaccurate, edit the issue description and write a comment with "replan".


Implementation Steps

  1. Add sessionId to frontend API calls
    • Modify the postQuery and sendLLMRequest functions in /ui/shared/api.ts to include the sessionId in the request headers. The sessionId can be retrieved using the getSessionId function from /ui/shared/utils.ts.
  2. Update backend to accept sessionId
    • Update the /query and /llm endpoints in /backend/main.py to accept the sessionId from the request headers and pass it to the respective functions execute_query and llm_get.
  3. Add sessionId to llm request metadata
    • Modify the llm_get function in /backend/llm.py to include the sessionId in the metadata of the llm request.

Generated with :heart: by www.bitbuilder.ai. Questions? Check out our the documentation.

nsbradford commented 12 months ago

replan - no need to modify the query endpoint

ellipsis-dev[bot] commented 12 months ago

To have BitBuilder create a Pull Request with the implementation, the user who created the issue (@nsbradford) can comment below with "LGTM". If the plan is inaccurate, edit the issue description and write a comment with "replan".


Implementation Steps

  1. Add sessionId to frontend API calls
    • Modify the postQuery and sendLLMRequest functions in /ui/shared/api.ts to include the sessionId in the request headers. The sessionId can be retrieved using the getSessionId function from /ui/shared/utils.ts. In the postQuery function, add a headers object to the axios post request with a 'sessionId' property that calls the getSessionId function. Do the same for the sendLLMRequest function.
  2. Update backend to accept sessionId
    • Update the /llm endpoint in /backend/main.py to accept the sessionId from the request headers and pass it to the llm_get function. In the llm function, extract the sessionId from the request headers and pass it as an argument to the llm_get function.
  3. Add sessionId to llm request metadata
    • Modify the llm_get function in /backend/llm.py to include the sessionId in the metadata of the llm request. Add a new key-value pair to the metadata object in the acompletion function call where the key is 'sessionId' and the value is the sessionId passed to the llm_get function.

Generated with :heart: by www.bitbuilder.ai. Questions? Check out our the documentation.

nsbradford commented 12 months ago

replan - put metadata as a request param, don't use request headers. and do not modify postQuery, just llm

ellipsis-dev[bot] commented 12 months ago

To have BitBuilder create a Pull Request with the implementation, the user who created the issue (@nsbradford) can comment below with "LGTM". If the plan is inaccurate, edit the issue description and write a comment with "replan".


Implementation Steps

  1. Add sessionId to sendLLMRequest function
    • Modify the sendLLMRequest function in /ui/shared/api.ts to include the sessionId in the request data. The sessionId can be retrieved using the getSessionId function from /ui/shared/utils.ts. In the sendLLMRequest function, add a 'sessionId' property to the data object that calls the getSessionId function.
  2. Update llm endpoint to accept sessionId
    • Update the /llm endpoint in /backend/main.py to accept the sessionId from the request data and pass it to the llm_get function. In the llm function, extract the sessionId from the request data and pass it as an argument to the llm_get function.
  3. Add sessionId to llm request metadata
    • Modify the llm_get function in /backend/llm.py to include the sessionId in the metadata of the llm request. Add a new key-value pair to the metadata object in the acompletion function call where the key is 'sessionId' and the value is the sessionId passed to the llm_get function.

Generated with :heart: by www.bitbuilder.ai. Questions? Check out our the documentation.