Giter Club home page Giter Club logo

Comments (1)

dosubot avatar dosubot commented on May 27, 2024 2

Hey @devorem! Great to see you back around here 😊 Let's dive into what's been bugging you.

Based on the error message you're receiving, it seems that the brain_id field is indeed required for the Question handler API call. This field is used to identify the specific "brain" (or knowledge base) that the question should be routed to for processing.

The brain_id should be added in the request as part of the JSON payload. For example, if there's an endpoint that expects a request body, you would include 'brain_id' like so:

{
  "model": "some_model",
  "brain_id": "specific_brain_id",
  "chat_id": "some_chat_id",
  ...
}

The exact structure of the API request that the APIBrainQA class expects is defined within the get_api_call_response_as_text method. This method outlines how the API request is constructed and sent, including the method type (GET, DELETE, POST, PUT, PATCH), the API URL, parameters, search parameters, and headers (which may include secrets).

Here is the relevant code snippet:

def get_api_call_response_as_text(
    self, method, api_url, params, search_params, secrets
) -> str:
    headers = {}

    api_url_with_search_params = api_url
    if search_params:
        api_url_with_search_params += "?"
        for search_param in search_params:
            api_url_with_search_params += (
                f"{search_param}={search_params[search_param]}&"
            )

    for secret in secrets:
        headers[secret] = secrets[secret]

    try:
        if method in ["GET", "DELETE"]:
            response = requests.request(
                method,
                url=api_url_with_search_params,
                params=params or None,
                headers=headers or None,
            )
        elif method in ["POST", "PUT", "PATCH"]:
            response = requests.request(
                method,
                url=api_url_with_search_params,
                json=params or None,
                headers=headers or None,
            )
        else:
            raise ValueError(f"Invalid method: {method}")
    return response.text

This method is where the API request structure is defined and handled within the APIBrainQA class. You can find this in the backend/modules/brain/api_brain_qa.py file.

I hope this helps! If you have any other questions, feel free to ask.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

from quivr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.