Namespaces

Organizing Requests

Namespaces offer a powerful mechanism for organizing, and managing the different types of requests from your LLM-powered application. You can think of them as channels from which the request is coming. Namespaces can be easily utilized to differentiate the source that a request comes from or manage threads, etc.

Use Namespaces

Any request that is logged to GPTBoost has a Namespace. It can be either the default or a custom one specified in the header. To assign a Namespace for a request, simply add the property in the HEADERS.

  • The key follows the format GPTBoost-Namespace

  • The value is the string representation of your custom namespace.

# This example is for v1+ of the openai: https://pypi.org/project/openai/
from openai import OpenAI

client = OpenAI( 
    base_url = "https://turbo.gptboost.io/v1",
    api_key= os.getenv("OPENAI_API_KEY"),
)

headers = {
    "GPTBoost-Namespace": "development"
    }

response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "user", "content": "Tell me an interesting fact about pandas"},
    ], 
    extra_headers=headers
)
print(response.choices[0].message.content)

Vizualization in GPTBoost

The Namespace for each request is shown in your GPTBoost Request Log. You can also filter requests by Namespace. To do that, click on the desired namespace on any of the requests in the log.

Filter by Namespace in GPTBoost Request Log

Use Cases

Environment Tracking with Namespaces: Effectively manage and track requests across development, staging, and production environments using Namespaces. Assign unique Namespaces to requests originating from each environment, providing clarity and facilitating seamless monitoring and debugging processes.

E.g: Use "GPTBoost-Namespace": "development", "GPTBoost-Namespace": "staging", or "GPTBoost-Namespace": "production" to seamlessly check the requests and data only for the channel you need. Moreover, you can filter by Namespce in GPTBoost Dashboard with just a click.

Multi-Channel Personalization: Imagine an e-commerce platform, that uses different Namespaces for requests originating from the website, mobile app, and social media channels. This allows the model to tailor product recommendations and responses based on the user's interaction context, providing a personalized shopping experience across various touchpoints.

E.g. In this scenario, simply try "GPTBoost-Namespace": "iOS", "GPTBoost-Namespace": "Android", or "GPTBoost-Namespace": "web" to have the info if the request is coming from your mobile or web app.

Threaded Conversations: In a customer support chat application, implement Namespaces to manage threaded conversations. Each user inquiry receives a unique Namespace, enabling the model to maintain context within the conversation. While this might not be the most elegant solution, it's a valid option to keep threads per user. Another approach for maintaining threads is with GPTBoost Custom Properties.

E.g. Use some user identificator, such as User22 for Namespace value.

Last updated