Skip to content

[Core/Hosted]: search feedback #96

Open
@louis030195

Description

@louis030195

Feature request

ChatGPT like user feedback to open opportunities to improve user experience

Motivation

  • interpretability over user happiness as statistics, visualisation in the dashboard
  • eventual fine-tuning or reranking

Your contribution

image

I'm imagining a middleware that save search queries and a new end point that accept feedback on search result with the ID of the result

from typing import Callable

import uuid

from fastapi import Request
from fastapi.responses import JSONResponse

from embedbase.database.base import VectorDatabase
from embedbase.embedding.base import Embedder


async def save_search(
    request: Request, call_next: Callable, db: VectorDatabase, embedder: Embedder
):
    """
    Upon search request, save the request to a database.
    """
    # todo overlap with add on "search" dataset
    if request.method != "POST" or "/v1/search" not in request.url.path:
        return await call_next(request)

    request_body = await request.json()
    new_id = str(uuid.uuid4())
    request_body["id"] = new_id
    response = await db.save("search", request_body)
    return await call_next(request)

(almost) pseudo code for feedback endpoint:

app = (
    get_app()
    .use_embedder(...)
    .use_db(...)
    .run()
)
# An endpoint that let you rate search results
@app.post("/feedback")
async def human_feedback(req, cb, db, embedder):
    # here would save to a table feedback
    # the request body looks like "searchid: vrevrwrew, feedback: 0 or 1"
    db.save("feedback", req.body)
    return 200

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