Skip to content

Instantly share code, notes, and snippets.

@hunterjsb
Last active April 14, 2024 12:57
Show Gist options
  • Select an option

  • Save hunterjsb/f185419a556116db9ab4c37e34e79f7b to your computer and use it in GitHub Desktop.

Select an option

Save hunterjsb/f185419a556116db9ab4c37e34e79f7b to your computer and use it in GitHub Desktop.

Conversation Cosmos Doc

This document describes the structure of the JSON payload used in the system and consequently how it will be stored in Cosmos.

Payload Structure

The JSON payload consists of the following fields:

  • exchange (string): Specifies the platform where the item is listed. It can be either "marketplace" or "offerup".

  • itemType (string): The Azure Cosmos DB partition key.

  • itemId (string): Unique identifier of the item.

  • itemName (string): Name or title of the item directly from the listing.

  • seller (object): Contains information about the seller. The structure of the seller object is not specified in this documentation.

  • messages (array): An array of message objects representing the conversation between the assistant and the user. Each message object has the following fields:

    • role (string): Specifies the role of the message sender. It can be either "assistant" or "user".
    • content (object): Contains the content of the message. It has the following fields:
      • type (string, optional): Specifies the type of the message content. It can be one of the following values:
        • "text": Represents a plain text message.
        • "tool_use": Represents a message related to the use of a tool.
        • "tool_response": Represents a response from a tool.
      • content (string): The actual content of the message.

Example Payload

Here's an example of a JSON payload that follows the described structure:

{
  "exchange": "marketplace",
  "itemId": "1234567890",
  "itemName": "Vintage Leather Jacket",
  "seller": {
    "id": "abc123",
    "name": "John Doe"
  },
  "messages": [
    {
      "role": "user",
      "content": {
        "type": "text",
        "content": "Hello, is this item still available?"
      }
    },
    {
      "role": "assistant",
      "content": {
        "type": "text",
        "content": "Yes, the vintage leather jacket is still available. How can I assist you?"
      }
    },
    {
      "role": "user",
      "content": {
        "type": "tool_use",
        "content": "Can you provide more details about the condition of the jacket?"
      }
    },
    {
      "role": "assistant",
      "content": {
        "type": "tool_response",
        "content": "The jacket is in excellent condition with minor signs of wear. It has been well-maintained and stored properly."
      }
    }
  ]
}

In this example, the payload represents an item listed on the "marketplace" platform with the ID "1234567890" and the name "Vintage Leather Jacket". The seller information is provided in the seller object. The messages array contains a conversation between the user and the assistant, including text messages, tool usage, and tool responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment