Tutorial: Creating a Chat App Through REST API

Create a chat app that can answer questions about Python Enhancement Proposals (PEPs) using REST API endpoints.

  • Level: Basic
  • Time to complete: 15 minutes
  • Prerequisites:
    • You must have a basic understanding of REST API: HTTP methods, response and request structure, and basic concepts.
    • Basic programming knowledge is a plus.
    • You must have a deepset Cloud API key. For instructions, see Generate an API Key.
    • Use the OpenAI API key to use GPT models. (This tutorial uses GPT-4, but you can exchange it for another model.)
  • Goal: After completing this tutorial, you will have built a chat assistant that runs on Python Enhancements Proposals and can answer questions about the contents of the https://peps.python.org/ website. You'll be able to plug it into a UI of your choice.

Upload Files

First, let's upload the files our chat will run on.

  1. Download the peps_main.zip file to your machine and unzip it.
  2. Create a new workspace:
    1. Log in to deepset Cloud and click the workspace name to expand the workspace list.
    2. Type peps as the new workspace name and click Create. You're automatically moved to the new workspace.
  3. In the navigation, click Files>Upload Files.
  4. Choose the files you extracted in step 1 and click Upload. You should have 664 files.

Result: You have uploaded 664 files containing to your workspace.

Create a Chat Pipeline

Now, we'll create a chat pipeline you'll later call with REST API endpoints.

  1. In deepset Cloud, ensure you're in the same workspace where you uploaded the files, and click Pipeline Templates.

  2. Make sure you're on the deepset Cloud 2.0 tab, choose Conversational templates, hover over RAG Chat GPT-4, and click Use Template.

  3. Rename the pipeline to rag-chat and click Create Pipeline. You're redirected to the Pipelines page.

  4. Click Deploy next to the rag-chat pipeline.

Result: You have created and deployed a chat pipeline. It's ready for use.

Call the Pipeline with REST API

To send user queries to your chat pipelines:

  1. Get the ID of your chat pipeline using the Get Pipeline endpoint.
  2. Create a search session with the Create Search Session endpoint.
  3. Send user queries using the Chat endpoint.

Get Pipeline ID

You'll need the ID to create a chat session. Use the Get Pipeline endpoint. You can use the following code snippet (cURL or Python). Fill in:

  • workspace name and pipeline name (in the URL).
  • your deepset Cloud API key (in headers).
import requests

url = "https://api.cloud.deepset.ai/api/v1/workspaces/peps/pipelines/rag-chat" #peps is the workspace, rag-chat is the pipeline name
headers = {
    "accept": "application/json",
    "authorization": "Bearer <deepset Cloud API key>" # Insert your deepset Cloud API key
}

response = requests.get(url, headers=headers)

print(response.status_code)
print(response.json())
curl --request GET \
     --url https://api.cloud.deepset.ai/api/v1/workspaces/peps/pipelines/rag-chat \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <deepset Cloud API key>'
Sample response
{
  "name": "rag-chat",
  "pipeline_id": "42e5333d-dd04-48de-aaa8-6b62863e17cd",
  "status": "DEPLOYED",
  "desired_status": "DEPLOYED",
  "created_at": "2024-10-18T09:04:35.539874Z",
  "deleted": false,
  "is_default": true,
  "created_by": {
    "given_name": "Jane",
    "family_name": "Doe",
    "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
  },
  "last_edited_by": null,
  "last_edited_at": null,
  "supports_prompt": true,
  "output_type": "CHAT",
  "last_deployed_at": "2024-10-18T09:04:46.595925Z",
  "service_level": "DEVELOPMENT",
  "idle_timeout_in_seconds": 43200,
  "deepset_cloud_version": "v2",
  "indexing": {
    "pending_file_count": 0,
    "failed_file_count": 0
  }
}

Create a Search Session

Search session lets you display chat history when running queries. Use the Create Search Session endpoint. You'll need to provide the following information:

  • your workspace name (in the URL).
  • your chat pipeline ID (you can find it in the Get Pipeline response).
  • your deepset Cloud API key (in headers).

Here is a sample code you can use:

import requests

url = "https://api.cloud.deepset.ai/api/v1/workspaces/peps/search_sessions" #legal-chat is the workspace name

payload = { "pipeline_id": "<pipeline_id>" } #insert the pipeline ID you got in the Get Pipeline response
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": "Bearer <your_api_key>" #insert your deepset Cloud API key
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
curl --request POST \
     --url https://api.cloud.deepset.ai/api/v1/workspaces/peps/search_sessions \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <your_api_key>' \
     --header 'content-type: application/json' \
     --data '
{
  "pipeline_id": "<pipeline_id>"
}
'

As a response, you get the search session ID, which you'll need to start the chat:

{
  "search_session_id": "52bda5ec-23d9-4240-9d12-e7c48513158b"
}

Start a Chat

Send your queries to the Chat endpoint to start chatting with your pipeline. You'll need to provide:

  • your pipeline and workspace name (in the URL).
  • your deepset Cloud API key (in headers).
  • queries
  • search session ID (from the Create Search Session response)

You can use this code snippet:

import requests

url = "https://api.cloud.deepset.ai/api/v1/workspaces/peps/pipelines/rag-chat/chat" #peps is the workspace name, rag-chat is the pipeline name

payload = {
    "chat_history_limit": 3, # the number of chat history items to show in the chat
    "debug": False,
    "view_prompts": False,
    "queries": ["How do you present datetime objects in human readable format?"], # the queries to ask
    "search_session_id": "52bda5ec-23d9-4240-9d12-e7c48513158b" # ID of the search session
}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": "Bearer <your_api_key>" # your deepset Cloud API key
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
curl --request POST \
     --url https://api.cloud.deepset.ai/api/v1/workspaces/peps/pipelines/rag-chat/chat \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <your_api_key>' \
     --header 'content-type: application/json' \
     --data '
{
  "chat_history_limit": 3,
  "debug": false,
  "view_prompts": false,
  "queries": [
    "How do you present datetime objects in human readable format?"
  ],
  "search_session_id": "52bda5ec-23d9-4240-9d12-e7c48513158b"
}
'
Sample response
{
  "query_id": "036b2866-2703-4d59-823d-9d8e683c7fa1",
  "results": [
    {
      "query_id": "036b2866-2703-4d59-823d-9d8e683c7fa1",
      "query": "How do you present datetime objects in human readable format?",
      "answers": [
        {
          "answer": "To present datetime objects in a human-readable format, you can use the `strftime()` method provided by the `datetime` class. This method allows you to specify the format of the output string using format specifiers that correspond to various components of the date and time. For example, you can format a datetime object to display the date and time in a readable format like \"Today is: {0:%a %b %d %H:%M:%S %Y}\". This would output a string such as \"Today is: Mon Sep 16 10:34:54 2023\" . Additionally, the `isoformat()` and `ctime()` methods on datetime objects return string representations of the time in ISO 8601 format and a more traditional format similar to the C function `asctime()`, respectively .",
          "type": "generative",
          "score": null,
          "context": null,
          "offsets_in_document": [],
          "offsets_in_context": [],
          "document_id": null,
          "document_ids": [
            "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
            "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
            "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
            "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
            "bdf4d62f2f52e9a3d1e87e6e41b9679ada4a930c321d33d3e77544c137cb88fb",
            "d707bfed2ede5435c51068efc5690033457d7e3106572b2221ee30097e16c20e",
            "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
            "d9878e926481ac189a88db4f7ed36cb64cd9e28bd58c450ee11c2731dba935d6"
          ],
          "meta": {
            "_references": [
              {
                "answer_end_idx": 487,
                "answer_start_idx": 487,
                "document_id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
                "document_position": 3,
                "label": "grounded",
                "score": 0,
                "doc_end_idx": 1607,
                "doc_start_idx": 0,
                "origin": "llm"
              },
              {
                "answer_end_idx": 706,
                "answer_start_idx": 706,
                "document_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
                "document_position": 1,
                "label": "grounded",
                "score": 0,
                "doc_end_idx": 1738,
                "doc_start_idx": 0,
                "origin": "llm"
              }
            ]
          },
          "file": {
            "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
            "name": "pep-0321.txt"
          },
          "files": [
            {
              "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
              "name": "pep-0321.txt"
            },
            {
              "id": "c549dad4-9306-417e-9e31-72eff4db300c",
              "name": "pep-0498.txt"
            },
            {
              "id": "d6987234-60e7-4651-864d-017631ca53b3",
              "name": "pep-3101.txt"
            },
            {
              "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
              "name": "pep-0495.txt"
            },
            {
              "id": "5eda3f1a-74b9-4887-9772-35ca44be1e99",
              "name": "pep-0410.txt"
            },
            {
              "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
              "name": "pep-0500.txt"
            },
            {
              "id": "a8a8d83e-6696-46c7-9ebf-3a953da41132",
              "name": "pep-0519.txt"
            }
          ],
          "result_id": "7ec72d79-639a-4291-8258-86a173ec02ae",
          "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nPEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.\n\nDocument[2]:\nHowever, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. \n\nDocument[3]:\nSame as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n\n\nDocument[4]:\nOnly complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:\n\nDocument[5]:\nOnly datetime/time instances with ``fold=1`` pickled\nin the new versions will become unreadable by the older Python\nversions.  Pickles of instances with ``fold=0`` (which is the\ndefault) will remain unchanged.\n\n\nQuestions and Answers\n=====================\n\nWhy not call the new flag \"isdst\"?\n----------------------------------\n\nA non-technical answer\n......................\n\n* Alice: Bob - let's have a stargazing party at 01:30 AM tomorrow!\n* Bob: Should I presume initially that Daylight Saving Time is or is\n  not in effect for the specified time?\n* Alice: Huh?\n\n-------\n\n* Bob: Alice - let's have a stargazing party at 01:30 AM tomorrow!\n* Alice: You know, Bob, 01:30 AM will happen twice tomorrow. Which time do you have in mind?\n* Bob:  I did not think about it, but let's pick the first.\n\n-------\n\n(same characters, an hour later)\n\n-------\n\n* Bob: Alice - this Py-O-Clock gadget of mine asks me to choose\n  between fold=0 and fold=1 when I set it for tomorrow 01:30 AM.\n  What should I do?\n* Alice: I've never hear of a Py-O-Clock, but I guess fold=0 is\n  the first 01:30 AM and fold=1 is the second.\n\n\nA technical reason\n..................\n\nWhile the ``tm_isdst`` field of the ``time.struct_time`` object can be\nused to disambiguate local times in the fold, the semantics of such\ndisambiguation are completely different from the proposal in this PEP.\n\n\n\nDocument[6]:\nThere is also an ordering issues with daylight saving time (DST) in\nthe duplicate hour of switching from DST to normal time.\n\ndatetime.datetime has been rejected because it cannot be used for functions\nusing an unspecified starting point like os.times() or time.clock().\n\nFor time.time() and time.clock_gettime(time.CLOCK_GETTIME): it is already\npossible to get the current time as a datetime.datetime object using::\n\n    datetime.datetime.now(datetime.timezone.utc)\n\nFor os.stat(), it is simple to create a datetime.datetime object from a\ndecimal.Decimal timestamp in the UTC timezone::\n\n    datetime.datetime.fromtimestamp(value, datetime.timezone.utc)\n\n.. note::\n   datetime.datetime only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\ndatetime.timedelta\n------------------\n\ndatetime.timedelta is the natural choice for a relative timestamp because it is\nclear that this type contains a timestamp, whereas int, float and Decimal are\nraw numbers. It can be used with datetime.datetime to get an absolute timestamp\nwhen the starting point is known.\n\ndatetime.timedelta has been rejected because it cannot be coerced to float and\nhas a fixed resolution. One new standard timestamp type is enough, Decimal is\npreferred over datetime.timedelta. Converting a datetime.timedelta to float\nrequires an explicit call to the datetime.timedelta.total_seconds() method.\n\n.. note::\n   datetime.timedelta only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\n\n.. _tuple:\n\nTuple of integers\n-----------------\n\nTo expose C functions in Python, a tuple of integers is the natural choice to\nstore a timestamp because the C language uses structures with integers fields\n(e.g. timeval and timespec structures). Using only integers avoids the loss of\nprecision (Python supports integers of arbitrary length). \n\nDocument[7]:\nPEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n\n\nDocument[8]:\nOne part is the proposal of a\nprotocol for objects to declare and provide support for exposing a\nfile system path representation. The other part deals with changes to\nPython's standard library to support the new protocol. These changes\nwill also lead to the pathlib module dropping its provisional status.\n\nProtocol\n--------\n\nThe following abstract base class defines the protocol for an object\nto be considered a path object::\n\n    import abc\n    import typing as t\n\n\n    class PathLike(abc.ABC):\n\n        \"\"\"Abstract base class for implementing the file system path protocol.\"\"\"@abc.abstractmethod\n        def __fspath__(self) -> t.Union[str, bytes]:\n            \"\"\"Return the file system path representation of the object.\"\"\"raise NotImplementedError\n\n\nObjects representing file system paths will implement the\n``__fspath__()`` method which will return the ``str`` or ``bytes``\nrepresentation of the path. The ``str`` representation is the\npreferred low-level path representation as it is human-readable and\nwhat people historically represent paths as.\n\n\nStandard library changes\n------------------------\n\nIt is expected that most APIs in Python's standard library that\ncurrently accept a file system path will be updated appropriately to\naccept path objects (whether that requires code or simply an update\nto documentation will vary). The modules mentioned below, though,\ndeserve specific details as they have either fundamental changes that\nempower the ability to use path objects, or entail additions/removal\nof APIs.\n\n\nbuiltins\n''''''''\n\n``open()`` [#builtins-open]_ will be updated to accept path objects as\nwell as continue to accept ``str`` and ``bytes``.\n\n\n\n\nQuestion: How do you present datetime objects in human readable format?\nAnswer:"
        }
      ],
      "documents": [
        {
          "id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
          "content": "PEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  0,
                  279
                ],
                "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
              }
            ],
            "split_idx_start": 0,
            "file_name": "pep-0321.txt",
            "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
            "split_id": 0,
            "_file_size": 4372,
            "page_number": 1,
            "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
          },
          "score": 0.09124755859375,
          "embedding": null,
          "file": {
            "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
            "name": "pep-0321.txt"
          },
          "result_id": "f93ab9cc-76ec-4120-9cfe-e6ac374b6684"
        },
        {
          "id": "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
          "content": "However, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. ",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  1194,
                  1425
                ],
                "doc_id": "d873a90f56222b0c02ef2987a6ef2390aa5f7400bb6f8fe5c1cfafebaba3a9d4"
              },
              {
                "range": [
                  0,
                  548
                ],
                "doc_id": "76db0307a81ca4d9012184b0066414935f4342f14219f177170a61737d6bfd2c"
              }
            ],
            "split_idx_start": 3396,
            "file_name": "pep-0498.txt",
            "_file_created_at": "2024-10-18T09:03:54.839485+00:00",
            "split_id": 3,
            "_file_size": 25320,
            "page_number": 1,
            "source_id": "51927b0152d7c0504de7a4e0a4f5265617143fce6a5f763d17118f6afdc92298"
          },
          "score": 0.06280517578125,
          "embedding": null,
          "file": {
            "id": "c549dad4-9306-417e-9e31-72eff4db300c",
            "name": "pep-0498.txt"
          },
          "result_id": "0c46d7af-4542-4b1e-ac23-95d5d2bdbc7c"
        },
        {
          "id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
          "content": "Same as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  1386,
                  1647
                ],
                "doc_id": "0080ddf63825baab764048b3e068878bd23701f44610365cd5808be57d4fe36d"
              },
              {
                "range": [
                  0,
                  255
                ],
                "doc_id": "2629b8672811bd4a8a6da1adaa55dc166d2fc0e3ba1b8336690e7599c77cc5f2"
              }
            ],
            "split_idx_start": 12752,
            "file_name": "pep-3101.txt",
            "_file_created_at": "2024-10-18T09:03:29.826858+00:00",
            "split_id": 11,
            "_file_size": 33149,
            "page_number": 1,
            "source_id": "b42e3a8de46bd3686eb4e0ec3015b34e916f424f29e9398acb58d062e89c15bf"
          },
          "score": 0.05792236328125,
          "embedding": null,
          "file": {
            "id": "d6987234-60e7-4651-864d-017631ca53b3",
            "name": "pep-3101.txt"
          },
          "result_id": "e497e02b-3aa9-498c-b687-fc850ed4398f"
        },
        {
          "id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
          "content": "Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  1582,
                  1892
                ],
                "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
              }
            ],
            "split_idx_start": 3041,
            "file_name": "pep-0321.txt",
            "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
            "split_id": 2,
            "_file_size": 4372,
            "page_number": 1,
            "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
          },
          "score": 0.02606201171875,
          "embedding": null,
          "file": {
            "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
            "name": "pep-0321.txt"
          },
          "result_id": "0956c775-a701-40e9-b914-5fdf82c42f19"
        },
        {
          "id": "bdf4d62f2f52e9a3d1e87e6e41b9679ada4a930c321d33d3e77544c137cb88fb",
          "content": "Only datetime/time instances with ``fold=1`` pickled\nin the new versions will become unreadable by the older Python\nversions.  Pickles of instances with ``fold=0`` (which is the\ndefault) will remain unchanged.\n\n\nQuestions and Answers\n=====================\n\nWhy not call the new flag \"isdst\"?\n----------------------------------\n\nA non-technical answer\n......................\n\n* Alice: Bob - let's have a stargazing party at 01:30 AM tomorrow!\n* Bob: Should I presume initially that Daylight Saving Time is or is\n  not in effect for the specified time?\n* Alice: Huh?\n\n-------\n\n* Bob: Alice - let's have a stargazing party at 01:30 AM tomorrow!\n* Alice: You know, Bob, 01:30 AM will happen twice tomorrow. Which time do you have in mind?\n* Bob:  I did not think about it, but let's pick the first.\n\n-------\n\n(same characters, an hour later)\n\n-------\n\n* Bob: Alice - this Py-O-Clock gadget of mine asks me to choose\n  between fold=0 and fold=1 when I set it for tomorrow 01:30 AM.\n  What should I do?\n* Alice: I've never hear of a Py-O-Clock, but I guess fold=0 is\n  the first 01:30 AM and fold=1 is the second.\n\n\nA technical reason\n..................\n\nWhile the ``tm_isdst`` field of the ``time.struct_time`` object can be\nused to disambiguate local times in the fold, the semantics of such\ndisambiguation are completely different from the proposal in this PEP.\n\n",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  1389,
                  1681
                ],
                "doc_id": "a1270e82b4dbf104c429342bb71fb0a7fc80db41719f0d2a79ffa88215e9ced6"
              },
              {
                "range": [
                  0,
                  211
                ],
                "doc_id": "ea7d03dac129035cacbb28d07304048f31e99487736aecb2df16b8903874ccca"
              }
            ],
            "split_idx_start": 23551,
            "file_name": "pep-0495.txt",
            "_file_created_at": "2024-10-18T09:03:54.819307+00:00",
            "split_id": 18,
            "_file_size": 34899,
            "page_number": 1,
            "source_id": "04ae5810b522e53d51d5bb1f7e708f045a1e09977cde5b7e18a54646ffa0575f"
          },
          "score": 0.020294189453125,
          "embedding": null,
          "file": {
            "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
            "name": "pep-0495.txt"
          },
          "result_id": "77aed3e6-8840-4edf-a532-e9b66375b1e2"
        },
        {
          "id": "d707bfed2ede5435c51068efc5690033457d7e3106572b2221ee30097e16c20e",
          "content": "There is also an ordering issues with daylight saving time (DST) in\nthe duplicate hour of switching from DST to normal time.\n\ndatetime.datetime has been rejected because it cannot be used for functions\nusing an unspecified starting point like os.times() or time.clock().\n\nFor time.time() and time.clock_gettime(time.CLOCK_GETTIME): it is already\npossible to get the current time as a datetime.datetime object using::\n\n    datetime.datetime.now(datetime.timezone.utc)\n\nFor os.stat(), it is simple to create a datetime.datetime object from a\ndecimal.Decimal timestamp in the UTC timezone::\n\n    datetime.datetime.fromtimestamp(value, datetime.timezone.utc)\n\n.. note::\n   datetime.datetime only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\ndatetime.timedelta\n------------------\n\ndatetime.timedelta is the natural choice for a relative timestamp because it is\nclear that this type contains a timestamp, whereas int, float and Decimal are\nraw numbers. It can be used with datetime.datetime to get an absolute timestamp\nwhen the starting point is known.\n\ndatetime.timedelta has been rejected because it cannot be coerced to float and\nhas a fixed resolution. One new standard timestamp type is enough, Decimal is\npreferred over datetime.timedelta. Converting a datetime.timedelta to float\nrequires an explicit call to the datetime.timedelta.total_seconds() method.\n\n.. note::\n   datetime.timedelta only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\n\n.. _tuple:\n\nTuple of integers\n-----------------\n\nTo expose C functions in Python, a tuple of integers is the natural choice to\nstore a timestamp because the C language uses structures with integers fields\n(e.g. timeval and timespec structures). Using only integers avoids the loss of\nprecision (Python supports integers of arbitrary length). ",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  1272,
                  1544
                ],
                "doc_id": "2f29a4a6323783368c1160597feb0d31e710bffb8f3df64f28bc205d88de1698"
              },
              {
                "range": [
                  0,
                  342
                ],
                "doc_id": "c7a17a8edafad008f36b5244fcd85b81d3cb50261f11ba6159fe1297112fb956"
              }
            ],
            "split_idx_start": 8032,
            "file_name": "pep-0410.txt",
            "_file_created_at": "2024-10-18T09:04:01.074298+00:00",
            "split_id": 6,
            "_file_size": 20703,
            "page_number": 1,
            "source_id": "0a5ffe8e2eae3b854132370ba3ee43c31cba6d88fb72c635690acb723fcadeae"
          },
          "score": 0.019683837890625,
          "embedding": null,
          "file": {
            "id": "5eda3f1a-74b9-4887-9772-35ca44be1e99",
            "name": "pep-0410.txt"
          },
          "result_id": "fd0e6f52-d944-4642-bc66-61b852960cc8"
        },
        {
          "id": "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
          "content": "PEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  0,
                  185
                ],
                "doc_id": "2491a8b58f7bb1979fdf5061006dfc72c54b6e9e287f06f9b8a5dd669967c874"
              }
            ],
            "split_idx_start": 0,
            "file_name": "pep-0500.txt",
            "_file_created_at": "2024-10-18T09:03:51.944443+00:00",
            "split_id": 0,
            "_file_size": 7045,
            "page_number": 1,
            "source_id": "5180621105b359308fb5b39c5455b227c26cb8533a69672335202ed14e8d568d"
          },
          "score": 0.018798828125,
          "embedding": null,
          "file": {
            "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
            "name": "pep-0500.txt"
          },
          "result_id": "623d6f02-476c-4110-83e9-92186bc055b9"
        },
        {
          "id": "d9878e926481ac189a88db4f7ed36cb64cd9e28bd58c450ee11c2731dba935d6",
          "content": "One part is the proposal of a\nprotocol for objects to declare and provide support for exposing a\nfile system path representation. The other part deals with changes to\nPython's standard library to support the new protocol. These changes\nwill also lead to the pathlib module dropping its provisional status.\n\nProtocol\n--------\n\nThe following abstract base class defines the protocol for an object\nto be considered a path object::\n\n    import abc\n    import typing as t\n\n\n    class PathLike(abc.ABC):\n\n        \"\"\"Abstract base class for implementing the file system path protocol.\"\"\"@abc.abstractmethod\n        def __fspath__(self) -> t.Union[str, bytes]:\n            \"\"\"Return the file system path representation of the object.\"\"\"raise NotImplementedError\n\n\nObjects representing file system paths will implement the\n``__fspath__()`` method which will return the ``str`` or ``bytes``\nrepresentation of the path. The ``str`` representation is the\npreferred low-level path representation as it is human-readable and\nwhat people historically represent paths as.\n\n\nStandard library changes\n------------------------\n\nIt is expected that most APIs in Python's standard library that\ncurrently accept a file system path will be updated appropriately to\naccept path objects (whether that requires code or simply an update\nto documentation will vary). The modules mentioned below, though,\ndeserve specific details as they have either fundamental changes that\nempower the ability to use path objects, or entail additions/removal\nof APIs.\n\n\nbuiltins\n''''''''\n\n``open()`` [#builtins-open]_ will be updated to accept path objects as\nwell as continue to accept ``str`` and ``bytes``.\n\n\n",
          "content_type": "text",
          "meta": {
            "_split_overlap": [
              {
                "range": [
                  1308,
                  1615
                ],
                "doc_id": "73e62bf9eacb2631fd3da8a9f98313919f5e6851cbc7fcd72f71b8e2ffb578d9"
              },
              {
                "range": [
                  0,
                  329
                ],
                "doc_id": "e3149c5c7a835f78b529358fafabe007d0d109d48517de4314d5f6ad45534d7a"
              }
            ],
            "split_idx_start": 3824,
            "file_name": "pep-0519.txt",
            "_file_created_at": "2024-10-18T09:03:49.692777+00:00",
            "split_id": 3,
            "_file_size": 22105,
            "page_number": 1,
            "source_id": "cf21ac8366c79d9b83f9fc8a0efd4982b0d4d4e0ae7c2716a5eea2fca6bf00a9"
          },
          "score": 0.0169219970703125,
          "embedding": null,
          "file": {
            "id": "a8a8d83e-6696-46c7-9ebf-3a953da41132",
            "name": "pep-0519.txt"
          },
          "result_id": "85c4399f-38d4-439d-94b6-ffcfa7c52e67"
        }
      ],
      "_debug": null,
      "prompts": null
    }
  ]
}

Chain the Requests

Here is a sample code that:

  1. Calls the Get Pipeline endpoint.
  2. Extracts the pipeline ID from the response and calls the Create Search Session endpoint to create a search session.
  3. Uses the session ID from the response to start the chat using the Chat endpoint.
import requests
import json

# Replace with your actual API key
API_KEY = "<api_key>"
BASE_URL = "https://api.cloud.deepset.ai/api/v1"
WORKSPACE = "legal-chat"
PIPELINE = "rag-chat"

headers = {
    "accept": "application/json",
    "authorization": f"Bearer {API_KEY}",
    "content-type": "application/json"
}

def get_pipeline_id():
    url = f"{BASE_URL}/workspaces/{WORKSPACE}/pipelines/{PIPELINE}"
    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        return response.json()["pipeline_id"]
    else:
        raise Exception(f"Failed to get pipeline ID: {response.status_code}")

def create_search_session(pipeline_id):
    url = f"{BASE_URL}/workspaces/{WORKSPACE}/search_sessions"
    data = {
        "pipeline_id": pipeline_id
    }
    response = requests.post(url, headers=headers, json=data)
    if response.status_code == 200:
        return response.json()["search_session_id"]
    else:
        raise Exception(f"Failed to create search session: {response.status_code}")

def start_chat(search_session_id, query):
    url = f"{BASE_URL}/workspaces/{WORKSPACE}/pipelines/{PIPELINE}/chat"
    data = {
        "chat_history_limit": 3,
        "debug": False,
        "view_prompts": False,
        "queries": [query],
        "search_session_id": search_session_id
    }
    response = requests.post(url, headers=headers, json=data)
    return response.status_code, response.json()

def main():
    try:
        # Get the pipeline ID
        pipeline_id = get_pipeline_id()
        print(f"Pipeline ID: {pipeline_id}")

        # Create a search session
        search_session_id = create_search_session(pipeline_id)
        print(f"Search Session ID: {search_session_id}")

        # Start the chat
        query = 'How do you present datetime objects in human readable format?"?'
        status_code, response_data = start_chat(search_session_id, query)
        print(f"Chat Status Code: {status_code}")
        print("Chat Response:")
        print(json.dumps(response_data, indent=2))

    except Exception as e:
        print(f"An error occurred: {str(e)}")

if __name__ == "__main__":
    main()
#!/bin/bash

API_KEY="<your API key>"
BASE_URL="https://api.cloud.deepset.ai/api/v1"
WORKSPACE="peps"
PIPELINE="rag-chat"

# Get pipeline ID
PIPELINE_ID=$(curl --silent --request GET \
     --url "${BASE_URL}/workspaces/${WORKSPACE}/pipelines/${PIPELINE}" \
     --header "accept: application/json" \
     --header "authorization: Bearer ${API_KEY}" | jq -r .pipeline_id)

echo "Pipeline ID: $PIPELINE_ID"

# Create search session
SEARCH_SESSION_ID=$(curl --silent --request POST \
     --url "${BASE_URL}/workspaces/${WORKSPACE}/search_sessions" \
     --header "accept: application/json" \
     --header "authorization: Bearer ${API_KEY}" \
     --header "content-type: application/json" \
     --data "{\"pipeline_id\": \"$PIPELINE_ID\"}" | jq -r .search_session_id)

echo "Search Session ID: $SEARCH_SESSION_ID"

# Start chat
curl --request POST \
     --url "${BASE_URL}/workspaces/${WORKSPACE}/pipelines/${PIPELINE}/chat" \
     --header "accept: application/json" \
     --header "authorization: Bearer ${API_KEY}" \
     --header "content-type: application/json" \
     --data "{
  \"chat_history_limit\": 3,
  \"debug\": false,
  \"view_prompts\": false,
  \"queries\": [
    \"How do you present datetime objects in human readable format?\"
  ],
  \"search_session_id\": \"$SEARCH_SESSION_ID\"
}"

Start a New Chat

To start a new chat, you must first create a new search session and then start a chat using the ID of the newly created session.

  1. Call the Create Search Session endpoint.
  2. Call the Chat endpoint providing the search session ID.

Show Previous Chats

Use the Pipeline Search History endpoint to display previous chats. Use this code snippet as a starting point for the request. Fill in:

  • the pipeline and workspace name (in the URL).
  • deepset Cloud API key (in headers).
import requests

url = "https://api.cloud.deepset.ai/api/v1/workspaces/peps/pipelines/rag-chat/search_history" #peps is the workspace name, rag-chat is the pipeline name

headers = {
    "accept": "application/json",
    "authorization": "Bearer <your_api_key>"
}

response = requests.get(url, headers=headers)

print(response.text)
curl --request GET \
     --url https://api.cloud.deepset.ai/api/v1/workspaces/legal-chat/pipelines/rag-chat/search_history \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <your_api_key>'
Sample response
{
  "data": [
    {
      "search_history_id": "41366067-34fd-4814-907b-fc9e6e9d5c87",
      "request": {
        "query": "how do I get a string representation of datetime?",
        "filters": {},
        "params": {}
      },
      "response": [
        {
          "search_result_history_id": "f78fd831-363c-4de1-bfd7-5c37a03da2c8",
          "result": {
            "answer": "To convert a datetime object to a string in Python, you can use the `strftime()` method provided by the `datetime` module. This method allows you to specify the string format in which you want the date and time to be expressed. Here is an example of how to use it:\n\n```python\nimport datetime\ndate = datetime.datetime.now()\nformatted_date = date.strftime(\"%Y-%m-%d %H:%M:%S\")\nprint(formatted_date)\n```\n\nIn this example, `%Y-%m-%d %H:%M:%S` is the format string that specifies the output format of the date and time .",
            "type": "generative",
            "score": null,
            "context": null,
            "offsets_in_document": [],
            "offsets_in_context": [],
            "document_id": null,
            "document_ids": [
              "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "c2fe9e54ae2ec2c66d129084630375b7c89d8d5b00a19a4a52c4966fbda70640",
              "241aa577d6795d9c3ee6260d07fa77d81b2538ec2c25704549bb089cedf13850",
              "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "d9d0117e5a5c1a9832d48943065a8c704b3da76939ebf38cd4d96cf0ec65c70a",
              "f1c5a03fa125585730c0bf8369c297a85e56a1a8b52c9047875110b5a2726966",
              "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "644f3cfbb8321ab100fc130d5f0ee054c64a7c11f2d2955995b96b311aa8a3ea"
            ],
            "meta": {
              "_references": [
                {
                  "answer_end_idx": 514,
                  "answer_start_idx": 514,
                  "document_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
                  "document_position": 4,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1738,
                  "doc_start_idx": 0,
                  "origin": "llm"
                }
              ]
            },
            "file": {
              "id": "c549dad4-9306-417e-9e31-72eff4db300c",
              "name": "pep-0498.txt"
            },
            "files": [
              {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              },
              {
                "id": "efc377d8-35ea-491a-b8e2-0c9b8bf36a6f",
                "name": "pep-0249.txt"
              },
              {
                "id": "a35111b3-3c0f-44d7-922a-dce35f889258",
                "name": "pep-0501.txt"
              },
              {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              },
              {
                "id": "34bb0d6e-094c-43f1-a560-eb181f46501c",
                "name": "pep-3138.txt"
              },
              {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              }
            ],
            "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nHowever, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. \n\nDocument[2]:\nWhen the database module sees\na Python string object, it doesn't know if it should be bound as a\nsimple ``CHAR`` column, as a raw ``BINARY`` item, or as a ``DATE``.\n\nTo overcome this problem, a module must provide the constructors\ndefined below to create objects that can hold special values.  When\npassed to the cursor methods, the module can then detect the proper\ntype of the input parameter and bind it accordingly.\n\nA Cursor_ Object's description attribute returns information about\neach of the result columns of a query.  The ``type_code`` must compare\nequal to one of Type Objects defined below. Type Objects may be equal\nto more than one type code (e.g. ``DATETIME`` could be equal to the\ntype codes for date, time and timestamp columns; see the\n`Implementation Hints`_ below for details).\n\nThe module exports the following constructors and singletons:\n\n.. _Date:\n\n`Date`_\\ (*year*, *month*, *day*)\n    This function constructs an object holding a date value.\n\n\n.. _Time:\n\n`Time`_\\ (*hour*, *minute*, *second*)\n    This function constructs an object holding a time value.\n\n\n.. _Timestamp:\n\n`Timestamp`_\\ (*year*, *month*, *day*, *hour*, *minute*, *second*)\n    This function constructs an object holding a time stamp value.\n\n\n.. _DateFromTicks:\n\n`DateFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a date value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of `the standard Python time module\n    <http://docs.python.org/library/time.html>`__ for details).\n\n\n\nDocument[3]:\nThe ``__format__`` method on ``types.TemplateLiteral`` would then\nimplement the following :meth:`str.format` inspired semantics:\n\n.. code-block:: python-console\n\n  >>> import datetime\n  >>> name = 'Jane'\n  >>> age = 50\n  >>> anniversary = datetime.date(1991, 10, 12)\n  >>> format(t'My name is {name}, my age next year is {age+1}, my anniversary is {anniversary:%A, %B %d, %Y}.')'My name is Jane, my age next year is 51, my anniversary is Saturday, October 12, 1991.'>>> format(t'She said her name is {name!r}.')\"She said her name is 'Jane'.\"The syntax of template literals would be based on :pep:`701`, and largely use the same\nsyntax for the string portion of the template. Aside from using a different prefix, the one\nother syntactic change is in the definition and handling of conversion specifiers, both to\nallow ``!()`` as a standard conversion specifier to request evaluation of a field at\nrendering time, and to allow custom renderers to also define custom conversion specifiers.\n\nThis PEP does not propose to remove or deprecate any of the existing\nstring formatting mechanisms, as those will remain valuable when formatting\nstrings that are not present directly in the source code of the application.\n\n\nLazy field evaluation conversion specifier\n------------------------------------------\n\nIn addition to the existing support for the ``a``, ``r``, and ``s`` conversion specifiers,\n:meth:`str.format`, :meth:`str.format_map`, and :class:`string.Formatter` will be updated\nto accept ``()`` as a conversion specifier that means \"call the interpolated value\".\n\nTo support application of the standard conversion specifiers in custom template rendering\nfunctions, a new :func:`!operator.convert_field` function will be added.\n\n\n\nDocument[4]:\nPEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.\n\nDocument[5]:\nThis function converts any python object to a\n  string using PyObject_Repr() and then hex-escapes all non-ASCII\n  characters.  ``PyObject_ASCII()`` generates the same string as\n  ``PyObject_Repr()`` in Python 2.\n\n- Add a new built-in function, ``ascii()``.  This function converts\n  any python object to a string using repr() and then hex-escapes all\n  non-ASCII characters.  ``ascii()`` generates the same string as\n  ``repr()`` in Python 2.\n\n- Add a ``'%a'`` string format operator.  ``'%a'`` converts any python\n  object to a string using repr() and then hex-escapes all non-ASCII\n  characters.  The ``'%a'`` format operator generates the same string\n  as ``'%r'`` in Python 2.  Also, add ``'!a'`` conversion flags to the\n  ``string.format()`` method and add ``'%A'`` operator to the\n  PyUnicode_FromFormat().  They convert any object to an ASCII string\n  as ``'%a'`` string format operator.\n\n- Add an ``isprintable()`` method to the string type.\n  ``str.isprintable()`` returns False if repr() would escape any\n  character in the string; otherwise returns True.  The\n  ``isprintable()`` method calls the ``Py_UNICODE_ISPRINTABLE()``\n  function internally.\n\n\nRationale\n=========\n\nThe repr() in Python 3000 should be Unicode, not ASCII based, just\nlike Python 3000 strings.  Also, conversion should not be affected by\nthe locale setting, because the locale is not necessarily the same as\nthe output device's locale.  For example, it is common for a daemon\nprocess to be invoked in an ASCII setting, but writes UTF-8 to its log\nfiles.  Also, web applications might want to report the error\ninformation in more readable form based on the HTML page's encoding.\n\n\n\nDocument[6]:\nPEP: 3138\nTitle: String representation in Python 3000\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Atsuo Ishimoto <ishimoto at gembook.org>\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 05-May-2008\nPython-Version: 3.0\nPost-History: 05-May-2008, 05-Jun-2008\n\n\nAbstract\n========\n\nThis PEP proposes a new string representation form for Python 3000.\nIn Python prior to Python 3000, the repr() built-in function converted\narbitrary objects to printable ASCII strings for debugging and\nlogging.  For Python 3000, a wider range of characters, based on the\nUnicode standard, should be considered 'printable'.\n\n\nMotivation\n==========\n\nThe current repr() converts 8-bit strings to ASCII using following\nalgorithm.\n\n- Convert CR, LF, TAB and '\\\\' to '\\\\r', '\\\\n', '\\\\t', '\\\\\\\\'.\n\n- Convert other non-printable characters(0x00-0x1f, 0x7f) and\n  non-ASCII characters (>= 0x80) to '\\\\xXX'.\n\n- Backslash-escape quote characters (apostrophe, ') and add the quote\n  character at the beginning and the end.\n\nFor Unicode strings, the following additional conversions are done.\n\n- Convert leading surrogate pair characters without trailing character\n  (0xd800-0xdbff, but not followed by 0xdc00-0xdfff) to '\\\\uXXXX'.\n\n- Convert 16-bit characters (>= 0x100) to '\\\\uXXXX'.\n\n- Convert 21-bit characters (>= 0x10000) and surrogate pair characters\n  to '\\\\U00xxxxxx'.\n\nThis algorithm converts any string to printable ASCII, and repr() is\nused as a handy and safe way to print strings for debugging or for\nlogging.  Although all non-ASCII characters are escaped, this does not\nmatter when most of the string's characters are ASCII.  But for other\nlanguages, such as Japanese where most characters in a string are not\nASCII, this is very inconvenient.\n\n\n\nDocument[7]:\nSame as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n\n\nDocument[8]:\n.. _DateFromTicks:\n\n`DateFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a date value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of `the standard Python time module\n    <http://docs.python.org/library/time.html>`__ for details).\n\n.. _TimeFromTicks:\n\n`TimeFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a time value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of the standard Python time module for details).\n\n\n.. _TimeStampFromTicks:\n\n`TimestampFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a time stamp value from\n    the given ticks value (number of seconds since the epoch; see the\n    documentation of the standard Python time module for details).\n\n\n.. _Binary:\n\n`Binary`_\\ (*string*)\n    This function constructs an object capable of holding a binary\n    (long) string value.\n\n\n.. _STRING:\n\n`STRING`_ type\n    This type object is used to describe columns in a database that\n    are string-based (e.g. ``CHAR``).\n\n\n.. _Binary type:\n\n`BINARY`_ type\n    This type object is used to describe (long) binary columns in a\n    database (e.g. ``LONG``, ``RAW``, ``BLOB``\\s).\n\n\n.. _NUMBER:\n\n`NUMBER`_ type\n    This type object is used to describe numeric columns in a\n    database.\n\n\n.. _DATETIME:\n\n`DATETIME`_ type\n    This type object is used to describe date/time columns in a\n    database.\n\n.. _ROWID:\n\n`ROWID`_ type\n    This type object is used to describe the \"Row ID\" column in a\n    database.\n\n\nSQL ``NULL`` values are represented by the Python ``None`` singleton\non input and output.\n\n.. Note::\n    Usage of Unix ticks for database interfacing can cause troubles\n    because of the limited date range they cover.\n\n\n\n\n\nQuestion: How do I convert a datetime object to a string in Python?\nAnswer:"
          },
          "type": 1,
          "rank": 1,
          "documents": [
            {
              "id": "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "content": "However, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1194,
                      1425
                    ],
                    "doc_id": "d873a90f56222b0c02ef2987a6ef2390aa5f7400bb6f8fe5c1cfafebaba3a9d4"
                  },
                  {
                    "range": [
                      0,
                      548
                    ],
                    "doc_id": "76db0307a81ca4d9012184b0066414935f4342f14219f177170a61737d6bfd2c"
                  }
                ],
                "split_idx_start": 3396,
                "file_name": "pep-0498.txt",
                "_file_created_at": "2024-10-18T09:03:54.839485+00:00",
                "split_id": 3,
                "_file_size": 25320,
                "page_number": 1,
                "source_id": "51927b0152d7c0504de7a4e0a4f5265617143fce6a5f763d17118f6afdc92298"
              },
              "score": 0.7236328125,
              "file": {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              }
            },
            {
              "id": "c2fe9e54ae2ec2c66d129084630375b7c89d8d5b00a19a4a52c4966fbda70640",
              "content": "When the database module sees\na Python string object, it doesn't know if it should be bound as a\nsimple ``CHAR`` column, as a raw ``BINARY`` item, or as a ``DATE``.\n\nTo overcome this problem, a module must provide the constructors\ndefined below to create objects that can hold special values.  When\npassed to the cursor methods, the module can then detect the proper\ntype of the input parameter and bind it accordingly.\n\nA Cursor_ Object's description attribute returns information about\neach of the result columns of a query.  The ``type_code`` must compare\nequal to one of Type Objects defined below. Type Objects may be equal\nto more than one type code (e.g. ``DATETIME`` could be equal to the\ntype codes for date, time and timestamp columns; see the\n`Implementation Hints`_ below for details).\n\nThe module exports the following constructors and singletons:\n\n.. _Date:\n\n`Date`_\\ (*year*, *month*, *day*)\n    This function constructs an object holding a date value.\n\n\n.. _Time:\n\n`Time`_\\ (*hour*, *minute*, *second*)\n    This function constructs an object holding a time value.\n\n\n.. _Timestamp:\n\n`Timestamp`_\\ (*year*, *month*, *day*, *hour*, *minute*, *second*)\n    This function constructs an object holding a time stamp value.\n\n\n.. _DateFromTicks:\n\n`DateFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a date value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of `the standard Python time module\n    <http://docs.python.org/library/time.html>`__ for details).\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1386,
                      1552
                    ],
                    "doc_id": "467d2872382327256d3b1321156980966fb1c294bcc08596d8fb3c04d97c1052"
                  },
                  {
                    "range": [
                      0,
                      302
                    ],
                    "doc_id": "644f3cfbb8321ab100fc130d5f0ee054c64a7c11f2d2955995b96b311aa8a3ea"
                  }
                ],
                "split_idx_start": 18317,
                "file_name": "pep-0249.txt",
                "_file_created_at": "2024-10-18T09:04:14.063065+00:00",
                "split_id": 13,
                "_file_size": 46420,
                "page_number": 1,
                "source_id": "844df4c20398c29318a2ab1a588f79da140a39b37bc7138536f9bf64fb19b378"
              },
              "score": 0.5224609375,
              "file": {
                "id": "efc377d8-35ea-491a-b8e2-0c9b8bf36a6f",
                "name": "pep-0249.txt"
              }
            },
            {
              "id": "241aa577d6795d9c3ee6260d07fa77d81b2538ec2c25704549bb089cedf13850",
              "content": "The ``__format__`` method on ``types.TemplateLiteral`` would then\nimplement the following :meth:`str.format` inspired semantics:\n\n.. code-block:: python-console\n\n  >>> import datetime\n  >>> name = 'Jane'\n  >>> age = 50\n  >>> anniversary = datetime.date(1991, 10, 12)\n  >>> format(t'My name is {name}, my age next year is {age+1}, my anniversary is {anniversary:%A, %B %d, %Y}.')'My name is Jane, my age next year is 51, my anniversary is Saturday, October 12, 1991.'>>> format(t'She said her name is {name!r}.')\"She said her name is 'Jane'.\"The syntax of template literals would be based on :pep:`701`, and largely use the same\nsyntax for the string portion of the template. Aside from using a different prefix, the one\nother syntactic change is in the definition and handling of conversion specifiers, both to\nallow ``!()`` as a standard conversion specifier to request evaluation of a field at\nrendering time, and to allow custom renderers to also define custom conversion specifiers.\n\nThis PEP does not propose to remove or deprecate any of the existing\nstring formatting mechanisms, as those will remain valuable when formatting\nstrings that are not present directly in the source code of the application.\n\n\nLazy field evaluation conversion specifier\n------------------------------------------\n\nIn addition to the existing support for the ``a``, ``r``, and ``s`` conversion specifiers,\n:meth:`str.format`, :meth:`str.format_map`, and :class:`string.Formatter` will be updated\nto accept ``()`` as a conversion specifier that means \"call the interpolated value\".\n\nTo support application of the standard conversion specifiers in custom template rendering\nfunctions, a new :func:`!operator.convert_field` function will be added.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1569,
                      1947
                    ],
                    "doc_id": "b08a3a2248140fe1a7f2107244f039a4d689ec3507385321ca9488adfc67a81f"
                  },
                  {
                    "range": [
                      0,
                      518
                    ],
                    "doc_id": "f94ef57b3e0d3555babeb2c67c2fefe2a9c7f2885d9fd6067d7ee5caf883bab9"
                  }
                ],
                "split_idx_start": 5675,
                "file_name": "pep-0501.txt",
                "_file_created_at": "2024-10-18T09:03:53.526225+00:00",
                "split_id": 4,
                "_file_size": 64602,
                "page_number": 1,
                "source_id": "d109b53ee7c89924afe3d116352c0570dea2b0fee1f9725c8d5c3e3370e7397c"
              },
              "score": 0.509765625,
              "file": {
                "id": "a35111b3-3c0f-44d7-922a-dce35f889258",
                "name": "pep-0501.txt"
              }
            },
            {
              "id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "content": "PEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      279
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 0,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.4453125,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "d9d0117e5a5c1a9832d48943065a8c704b3da76939ebf38cd4d96cf0ec65c70a",
              "content": "This function converts any python object to a\n  string using PyObject_Repr() and then hex-escapes all non-ASCII\n  characters.  ``PyObject_ASCII()`` generates the same string as\n  ``PyObject_Repr()`` in Python 2.\n\n- Add a new built-in function, ``ascii()``.  This function converts\n  any python object to a string using repr() and then hex-escapes all\n  non-ASCII characters.  ``ascii()`` generates the same string as\n  ``repr()`` in Python 2.\n\n- Add a ``'%a'`` string format operator.  ``'%a'`` converts any python\n  object to a string using repr() and then hex-escapes all non-ASCII\n  characters.  The ``'%a'`` format operator generates the same string\n  as ``'%r'`` in Python 2.  Also, add ``'!a'`` conversion flags to the\n  ``string.format()`` method and add ``'%A'`` operator to the\n  PyUnicode_FromFormat().  They convert any object to an ASCII string\n  as ``'%a'`` string format operator.\n\n- Add an ``isprintable()`` method to the string type.\n  ``str.isprintable()`` returns False if repr() would escape any\n  character in the string; otherwise returns True.  The\n  ``isprintable()`` method calls the ``Py_UNICODE_ISPRINTABLE()``\n  function internally.\n\n\nRationale\n=========\n\nThe repr() in Python 3000 should be Unicode, not ASCII based, just\nlike Python 3000 strings.  Also, conversion should not be affected by\nthe locale setting, because the locale is not necessarily the same as\nthe output device's locale.  For example, it is common for a daemon\nprocess to be invoked in an ASCII setting, but writes UTF-8 to its log\nfiles.  Also, web applications might want to report the error\ninformation in more readable form based on the HTML page's encoding.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1482,
                      1740
                    ],
                    "doc_id": "d855658705b20f55046f1995b8054dc02fd90639cbabb970d068879eaf04ae83"
                  },
                  {
                    "range": [
                      0,
                      242
                    ],
                    "doc_id": "0aa0fe37bdd5819d474dde4f0bd8a7e9a8e3d9d1d4e59983a8ef86f11fb34646"
                  }
                ],
                "split_idx_start": 4251,
                "file_name": "pep-3138.txt",
                "_file_created_at": "2024-10-18T09:03:27.557934+00:00",
                "split_id": 3,
                "_file_size": 12117,
                "page_number": 1,
                "source_id": "548ab131edfcfd545fa61b9579253dd8742f667a5e0f025c1eef72aa49212d64"
              },
              "score": 0.41796875,
              "file": {
                "id": "34bb0d6e-094c-43f1-a560-eb181f46501c",
                "name": "pep-3138.txt"
              }
            },
            {
              "id": "f1c5a03fa125585730c0bf8369c297a85e56a1a8b52c9047875110b5a2726966",
              "content": "PEP: 3138\nTitle: String representation in Python 3000\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Atsuo Ishimoto <ishimoto at gembook.org>\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 05-May-2008\nPython-Version: 3.0\nPost-History: 05-May-2008, 05-Jun-2008\n\n\nAbstract\n========\n\nThis PEP proposes a new string representation form for Python 3000.\nIn Python prior to Python 3000, the repr() built-in function converted\narbitrary objects to printable ASCII strings for debugging and\nlogging.  For Python 3000, a wider range of characters, based on the\nUnicode standard, should be considered 'printable'.\n\n\nMotivation\n==========\n\nThe current repr() converts 8-bit strings to ASCII using following\nalgorithm.\n\n- Convert CR, LF, TAB and '\\\\' to '\\\\r', '\\\\n', '\\\\t', '\\\\\\\\'.\n\n- Convert other non-printable characters(0x00-0x1f, 0x7f) and\n  non-ASCII characters (>= 0x80) to '\\\\xXX'.\n\n- Backslash-escape quote characters (apostrophe, ') and add the quote\n  character at the beginning and the end.\n\nFor Unicode strings, the following additional conversions are done.\n\n- Convert leading surrogate pair characters without trailing character\n  (0xd800-0xdbff, but not followed by 0xdc00-0xdfff) to '\\\\uXXXX'.\n\n- Convert 16-bit characters (>= 0x100) to '\\\\uXXXX'.\n\n- Convert 21-bit characters (>= 0x10000) and surrogate pair characters\n  to '\\\\U00xxxxxx'.\n\nThis algorithm converts any string to printable ASCII, and repr() is\nused as a handy and safe way to print strings for debugging or for\nlogging.  Although all non-ASCII characters are escaped, this does not\nmatter when most of the string's characters are ASCII.  But for other\nlanguages, such as Japanese where most characters in a string are not\nASCII, this is very inconvenient.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      236
                    ],
                    "doc_id": "ab86213978b04dc85ce262cdaf3b7e5fc0447dc65a1a832963ee522c086fc53e"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-3138.txt",
                "_file_created_at": "2024-10-18T09:03:27.557934+00:00",
                "split_id": 0,
                "_file_size": 12117,
                "page_number": 1,
                "source_id": "548ab131edfcfd545fa61b9579253dd8742f667a5e0f025c1eef72aa49212d64"
              },
              "score": 0.363525390625,
              "file": {
                "id": "34bb0d6e-094c-43f1-a560-eb181f46501c",
                "name": "pep-3138.txt"
              }
            },
            {
              "id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "content": "Same as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1386,
                      1647
                    ],
                    "doc_id": "0080ddf63825baab764048b3e068878bd23701f44610365cd5808be57d4fe36d"
                  },
                  {
                    "range": [
                      0,
                      255
                    ],
                    "doc_id": "2629b8672811bd4a8a6da1adaa55dc166d2fc0e3ba1b8336690e7599c77cc5f2"
                  }
                ],
                "split_idx_start": 12752,
                "file_name": "pep-3101.txt",
                "_file_created_at": "2024-10-18T09:03:29.826858+00:00",
                "split_id": 11,
                "_file_size": 33149,
                "page_number": 1,
                "source_id": "b42e3a8de46bd3686eb4e0ec3015b34e916f424f29e9398acb58d062e89c15bf"
              },
              "score": 0.3115234375,
              "file": {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              }
            },
            {
              "id": "644f3cfbb8321ab100fc130d5f0ee054c64a7c11f2d2955995b96b311aa8a3ea",
              "content": ".. _DateFromTicks:\n\n`DateFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a date value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of `the standard Python time module\n    <http://docs.python.org/library/time.html>`__ for details).\n\n.. _TimeFromTicks:\n\n`TimeFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a time value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of the standard Python time module for details).\n\n\n.. _TimeStampFromTicks:\n\n`TimestampFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a time stamp value from\n    the given ticks value (number of seconds since the epoch; see the\n    documentation of the standard Python time module for details).\n\n\n.. _Binary:\n\n`Binary`_\\ (*string*)\n    This function constructs an object capable of holding a binary\n    (long) string value.\n\n\n.. _STRING:\n\n`STRING`_ type\n    This type object is used to describe columns in a database that\n    are string-based (e.g. ``CHAR``).\n\n\n.. _Binary type:\n\n`BINARY`_ type\n    This type object is used to describe (long) binary columns in a\n    database (e.g. ``LONG``, ``RAW``, ``BLOB``\\s).\n\n\n.. _NUMBER:\n\n`NUMBER`_ type\n    This type object is used to describe numeric columns in a\n    database.\n\n\n.. _DATETIME:\n\n`DATETIME`_ type\n    This type object is used to describe date/time columns in a\n    database.\n\n.. _ROWID:\n\n`ROWID`_ type\n    This type object is used to describe the \"Row ID\" column in a\n    database.\n\n\nSQL ``NULL`` values are represented by the Python ``None`` singleton\non input and output.\n\n.. Note::\n    Usage of Unix ticks for database interfacing can cause troubles\n    because of the limited date range they cover.\n\n\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1234,
                      1536
                    ],
                    "doc_id": "c2fe9e54ae2ec2c66d129084630375b7c89d8d5b00a19a4a52c4966fbda70640"
                  },
                  {
                    "range": [
                      0,
                      222
                    ],
                    "doc_id": "71cc3c35f72e7a428734fb46c661ce5206d8a2a3edaf0ece31601a499edf3c55"
                  }
                ],
                "split_idx_start": 19551,
                "file_name": "pep-0249.txt",
                "_file_created_at": "2024-10-18T09:04:14.063065+00:00",
                "split_id": 14,
                "_file_size": 46420,
                "page_number": 1,
                "source_id": "844df4c20398c29318a2ab1a588f79da140a39b37bc7138536f9bf64fb19b378"
              },
              "score": 0.2783203125,
              "file": {
                "id": "efc377d8-35ea-491a-b8e2-0c9b8bf36a6f",
                "name": "pep-0249.txt"
              }
            }
          ],
          "score": null
        }
      ],
      "session_id": null,
      "time": "2024-10-18T11:00:24.885281Z",
      "duration": 7.059947967529297,
      "user": {
        "given_name": "Agnieszka",
        "family_name": "Marzec",
        "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
      },
      "pipeline": {
        "name": "rag-chat"
      }
    },
    {
      "search_history_id": "943af191-4b95-4a53-b58d-362747f9216d",
      "request": {
        "query": "how do I get a string representation of datetime?",
        "filters": {
          "operator": "AND",
          "conditions": []
        },
        "params": {}
      },
      "response": [
        {
          "search_result_history_id": "7b7f4e34-9ddf-41dd-8a31-55dad907b5b0",
          "result": {
            "answer": "To get a string representation of datetime objects in Python using the `strftime()` method, you can use the `strftime()` method provided by the `datetime` class. This method allows you to format a datetime object into a string based on the format string you provide. Here is an example of how to use it:\n\n```python\nfrom datetime import datetime\ncurrent_datetime = datetime.now()\nformatted_string = current_datetime.strftime(\"%Y-%m-%d %H:%M:%S\")\nprint(formatted_string)\n```\n\nIn this example, `%Y-%m-%d %H:%M:%S` is the format string that specifies the output format of the year, month, day, hour, minute, and second .",
            "type": "generative",
            "score": null,
            "context": null,
            "offsets_in_document": [],
            "offsets_in_context": [],
            "document_id": null,
            "document_ids": [
              "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "c66e138f5d63b1a3761a8885fc5115873f015b44a671f5e1626abc5751a8940c",
              "1bb922d8c613f2906c3ef1e680d03408b6923fb5d1cf3b85b6e697d50f37a46d",
              "2647fe43dcff4fffbf94cffce897b72267880e5cf2ca15fdeedfdfa19f9e13ae",
              "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0",
              "3ed8bbfdc93a522416b1e7326eb68bfe6cc43f4d31bd4e1a52830e6e49f2edb6",
              "206db8bf767c74b017f25da906f9fa3a11d690b86fd0449816fd61fba941999b"
            ],
            "meta": {
              "_references": [
                {
                  "answer_end_idx": 615,
                  "answer_start_idx": 615,
                  "document_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
                  "document_position": 1,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1738,
                  "doc_start_idx": 0,
                  "origin": "llm"
                }
              ]
            },
            "file": {
              "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
              "name": "pep-0321.txt"
            },
            "files": [
              {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              },
              {
                "id": "e1f78630-6eea-4edd-aab9-d635d49d61d6",
                "name": "pep-0680.txt"
              },
              {
                "id": "a8a8d83e-6696-46c7-9ebf-3a953da41132",
                "name": "pep-0519.txt"
              },
              {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              },
              {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              },
              {
                "id": "d7025700-2457-4d7c-b9aa-c7704f445201",
                "name": "pep-0431.txt"
              },
              {
                "id": "09b2172b-94f0-46c3-95dd-5c7f444b8444",
                "name": "pep-3140.txt"
              }
            ],
            "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nPEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.\n\nDocument[2]:\nSpecification\n=============\n\nA new module ``tomllib`` will be added to the Python standard library,\nexposing the following public functions:\n\n.. code-block::\n\n   def load(\n       fp: SupportsRead[bytes],\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n    ) -> dict[str, Any]: ...\n\n   def loads(\n       s: str,\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n   ) -> dict[str, Any]: ...\n\n``tomllib.load`` deserializes a binary file-like object containing a\nTOML document to a Python ``dict``.\nThe ``fp`` argument must have a ``read()`` method with the same API as\n``io.RawIOBase.read()``.\n\n``tomllib.loads`` deserializes a ``str`` instance containing a TOML document\nto a Python ``dict``.\n\nThe ``parse_float`` argument is a callable object that takes as input the\noriginal string representation of a TOML float, and returns a corresponding\nPython object (similar to ``parse_float`` in ``json.load``).\nFor example, the user may pass a function returning a ``decimal.Decimal``,\nfor use cases where exact precision is important. By default, TOML floats\nare parsed as instances of the Python ``float`` type.\n\nThe returned object contains only basic Python objects (``str``, ``int``,\n``bool``, ``float``, ``datetime.{datetime,date,time}``, ``list``, ``dict`` with\nstring keys), and the results of ``parse_float``.\n\n``tomllib.TOMLDecodeError`` is raised in the case of invalid TOML.\n\nNote that this PEP does not propose ``tomllib.dump`` or ``tomllib.dumps``\nfunctions; see `Including an API for writing TOML`_ for details.\n\n\nMaintenance Implications\n========================\n\nStability of TOML\n-----------------\n\nThe release of TOML 1.0.0 in January 2021 indicates the TOML format should\nnow be officially considered stable. \n\nDocument[3]:\nAt\nissue is the fact that while all file system paths can be represented\nas strings or bytes, not all strings or bytes represent a file system\npath. This can lead to issues where any e.g. string duck-types to a\nfile system path whether it actually represents a path or not.\n\nTo help elevate the representation of file system paths from their\nrepresentation as strings and bytes to a richer object representation,\nthe pathlib module [#pathlib]_ was provisionally introduced in\nPython 3.4 through :pep:`428`. While considered by some as an improvement\nover strings and bytes for file system paths, it has suffered from a\nlack of adoption. Typically the key issue listed for the low adoption\nrate has been the lack of support in the standard library. This lack\nof support required users of pathlib to manually convert path objects\nto strings by calling ``str(path)`` which many found error-prone.\n\nOne issue in converting path objects to strings comes from\nthe fact that the only generic way to get a string representation of\nthe path was to pass the object to ``str()``. This can pose a\nproblem when done blindly as nearly all Python objects have some\nstring representation whether they are a path or not, e.g.\n``str(None)`` will give a result that\n``builtins.open()`` [#builtins-open]_ will happily use to create a new\nfile.\n\nExacerbating this whole situation is the\n``DirEntry`` object [#os-direntry]_. While path objects have a\nrepresentation that can be extracted using ``str()``, ``DirEntry``\nobjects expose a ``path`` attribute instead. \n\nDocument[4]:\nSubtraction of timedelta\n------------------------\n\nA ``tzinfo`` subclass supporting the PDDM, may define a method called\n``__datetime_sub__`` that should take two arguments--a datetime and a\ntimedelta instances--and return a datetime instance.\n\n\nFormatting\n----------\n\nA ``tzinfo`` subclass supporting the PDDM, may define methods called\n``__datetime_isoformat__`` and ``__datetime_strftime__``.\n\nThe ``__datetime_isoformat__`` method should take a datetime instance\nand an optional separator and produce a string representation of the\ngiven datetime instance.\n\nThe ``__datetime_strftime__`` method should take a datetime instance\nand a format string and produce a string representation of the given\ndatetime instance formatted according to the given format.\n\n\nParsing\n-------\n\nA ``tzinfo`` subclass supporting the PDDM, may define a class method\ncalled ``__datetime_strptime__`` and register the \"canonical\" names of\nthe timezones that it implements with a registry. **TODO** Describe a\nregistry.\n\n\nChanges to datetime methods\n===========================\n\nSubtraction\n-----------\n\n::\n\n   class datetime:\n       def __sub__(self, other):\n           if isinstance(other, datetime):\n               try:\n                   self_diff = self.tzinfo.__datetime_diff__\n               except AttributeError:\n                   self_diff = None\n               try:\n                   other_diff = self.tzinfo.__datetime_diff__\n               except AttributeError:\n                   other_diff = None\n               if self_diff is not None:\n                   if self_diff is not other_diff and self_diff.__func__ is not other_diff.__func__:\n                       raise ValueError(\"Cannot find difference of two datetimes with \"\n                                        \"different tzinfo.__datetime_diff__ implementations.\")return self_diff(self, other)\n           elif isinstance(other, timedelta):\n               try:\n                   sub = self.tzinfo.__datetime_sub__\n               except AttributeError:\n                   pass\n               else:\n                   return sub(self, other)\n               return self + -other\n           else:\n               return NotImplemented\n           # current implementation\n\n\nAddition\n--------\n\nAddition of a timedelta to a datetime instance will be delegated to the\n``self.tzinfo.__datetime_add__`` method whenever it is defined.\n\n\n\n\nDocument[5]:\nSame as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n\n\nDocument[6]:\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.::\n\n        import datetime\n        d = datetime.date.parse_iso8601(\"2003-09-15T10:34:54\")\n\n3) Add a separate module (possible names: date, date_parse, parse_date)\n   or subpackage (possible names: datetime.parser) containing parsing\n   functions::\n\n        import datetime\n        d = datetime.parser.parse_iso8601(\"2003-09-15T10:34:54\")\n\n\nUnresolved questions:\n\n* Naming convention to use.\n* What exception to raise on errors?  ValueError, or a specialized exception?\n* Should you know what type you're expecting, or should the parsing figure\n  it out?  (e.g. ``parse_iso8601(\"yyyy-mm-dd\")`` returns a ``date`` instance,\n  but parsing \"yyyy-mm-ddThh:mm:ss\" returns a ``datetime``.)  Should\n  there be an option to signal an error if a time is provided where\n  none is expected, or if no time is provided?\n* Anything special required for I18N?  For time zones?\n\n\nGeneric Input Parsing\n=======================\n\nIs a strptime() implementation that returns ``datetime`` types sufficient?\n\nXXX if yes, describe strptime here.  Can the existing pure-Python\nimplementation be easily retargeted?\n\n\nOutput Formats\n=======================\n\nNot all input formats need to be supported as output formats, because it's\npretty trivial to get the ``strftime()`` argument right for simple things\nsuch as YYYY/MM/DD.   Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n\n\nDocument[7]:\nIn addition to this, several\nmethods on the datetime object gets a new ``is_dst`` parameter.\n\nNew class ``dsttimezone``\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThis class provides a concrete implementation of the ``tzinfo`` base\nclass that implements DST support.\n\n\nNew function ``zoneinfo(name=None, db_path=None)``\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThis function takes a name string that must be a string specifying a\nvalid zoneinfo time zone, i.e. \"US/Eastern\", \"Europe/Warsaw\" or \"Etc/GMT\".\nIf not given, the local time zone will be looked up. If an invalid zone name\nis given, or the local time zone can not be retrieved, the function raises\n``UnknownTimeZoneError``.\n\nThe function also takes an optional path to the location of the zoneinfo\ndatabase which should be used. If not specified, the function will look for\ndatabases in the following order:\n\n1. Check if the ``tzdata-update`` module is installed, and then use that\n   database.\n\n2. Use the database in ``/usr/share/zoneinfo``, if it exists.\n\n3. Use the Python-provided database in ``Lib/tzdata``.\n\nIf no database is found an ``UnknownTimeZoneError`` or subclass thereof will\nbe raised with a message explaining that no zoneinfo database can be found,\nbut that you can install one with the ``tzdata-update`` package.\n\n\nNew parameter ``is_dst``\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nA new ``is_dst`` parameter is added to several methods to handle time\nambiguity during DST changeovers.\n\n* ``tzinfo.utcoffset(dt, is_dst=False)``\n\n* ``tzinfo.dst(dt, is_dst=False)``\n\n* ``tzinfo.tzname(dt, is_dst=False)``\n\n* ``datetime.astimezone(tz, is_dst=False)``\n\nThe ``is_dst`` parameter can be ``False`` (default), ``True``, or ``None``.\n\n``False`` will specify that the given datetime should be interpreted as not\nhappening during daylight savings time, i.e. \n\nDocument[8]:\nIt is\nproposed to mimic how ``repr(container)`` works except one detail - call\n``str`` on items instead of ``repr``.  This allows a user to choose\nwhat results she want to get - from ``item.__repr__`` or ``item.__str__``.\n\n\nCurrent situation\n=================\n\nMost container types (tuples, lists, dicts, sets, etc.) do not\nimplement ``__str__`` method, so ``str(container)`` calls\n``container.__repr__``, and ``container.__repr__``, once called, forgets\nit is called from ``str`` and always calls ``repr`` on the container's\nitems.\n\nThis behaviour has advantages and disadvantages.  One advantage is\nthat most items are represented with type information - strings\nare surrounded by apostrophes, instances may have both class name\nand instance data::\n\n    >>> print([42, '42'])\n    [42, '42']\n    >>> print([Decimal('42'), datetime.now()])\n    [Decimal(\"42\"), datetime.datetime(2008, 5, 27, 19, 57, 43, 485028)]\n\nThe disadvantage is that ``__repr__`` often returns technical data\n(like '``<object at address>``') or unreadable string (hex-encoded\nstring if the input is non-ASCII string)::\n\n    >>> print(['тест'])\n    ['\\xd4\\xc5\\xd3\\xd4']\n\nOne of the motivations for :pep:`3138` is that neither ``repr`` nor ``str``\nwill allow the sensible printing of dicts whose keys are non-ASCII\ntext strings.  Now that Unicode identifiers are allowed, it\nincludes Python's own attribute dicts.  This also includes JSON\nserialization (and caused some hoops for the json lib).\n\n:pep:`3138` proposes to fix this by breaking the \"repr is safe ASCII\"\ninvariant, and changing the way ``repr`` (which is used for\npersistence) outputs some objects, with system-dependent failures.\n\nChanging how ``str(container)`` works would allow easy debugging in\nthe normal case, and retain the safety of ASCII-only for the\nmachine-readable  case.  \n\nQuestion: How do I get a string representation of datetime objects in Python using the `strftime()` method?\nAnswer:"
          },
          "type": 1,
          "rank": 1,
          "documents": [
            {
              "id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "content": "PEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      279
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 0,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.8203125,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "c66e138f5d63b1a3761a8885fc5115873f015b44a671f5e1626abc5751a8940c",
              "content": "Specification\n=============\n\nA new module ``tomllib`` will be added to the Python standard library,\nexposing the following public functions:\n\n.. code-block::\n\n   def load(\n       fp: SupportsRead[bytes],\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n    ) -> dict[str, Any]: ...\n\n   def loads(\n       s: str,\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n   ) -> dict[str, Any]: ...\n\n``tomllib.load`` deserializes a binary file-like object containing a\nTOML document to a Python ``dict``.\nThe ``fp`` argument must have a ``read()`` method with the same API as\n``io.RawIOBase.read()``.\n\n``tomllib.loads`` deserializes a ``str`` instance containing a TOML document\nto a Python ``dict``.\n\nThe ``parse_float`` argument is a callable object that takes as input the\noriginal string representation of a TOML float, and returns a corresponding\nPython object (similar to ``parse_float`` in ``json.load``).\nFor example, the user may pass a function returning a ``decimal.Decimal``,\nfor use cases where exact precision is important. By default, TOML floats\nare parsed as instances of the Python ``float`` type.\n\nThe returned object contains only basic Python objects (``str``, ``int``,\n``bool``, ``float``, ``datetime.{datetime,date,time}``, ``list``, ``dict`` with\nstring keys), and the results of ``parse_float``.\n\n``tomllib.TOMLDecodeError`` is raised in the case of invalid TOML.\n\nNote that this PEP does not propose ``tomllib.dump`` or ``tomllib.dumps``\nfunctions; see `Including an API for writing TOML`_ for details.\n\n\nMaintenance Implications\n========================\n\nStability of TOML\n-----------------\n\nThe release of TOML 1.0.0 in January 2021 indicates the TOML format should\nnow be officially considered stable. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1087,
                      1817
                    ],
                    "doc_id": "be319d32085d060af6147769231452042e5a2989156f5a50a6ba8310bf4fa224"
                  },
                  {
                    "range": [
                      0,
                      341
                    ],
                    "doc_id": "7a62c449f153d6c1b554673e317af0c33674d2a7cef2eb4405286bbfce1799c1"
                  }
                ],
                "split_idx_start": 2900,
                "file_name": "pep-0680.txt",
                "_file_created_at": "2024-10-18T09:03:37.652307+00:00",
                "split_id": 2,
                "_file_size": 23382,
                "page_number": 1,
                "source_id": "40ebf955c9de2779a5e7e6a5ffc362d402093444d3fe6f5d6110c230e184739e"
              },
              "score": 0.673828125,
              "file": {
                "id": "e1f78630-6eea-4edd-aab9-d635d49d61d6",
                "name": "pep-0680.txt"
              }
            },
            {
              "id": "1bb922d8c613f2906c3ef1e680d03408b6923fb5d1cf3b85b6e697d50f37a46d",
              "content": "At\nissue is the fact that while all file system paths can be represented\nas strings or bytes, not all strings or bytes represent a file system\npath. This can lead to issues where any e.g. string duck-types to a\nfile system path whether it actually represents a path or not.\n\nTo help elevate the representation of file system paths from their\nrepresentation as strings and bytes to a richer object representation,\nthe pathlib module [#pathlib]_ was provisionally introduced in\nPython 3.4 through :pep:`428`. While considered by some as an improvement\nover strings and bytes for file system paths, it has suffered from a\nlack of adoption. Typically the key issue listed for the low adoption\nrate has been the lack of support in the standard library. This lack\nof support required users of pathlib to manually convert path objects\nto strings by calling ``str(path)`` which many found error-prone.\n\nOne issue in converting path objects to strings comes from\nthe fact that the only generic way to get a string representation of\nthe path was to pass the object to ``str()``. This can pose a\nproblem when done blindly as nearly all Python objects have some\nstring representation whether they are a path or not, e.g.\n``str(None)`` will give a result that\n``builtins.open()`` [#builtins-open]_ will happily use to create a new\nfile.\n\nExacerbating this whole situation is the\n``DirEntry`` object [#os-direntry]_. While path objects have a\nrepresentation that can be extracted using ``str()``, ``DirEntry``\nobjects expose a ``path`` attribute instead. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1307,
                      1582
                    ],
                    "doc_id": "2a4f18222a1ad287031dd634428ab8e87b0a63a4f7f0cd1820545e5ce0fa123b"
                  },
                  {
                    "range": [
                      0,
                      332
                    ],
                    "doc_id": "73e62bf9eacb2631fd3da8a9f98313919f5e6851cbc7fcd72f71b8e2ffb578d9"
                  }
                ],
                "split_idx_start": 1307,
                "file_name": "pep-0519.txt",
                "_file_created_at": "2024-10-18T09:03:49.692777+00:00",
                "split_id": 1,
                "_file_size": 22105,
                "page_number": 1,
                "source_id": "cf21ac8366c79d9b83f9fc8a0efd4982b0d4d4e0ae7c2716a5eea2fca6bf00a9"
              },
              "score": 0.59130859375,
              "file": {
                "id": "a8a8d83e-6696-46c7-9ebf-3a953da41132",
                "name": "pep-0519.txt"
              }
            },
            {
              "id": "2647fe43dcff4fffbf94cffce897b72267880e5cf2ca15fdeedfdfa19f9e13ae",
              "content": "Subtraction of timedelta\n------------------------\n\nA ``tzinfo`` subclass supporting the PDDM, may define a method called\n``__datetime_sub__`` that should take two arguments--a datetime and a\ntimedelta instances--and return a datetime instance.\n\n\nFormatting\n----------\n\nA ``tzinfo`` subclass supporting the PDDM, may define methods called\n``__datetime_isoformat__`` and ``__datetime_strftime__``.\n\nThe ``__datetime_isoformat__`` method should take a datetime instance\nand an optional separator and produce a string representation of the\ngiven datetime instance.\n\nThe ``__datetime_strftime__`` method should take a datetime instance\nand a format string and produce a string representation of the given\ndatetime instance formatted according to the given format.\n\n\nParsing\n-------\n\nA ``tzinfo`` subclass supporting the PDDM, may define a class method\ncalled ``__datetime_strptime__`` and register the \"canonical\" names of\nthe timezones that it implements with a registry. **TODO** Describe a\nregistry.\n\n\nChanges to datetime methods\n===========================\n\nSubtraction\n-----------\n\n::\n\n   class datetime:\n       def __sub__(self, other):\n           if isinstance(other, datetime):\n               try:\n                   self_diff = self.tzinfo.__datetime_diff__\n               except AttributeError:\n                   self_diff = None\n               try:\n                   other_diff = self.tzinfo.__datetime_diff__\n               except AttributeError:\n                   other_diff = None\n               if self_diff is not None:\n                   if self_diff is not other_diff and self_diff.__func__ is not other_diff.__func__:\n                       raise ValueError(\"Cannot find difference of two datetimes with \"\n                                        \"different tzinfo.__datetime_diff__ implementations.\")return self_diff(self, other)\n           elif isinstance(other, timedelta):\n               try:\n                   sub = self.tzinfo.__datetime_sub__\n               except AttributeError:\n                   pass\n               else:\n                   return sub(self, other)\n               return self + -other\n           else:\n               return NotImplemented\n           # current implementation\n\n\nAddition\n--------\n\nAddition of a timedelta to a datetime instance will be delegated to the\n``self.tzinfo.__datetime_add__`` method whenever it is defined.\n\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1310,
                      1707
                    ],
                    "doc_id": "2491a8b58f7bb1979fdf5061006dfc72c54b6e9e287f06f9b8a5dd669967c874"
                  },
                  {
                    "range": [
                      0,
                      561
                    ],
                    "doc_id": "0870f6527dd03712cc858106c75f3074182ce7e6ab9f2698180ad5d98f0e97b4"
                  }
                ],
                "split_idx_start": 2989,
                "file_name": "pep-0500.txt",
                "_file_created_at": "2024-10-18T09:03:51.944443+00:00",
                "split_id": 2,
                "_file_size": 7045,
                "page_number": 1,
                "source_id": "5180621105b359308fb5b39c5455b227c26cb8533a69672335202ed14e8d568d"
              },
              "score": 0.51806640625,
              "file": {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              }
            },
            {
              "id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "content": "Same as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1386,
                      1647
                    ],
                    "doc_id": "0080ddf63825baab764048b3e068878bd23701f44610365cd5808be57d4fe36d"
                  },
                  {
                    "range": [
                      0,
                      255
                    ],
                    "doc_id": "2629b8672811bd4a8a6da1adaa55dc166d2fc0e3ba1b8336690e7599c77cc5f2"
                  }
                ],
                "split_idx_start": 12752,
                "file_name": "pep-3101.txt",
                "_file_created_at": "2024-10-18T09:03:29.826858+00:00",
                "split_id": 11,
                "_file_size": 33149,
                "page_number": 1,
                "source_id": "b42e3a8de46bd3686eb4e0ec3015b34e916f424f29e9398acb58d062e89c15bf"
              },
              "score": 0.45556640625,
              "file": {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              }
            },
            {
              "id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0",
              "content": "Options:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.::\n\n        import datetime\n        d = datetime.date.parse_iso8601(\"2003-09-15T10:34:54\")\n\n3) Add a separate module (possible names: date, date_parse, parse_date)\n   or subpackage (possible names: datetime.parser) containing parsing\n   functions::\n\n        import datetime\n        d = datetime.parser.parse_iso8601(\"2003-09-15T10:34:54\")\n\n\nUnresolved questions:\n\n* Naming convention to use.\n* What exception to raise on errors?  ValueError, or a specialized exception?\n* Should you know what type you're expecting, or should the parsing figure\n  it out?  (e.g. ``parse_iso8601(\"yyyy-mm-dd\")`` returns a ``date`` instance,\n  but parsing \"yyyy-mm-ddThh:mm:ss\" returns a ``datetime``.)  Should\n  there be an option to signal an error if a time is provided where\n  none is expected, or if no time is provided?\n* Anything special required for I18N?  For time zones?\n\n\nGeneric Input Parsing\n=======================\n\nIs a strptime() implementation that returns ``datetime`` types sufficient?\n\nXXX if yes, describe strptime here.  Can the existing pure-Python\nimplementation be easily retargeted?\n\n\nOutput Formats\n=======================\n\nNot all input formats need to be supported as output formats, because it's\npretty trivial to get the ``strftime()`` argument right for simple things\nsuch as YYYY/MM/DD.   Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1459,
                      1738
                    ],
                    "doc_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040"
                  },
                  {
                    "range": [
                      0,
                      310
                    ],
                    "doc_id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b"
                  }
                ],
                "split_idx_start": 1459,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 1,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.42919921875,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "3ed8bbfdc93a522416b1e7326eb68bfe6cc43f4d31bd4e1a52830e6e49f2edb6",
              "content": "In addition to this, several\nmethods on the datetime object gets a new ``is_dst`` parameter.\n\nNew class ``dsttimezone``\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThis class provides a concrete implementation of the ``tzinfo`` base\nclass that implements DST support.\n\n\nNew function ``zoneinfo(name=None, db_path=None)``\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThis function takes a name string that must be a string specifying a\nvalid zoneinfo time zone, i.e. \"US/Eastern\", \"Europe/Warsaw\" or \"Etc/GMT\".\nIf not given, the local time zone will be looked up. If an invalid zone name\nis given, or the local time zone can not be retrieved, the function raises\n``UnknownTimeZoneError``.\n\nThe function also takes an optional path to the location of the zoneinfo\ndatabase which should be used. If not specified, the function will look for\ndatabases in the following order:\n\n1. Check if the ``tzdata-update`` module is installed, and then use that\n   database.\n\n2. Use the database in ``/usr/share/zoneinfo``, if it exists.\n\n3. Use the Python-provided database in ``Lib/tzdata``.\n\nIf no database is found an ``UnknownTimeZoneError`` or subclass thereof will\nbe raised with a message explaining that no zoneinfo database can be found,\nbut that you can install one with the ``tzdata-update`` package.\n\n\nNew parameter ``is_dst``\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nA new ``is_dst`` parameter is added to several methods to handle time\nambiguity during DST changeovers.\n\n* ``tzinfo.utcoffset(dt, is_dst=False)``\n\n* ``tzinfo.dst(dt, is_dst=False)``\n\n* ``tzinfo.tzname(dt, is_dst=False)``\n\n* ``datetime.astimezone(tz, is_dst=False)``\n\nThe ``is_dst`` parameter can be ``False`` (default), ``True``, or ``None``.\n\n``False`` will specify that the given datetime should be interpreted as not\nhappening during daylight savings time, i.e. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1472,
                      1725
                    ],
                    "doc_id": "d8c0e6a3bb0ba615f0b18a75146331e7b4e532c276ecd01e4d345dc0835dad14"
                  },
                  {
                    "range": [
                      0,
                      360
                    ],
                    "doc_id": "77cf4e4e4c7ac638eb42557a1d6b484fc70a1dd13dda95a426d69af72b0b55ca"
                  }
                ],
                "split_idx_start": 7274,
                "file_name": "pep-0431.txt",
                "_file_created_at": "2024-10-18T09:03:56.985216+00:00",
                "split_id": 6,
                "_file_size": 12716,
                "page_number": 1,
                "source_id": "ad23eacb6af40a3617c027062ed701958fbab228e08ba41605693a9d5541172f"
              },
              "score": 0.3564453125,
              "file": {
                "id": "d7025700-2457-4d7c-b9aa-c7704f445201",
                "name": "pep-0431.txt"
              }
            },
            {
              "id": "206db8bf767c74b017f25da906f9fa3a11d690b86fd0449816fd61fba941999b",
              "content": "It is\nproposed to mimic how ``repr(container)`` works except one detail - call\n``str`` on items instead of ``repr``.  This allows a user to choose\nwhat results she want to get - from ``item.__repr__`` or ``item.__str__``.\n\n\nCurrent situation\n=================\n\nMost container types (tuples, lists, dicts, sets, etc.) do not\nimplement ``__str__`` method, so ``str(container)`` calls\n``container.__repr__``, and ``container.__repr__``, once called, forgets\nit is called from ``str`` and always calls ``repr`` on the container's\nitems.\n\nThis behaviour has advantages and disadvantages.  One advantage is\nthat most items are represented with type information - strings\nare surrounded by apostrophes, instances may have both class name\nand instance data::\n\n    >>> print([42, '42'])\n    [42, '42']\n    >>> print([Decimal('42'), datetime.now()])\n    [Decimal(\"42\"), datetime.datetime(2008, 5, 27, 19, 57, 43, 485028)]\n\nThe disadvantage is that ``__repr__`` often returns technical data\n(like '``<object at address>``') or unreadable string (hex-encoded\nstring if the input is non-ASCII string)::\n\n    >>> print(['тест'])\n    ['\\xd4\\xc5\\xd3\\xd4']\n\nOne of the motivations for :pep:`3138` is that neither ``repr`` nor ``str``\nwill allow the sensible printing of dicts whose keys are non-ASCII\ntext strings.  Now that Unicode identifiers are allowed, it\nincludes Python's own attribute dicts.  This also includes JSON\nserialization (and caused some hoops for the json lib).\n\n:pep:`3138` proposes to fix this by breaking the \"repr is safe ASCII\"\ninvariant, and changing the way ``repr`` (which is used for\npersistence) outputs some objects, with system-dependent failures.\n\nChanging how ``str(container)`` works would allow easy debugging in\nthe normal case, and retain the safety of ASCII-only for the\nmachine-readable  case.  ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1448,
                      1672
                    ],
                    "doc_id": "a93ad6d29fa48994170a64d5f035d034ee9cb7eed54c0f382a9e70da3935d231"
                  },
                  {
                    "range": [
                      0,
                      352
                    ],
                    "doc_id": "42eded5001258515a0e242c78b6f86445dc98e8bdd6704c28cd8d759ace83ab5"
                  }
                ],
                "split_idx_start": 1448,
                "file_name": "pep-3140.txt",
                "_file_created_at": "2024-10-18T09:03:27.060477+00:00",
                "split_id": 1,
                "_file_size": 6643,
                "page_number": 1,
                "source_id": "1885edad78357f10823cfe7dbaadeb2dc8edacc4604cb7589cf6a12fa4929b11"
              },
              "score": 0.353515625,
              "file": {
                "id": "09b2172b-94f0-46c3-95dd-5c7f444b8444",
                "name": "pep-3140.txt"
              }
            }
          ],
          "score": null
        }
      ],
      "session_id": "b826bb58-4f17-466e-a770-3f9ae89c5f4f",
      "time": "2024-10-18T10:56:55.310744Z",
      "duration": 7.6710498332977295,
      "user": {
        "given_name": "Agnieszka",
        "family_name": "Marzec",
        "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
      },
      "pipeline": {
        "name": "rag-chat"
      }
    },
    {
      "search_history_id": "036b2866-2703-4d59-823d-9d8e683c7fa1",
      "request": {
        "query": "How do you present datetime objects in human readable format?",
        "filters": {},
        "params": {}
      },
      "response": [
        {
          "search_result_history_id": "7ec72d79-639a-4291-8258-86a173ec02ae",
          "result": {
            "answer": "To present datetime objects in a human-readable format, you can use the `strftime()` method provided by the `datetime` class. This method allows you to specify the format of the output string using format specifiers that correspond to various components of the date and time. For example, you can format a datetime object to display the date and time in a readable format like \"Today is: {0:%a %b %d %H:%M:%S %Y}\". This would output a string such as \"Today is: Mon Sep 16 10:34:54 2023\" . Additionally, the `isoformat()` and `ctime()` methods on datetime objects return string representations of the time in ISO 8601 format and a more traditional format similar to the C function `asctime()`, respectively .",
            "type": "generative",
            "score": null,
            "context": null,
            "offsets_in_document": [],
            "offsets_in_context": [],
            "document_id": null,
            "document_ids": [
              "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
              "bdf4d62f2f52e9a3d1e87e6e41b9679ada4a930c321d33d3e77544c137cb88fb",
              "d707bfed2ede5435c51068efc5690033457d7e3106572b2221ee30097e16c20e",
              "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "d9878e926481ac189a88db4f7ed36cb64cd9e28bd58c450ee11c2731dba935d6"
            ],
            "meta": {
              "_references": [
                {
                  "answer_end_idx": 487,
                  "answer_start_idx": 487,
                  "document_id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
                  "document_position": 3,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1607,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 706,
                  "answer_start_idx": 706,
                  "document_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
                  "document_position": 1,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1738,
                  "doc_start_idx": 0,
                  "origin": "llm"
                }
              ]
            },
            "file": {
              "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
              "name": "pep-0321.txt"
            },
            "files": [
              {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              },
              {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              },
              {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              },
              {
                "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
                "name": "pep-0495.txt"
              },
              {
                "id": "5eda3f1a-74b9-4887-9772-35ca44be1e99",
                "name": "pep-0410.txt"
              },
              {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              },
              {
                "id": "a8a8d83e-6696-46c7-9ebf-3a953da41132",
                "name": "pep-0519.txt"
              }
            ],
            "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nPEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.\n\nDocument[2]:\nHowever, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. \n\nDocument[3]:\nSame as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n\n\nDocument[4]:\nOnly complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:\n\nDocument[5]:\nOnly datetime/time instances with ``fold=1`` pickled\nin the new versions will become unreadable by the older Python\nversions.  Pickles of instances with ``fold=0`` (which is the\ndefault) will remain unchanged.\n\n\nQuestions and Answers\n=====================\n\nWhy not call the new flag \"isdst\"?\n----------------------------------\n\nA non-technical answer\n......................\n\n* Alice: Bob - let's have a stargazing party at 01:30 AM tomorrow!\n* Bob: Should I presume initially that Daylight Saving Time is or is\n  not in effect for the specified time?\n* Alice: Huh?\n\n-------\n\n* Bob: Alice - let's have a stargazing party at 01:30 AM tomorrow!\n* Alice: You know, Bob, 01:30 AM will happen twice tomorrow. Which time do you have in mind?\n* Bob:  I did not think about it, but let's pick the first.\n\n-------\n\n(same characters, an hour later)\n\n-------\n\n* Bob: Alice - this Py-O-Clock gadget of mine asks me to choose\n  between fold=0 and fold=1 when I set it for tomorrow 01:30 AM.\n  What should I do?\n* Alice: I've never hear of a Py-O-Clock, but I guess fold=0 is\n  the first 01:30 AM and fold=1 is the second.\n\n\nA technical reason\n..................\n\nWhile the ``tm_isdst`` field of the ``time.struct_time`` object can be\nused to disambiguate local times in the fold, the semantics of such\ndisambiguation are completely different from the proposal in this PEP.\n\n\n\nDocument[6]:\nThere is also an ordering issues with daylight saving time (DST) in\nthe duplicate hour of switching from DST to normal time.\n\ndatetime.datetime has been rejected because it cannot be used for functions\nusing an unspecified starting point like os.times() or time.clock().\n\nFor time.time() and time.clock_gettime(time.CLOCK_GETTIME): it is already\npossible to get the current time as a datetime.datetime object using::\n\n    datetime.datetime.now(datetime.timezone.utc)\n\nFor os.stat(), it is simple to create a datetime.datetime object from a\ndecimal.Decimal timestamp in the UTC timezone::\n\n    datetime.datetime.fromtimestamp(value, datetime.timezone.utc)\n\n.. note::\n   datetime.datetime only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\ndatetime.timedelta\n------------------\n\ndatetime.timedelta is the natural choice for a relative timestamp because it is\nclear that this type contains a timestamp, whereas int, float and Decimal are\nraw numbers. It can be used with datetime.datetime to get an absolute timestamp\nwhen the starting point is known.\n\ndatetime.timedelta has been rejected because it cannot be coerced to float and\nhas a fixed resolution. One new standard timestamp type is enough, Decimal is\npreferred over datetime.timedelta. Converting a datetime.timedelta to float\nrequires an explicit call to the datetime.timedelta.total_seconds() method.\n\n.. note::\n   datetime.timedelta only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\n\n.. _tuple:\n\nTuple of integers\n-----------------\n\nTo expose C functions in Python, a tuple of integers is the natural choice to\nstore a timestamp because the C language uses structures with integers fields\n(e.g. timeval and timespec structures). Using only integers avoids the loss of\nprecision (Python supports integers of arbitrary length). \n\nDocument[7]:\nPEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n\n\nDocument[8]:\nOne part is the proposal of a\nprotocol for objects to declare and provide support for exposing a\nfile system path representation. The other part deals with changes to\nPython's standard library to support the new protocol. These changes\nwill also lead to the pathlib module dropping its provisional status.\n\nProtocol\n--------\n\nThe following abstract base class defines the protocol for an object\nto be considered a path object::\n\n    import abc\n    import typing as t\n\n\n    class PathLike(abc.ABC):\n\n        \"\"\"Abstract base class for implementing the file system path protocol.\"\"\"@abc.abstractmethod\n        def __fspath__(self) -> t.Union[str, bytes]:\n            \"\"\"Return the file system path representation of the object.\"\"\"raise NotImplementedError\n\n\nObjects representing file system paths will implement the\n``__fspath__()`` method which will return the ``str`` or ``bytes``\nrepresentation of the path. The ``str`` representation is the\npreferred low-level path representation as it is human-readable and\nwhat people historically represent paths as.\n\n\nStandard library changes\n------------------------\n\nIt is expected that most APIs in Python's standard library that\ncurrently accept a file system path will be updated appropriately to\naccept path objects (whether that requires code or simply an update\nto documentation will vary). The modules mentioned below, though,\ndeserve specific details as they have either fundamental changes that\nempower the ability to use path objects, or entail additions/removal\nof APIs.\n\n\nbuiltins\n''''''''\n\n``open()`` [#builtins-open]_ will be updated to accept path objects as\nwell as continue to accept ``str`` and ``bytes``.\n\n\n\n\nQuestion: How do you present datetime objects in human readable format?\nAnswer:"
          },
          "type": 1,
          "rank": 1,
          "documents": [
            {
              "id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "content": "PEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      279
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 0,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.09124755859375,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "content": "However, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1194,
                      1425
                    ],
                    "doc_id": "d873a90f56222b0c02ef2987a6ef2390aa5f7400bb6f8fe5c1cfafebaba3a9d4"
                  },
                  {
                    "range": [
                      0,
                      548
                    ],
                    "doc_id": "76db0307a81ca4d9012184b0066414935f4342f14219f177170a61737d6bfd2c"
                  }
                ],
                "split_idx_start": 3396,
                "file_name": "pep-0498.txt",
                "_file_created_at": "2024-10-18T09:03:54.839485+00:00",
                "split_id": 3,
                "_file_size": 25320,
                "page_number": 1,
                "source_id": "51927b0152d7c0504de7a4e0a4f5265617143fce6a5f763d17118f6afdc92298"
              },
              "score": 0.06280517578125,
              "file": {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              }
            },
            {
              "id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "content": "Same as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1386,
                      1647
                    ],
                    "doc_id": "0080ddf63825baab764048b3e068878bd23701f44610365cd5808be57d4fe36d"
                  },
                  {
                    "range": [
                      0,
                      255
                    ],
                    "doc_id": "2629b8672811bd4a8a6da1adaa55dc166d2fc0e3ba1b8336690e7599c77cc5f2"
                  }
                ],
                "split_idx_start": 12752,
                "file_name": "pep-3101.txt",
                "_file_created_at": "2024-10-18T09:03:29.826858+00:00",
                "split_id": 11,
                "_file_size": 33149,
                "page_number": 1,
                "source_id": "b42e3a8de46bd3686eb4e0ec3015b34e916f424f29e9398acb58d062e89c15bf"
              },
              "score": 0.05792236328125,
              "file": {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              }
            },
            {
              "id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
              "content": "Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1582,
                      1892
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 3041,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 2,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.02606201171875,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "bdf4d62f2f52e9a3d1e87e6e41b9679ada4a930c321d33d3e77544c137cb88fb",
              "content": "Only datetime/time instances with ``fold=1`` pickled\nin the new versions will become unreadable by the older Python\nversions.  Pickles of instances with ``fold=0`` (which is the\ndefault) will remain unchanged.\n\n\nQuestions and Answers\n=====================\n\nWhy not call the new flag \"isdst\"?\n----------------------------------\n\nA non-technical answer\n......................\n\n* Alice: Bob - let's have a stargazing party at 01:30 AM tomorrow!\n* Bob: Should I presume initially that Daylight Saving Time is or is\n  not in effect for the specified time?\n* Alice: Huh?\n\n-------\n\n* Bob: Alice - let's have a stargazing party at 01:30 AM tomorrow!\n* Alice: You know, Bob, 01:30 AM will happen twice tomorrow. Which time do you have in mind?\n* Bob:  I did not think about it, but let's pick the first.\n\n-------\n\n(same characters, an hour later)\n\n-------\n\n* Bob: Alice - this Py-O-Clock gadget of mine asks me to choose\n  between fold=0 and fold=1 when I set it for tomorrow 01:30 AM.\n  What should I do?\n* Alice: I've never hear of a Py-O-Clock, but I guess fold=0 is\n  the first 01:30 AM and fold=1 is the second.\n\n\nA technical reason\n..................\n\nWhile the ``tm_isdst`` field of the ``time.struct_time`` object can be\nused to disambiguate local times in the fold, the semantics of such\ndisambiguation are completely different from the proposal in this PEP.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1389,
                      1681
                    ],
                    "doc_id": "a1270e82b4dbf104c429342bb71fb0a7fc80db41719f0d2a79ffa88215e9ced6"
                  },
                  {
                    "range": [
                      0,
                      211
                    ],
                    "doc_id": "ea7d03dac129035cacbb28d07304048f31e99487736aecb2df16b8903874ccca"
                  }
                ],
                "split_idx_start": 23551,
                "file_name": "pep-0495.txt",
                "_file_created_at": "2024-10-18T09:03:54.819307+00:00",
                "split_id": 18,
                "_file_size": 34899,
                "page_number": 1,
                "source_id": "04ae5810b522e53d51d5bb1f7e708f045a1e09977cde5b7e18a54646ffa0575f"
              },
              "score": 0.020294189453125,
              "file": {
                "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
                "name": "pep-0495.txt"
              }
            },
            {
              "id": "d707bfed2ede5435c51068efc5690033457d7e3106572b2221ee30097e16c20e",
              "content": "There is also an ordering issues with daylight saving time (DST) in\nthe duplicate hour of switching from DST to normal time.\n\ndatetime.datetime has been rejected because it cannot be used for functions\nusing an unspecified starting point like os.times() or time.clock().\n\nFor time.time() and time.clock_gettime(time.CLOCK_GETTIME): it is already\npossible to get the current time as a datetime.datetime object using::\n\n    datetime.datetime.now(datetime.timezone.utc)\n\nFor os.stat(), it is simple to create a datetime.datetime object from a\ndecimal.Decimal timestamp in the UTC timezone::\n\n    datetime.datetime.fromtimestamp(value, datetime.timezone.utc)\n\n.. note::\n   datetime.datetime only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\ndatetime.timedelta\n------------------\n\ndatetime.timedelta is the natural choice for a relative timestamp because it is\nclear that this type contains a timestamp, whereas int, float and Decimal are\nraw numbers. It can be used with datetime.datetime to get an absolute timestamp\nwhen the starting point is known.\n\ndatetime.timedelta has been rejected because it cannot be coerced to float and\nhas a fixed resolution. One new standard timestamp type is enough, Decimal is\npreferred over datetime.timedelta. Converting a datetime.timedelta to float\nrequires an explicit call to the datetime.timedelta.total_seconds() method.\n\n.. note::\n   datetime.timedelta only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\n\n.. _tuple:\n\nTuple of integers\n-----------------\n\nTo expose C functions in Python, a tuple of integers is the natural choice to\nstore a timestamp because the C language uses structures with integers fields\n(e.g. timeval and timespec structures). Using only integers avoids the loss of\nprecision (Python supports integers of arbitrary length). ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1272,
                      1544
                    ],
                    "doc_id": "2f29a4a6323783368c1160597feb0d31e710bffb8f3df64f28bc205d88de1698"
                  },
                  {
                    "range": [
                      0,
                      342
                    ],
                    "doc_id": "c7a17a8edafad008f36b5244fcd85b81d3cb50261f11ba6159fe1297112fb956"
                  }
                ],
                "split_idx_start": 8032,
                "file_name": "pep-0410.txt",
                "_file_created_at": "2024-10-18T09:04:01.074298+00:00",
                "split_id": 6,
                "_file_size": 20703,
                "page_number": 1,
                "source_id": "0a5ffe8e2eae3b854132370ba3ee43c31cba6d88fb72c635690acb723fcadeae"
              },
              "score": 0.019683837890625,
              "file": {
                "id": "5eda3f1a-74b9-4887-9772-35ca44be1e99",
                "name": "pep-0410.txt"
              }
            },
            {
              "id": "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "content": "PEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      185
                    ],
                    "doc_id": "2491a8b58f7bb1979fdf5061006dfc72c54b6e9e287f06f9b8a5dd669967c874"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0500.txt",
                "_file_created_at": "2024-10-18T09:03:51.944443+00:00",
                "split_id": 0,
                "_file_size": 7045,
                "page_number": 1,
                "source_id": "5180621105b359308fb5b39c5455b227c26cb8533a69672335202ed14e8d568d"
              },
              "score": 0.018798828125,
              "file": {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              }
            },
            {
              "id": "d9878e926481ac189a88db4f7ed36cb64cd9e28bd58c450ee11c2731dba935d6",
              "content": "One part is the proposal of a\nprotocol for objects to declare and provide support for exposing a\nfile system path representation. The other part deals with changes to\nPython's standard library to support the new protocol. These changes\nwill also lead to the pathlib module dropping its provisional status.\n\nProtocol\n--------\n\nThe following abstract base class defines the protocol for an object\nto be considered a path object::\n\n    import abc\n    import typing as t\n\n\n    class PathLike(abc.ABC):\n\n        \"\"\"Abstract base class for implementing the file system path protocol.\"\"\"@abc.abstractmethod\n        def __fspath__(self) -> t.Union[str, bytes]:\n            \"\"\"Return the file system path representation of the object.\"\"\"raise NotImplementedError\n\n\nObjects representing file system paths will implement the\n``__fspath__()`` method which will return the ``str`` or ``bytes``\nrepresentation of the path. The ``str`` representation is the\npreferred low-level path representation as it is human-readable and\nwhat people historically represent paths as.\n\n\nStandard library changes\n------------------------\n\nIt is expected that most APIs in Python's standard library that\ncurrently accept a file system path will be updated appropriately to\naccept path objects (whether that requires code or simply an update\nto documentation will vary). The modules mentioned below, though,\ndeserve specific details as they have either fundamental changes that\nempower the ability to use path objects, or entail additions/removal\nof APIs.\n\n\nbuiltins\n''''''''\n\n``open()`` [#builtins-open]_ will be updated to accept path objects as\nwell as continue to accept ``str`` and ``bytes``.\n\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1308,
                      1615
                    ],
                    "doc_id": "73e62bf9eacb2631fd3da8a9f98313919f5e6851cbc7fcd72f71b8e2ffb578d9"
                  },
                  {
                    "range": [
                      0,
                      329
                    ],
                    "doc_id": "e3149c5c7a835f78b529358fafabe007d0d109d48517de4314d5f6ad45534d7a"
                  }
                ],
                "split_idx_start": 3824,
                "file_name": "pep-0519.txt",
                "_file_created_at": "2024-10-18T09:03:49.692777+00:00",
                "split_id": 3,
                "_file_size": 22105,
                "page_number": 1,
                "source_id": "cf21ac8366c79d9b83f9fc8a0efd4982b0d4d4e0ae7c2716a5eea2fca6bf00a9"
              },
              "score": 0.0169219970703125,
              "file": {
                "id": "a8a8d83e-6696-46c7-9ebf-3a953da41132",
                "name": "pep-0519.txt"
              }
            }
          ],
          "score": null
        }
      ],
      "session_id": "b44f553b-0619-4ac1-bb69-d717de8d795f",
      "time": "2024-10-18T10:40:54.571307Z",
      "duration": 6.825776815414429,
      "user": {
        "given_name": "Agnieszka",
        "family_name": "Marzec",
        "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
      },
      "pipeline": {
        "name": "rag-chat"
      }
    },
    {
      "search_history_id": "57812f87-3da5-4f74-856a-e9e75ea6d9fd",
      "request": {
        "query": "how do I present datetime objects in human readable formats?",
        "filters": {
          "operator": "AND",
          "conditions": []
        },
        "params": {}
      },
      "response": [
        {
          "search_result_history_id": "e2e00188-2822-41fc-8339-f2cd61fd6547",
          "result": {
            "answer": "To present datetime objects in human-readable formats, you can use the `strftime()` method provided by the `datetime` class. This method allows you to specify the format of the output string using format specifiers. For example, you can format a datetime object to display the date and time in a readable format like \"Day Month Date Hour:Minute:Second Year\" using the format specifier `\"%a %b %d %H:%M:%S %Y\"`. This would output a string such as \"Mon Sep 16 10:34:54 2003\" .\n\nAdditionally, Python's `datetime` class supports predefined format strings for commonly used date and time formats, such as RFC 2822. You can use these predefined format strings with the `strftime()` method to output the datetime in these formats directly, without needing to manually specify the individual components of the format .",
            "type": "generative",
            "score": null,
            "context": null,
            "offsets_in_document": [],
            "offsets_in_context": [],
            "document_id": null,
            "document_ids": [
              "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
              "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0",
              "d707bfed2ede5435c51068efc5690033457d7e3106572b2221ee30097e16c20e",
              "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "206db8bf767c74b017f25da906f9fa3a11d690b86fd0449816fd61fba941999b"
            ],
            "meta": {
              "_references": [
                {
                  "answer_end_idx": 473,
                  "answer_start_idx": 473,
                  "document_id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
                  "document_position": 2,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1607,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 809,
                  "answer_start_idx": 809,
                  "document_id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
                  "document_position": 4,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1330,
                  "doc_start_idx": 0,
                  "origin": "llm"
                }
              ]
            },
            "file": {
              "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
              "name": "pep-0321.txt"
            },
            "files": [
              {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              },
              {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              },
              {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              },
              {
                "id": "5eda3f1a-74b9-4887-9772-35ca44be1e99",
                "name": "pep-0410.txt"
              },
              {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              },
              {
                "id": "09b2172b-94f0-46c3-95dd-5c7f444b8444",
                "name": "pep-3140.txt"
              }
            ],
            "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nPEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.\n\nDocument[2]:\nSame as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n\n\nDocument[3]:\nHowever, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. \n\nDocument[4]:\nOnly complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:\n\nDocument[5]:\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.::\n\n        import datetime\n        d = datetime.date.parse_iso8601(\"2003-09-15T10:34:54\")\n\n3) Add a separate module (possible names: date, date_parse, parse_date)\n   or subpackage (possible names: datetime.parser) containing parsing\n   functions::\n\n        import datetime\n        d = datetime.parser.parse_iso8601(\"2003-09-15T10:34:54\")\n\n\nUnresolved questions:\n\n* Naming convention to use.\n* What exception to raise on errors?  ValueError, or a specialized exception?\n* Should you know what type you're expecting, or should the parsing figure\n  it out?  (e.g. ``parse_iso8601(\"yyyy-mm-dd\")`` returns a ``date`` instance,\n  but parsing \"yyyy-mm-ddThh:mm:ss\" returns a ``datetime``.)  Should\n  there be an option to signal an error if a time is provided where\n  none is expected, or if no time is provided?\n* Anything special required for I18N?  For time zones?\n\n\nGeneric Input Parsing\n=======================\n\nIs a strptime() implementation that returns ``datetime`` types sufficient?\n\nXXX if yes, describe strptime here.  Can the existing pure-Python\nimplementation be easily retargeted?\n\n\nOutput Formats\n=======================\n\nNot all input formats need to be supported as output formats, because it's\npretty trivial to get the ``strftime()`` argument right for simple things\nsuch as YYYY/MM/DD.   Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n\n\nDocument[6]:\nThere is also an ordering issues with daylight saving time (DST) in\nthe duplicate hour of switching from DST to normal time.\n\ndatetime.datetime has been rejected because it cannot be used for functions\nusing an unspecified starting point like os.times() or time.clock().\n\nFor time.time() and time.clock_gettime(time.CLOCK_GETTIME): it is already\npossible to get the current time as a datetime.datetime object using::\n\n    datetime.datetime.now(datetime.timezone.utc)\n\nFor os.stat(), it is simple to create a datetime.datetime object from a\ndecimal.Decimal timestamp in the UTC timezone::\n\n    datetime.datetime.fromtimestamp(value, datetime.timezone.utc)\n\n.. note::\n   datetime.datetime only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\ndatetime.timedelta\n------------------\n\ndatetime.timedelta is the natural choice for a relative timestamp because it is\nclear that this type contains a timestamp, whereas int, float and Decimal are\nraw numbers. It can be used with datetime.datetime to get an absolute timestamp\nwhen the starting point is known.\n\ndatetime.timedelta has been rejected because it cannot be coerced to float and\nhas a fixed resolution. One new standard timestamp type is enough, Decimal is\npreferred over datetime.timedelta. Converting a datetime.timedelta to float\nrequires an explicit call to the datetime.timedelta.total_seconds() method.\n\n.. note::\n   datetime.timedelta only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\n\n.. _tuple:\n\nTuple of integers\n-----------------\n\nTo expose C functions in Python, a tuple of integers is the natural choice to\nstore a timestamp because the C language uses structures with integers fields\n(e.g. timeval and timespec structures). Using only integers avoids the loss of\nprecision (Python supports integers of arbitrary length). \n\nDocument[7]:\nPEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n\n\nDocument[8]:\nIt is\nproposed to mimic how ``repr(container)`` works except one detail - call\n``str`` on items instead of ``repr``.  This allows a user to choose\nwhat results she want to get - from ``item.__repr__`` or ``item.__str__``.\n\n\nCurrent situation\n=================\n\nMost container types (tuples, lists, dicts, sets, etc.) do not\nimplement ``__str__`` method, so ``str(container)`` calls\n``container.__repr__``, and ``container.__repr__``, once called, forgets\nit is called from ``str`` and always calls ``repr`` on the container's\nitems.\n\nThis behaviour has advantages and disadvantages.  One advantage is\nthat most items are represented with type information - strings\nare surrounded by apostrophes, instances may have both class name\nand instance data::\n\n    >>> print([42, '42'])\n    [42, '42']\n    >>> print([Decimal('42'), datetime.now()])\n    [Decimal(\"42\"), datetime.datetime(2008, 5, 27, 19, 57, 43, 485028)]\n\nThe disadvantage is that ``__repr__`` often returns technical data\n(like '``<object at address>``') or unreadable string (hex-encoded\nstring if the input is non-ASCII string)::\n\n    >>> print(['тест'])\n    ['\\xd4\\xc5\\xd3\\xd4']\n\nOne of the motivations for :pep:`3138` is that neither ``repr`` nor ``str``\nwill allow the sensible printing of dicts whose keys are non-ASCII\ntext strings.  Now that Unicode identifiers are allowed, it\nincludes Python's own attribute dicts.  This also includes JSON\nserialization (and caused some hoops for the json lib).\n\n:pep:`3138` proposes to fix this by breaking the \"repr is safe ASCII\"\ninvariant, and changing the way ``repr`` (which is used for\npersistence) outputs some objects, with system-dependent failures.\n\nChanging how ``str(container)`` works would allow easy debugging in\nthe normal case, and retain the safety of ASCII-only for the\nmachine-readable  case.  \n\nQuestion: how do I present datetime objects in human readable formats?\nAnswer:"
          },
          "type": 1,
          "rank": 1,
          "documents": [
            {
              "id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "content": "PEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      279
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 0,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.168212890625,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "edbc2088c4f9922d1e38554a6e1919508f3d739682abb07769ff14bcfd53c132",
              "content": "Same as 'g' except switches to 'E'\n          if the number gets to large.\n    'n' - Number. This is the same as 'g', except that it uses the\n          current locale setting to insert the appropriate\n          number separator characters.\n    '%' - Percentage. Multiplies the number by 100 and displays\n          in fixed ('f') format, followed by a percent sign.\n    '' (None) - similar to 'g', except that it prints at least one\n          digit after the decimal point.\n\nObjects are able to define their own format specifiers to\nreplace the standard ones.  An example is the 'datetime' class,\nwhose format specifiers might look something like the\narguments to the ``strftime()`` function::\n\n    \"Today is: {0:%a %b %d %H:%M:%S %Y}\".format(datetime.now())\n\nFor all built-in types, an empty format specification will produce\nthe equivalent of ``str(value)``.  It is recommended that objects\ndefining their own format specifiers follow this convention as\nwell.\n\n\nExplicit Conversion Flag\n------------------------\n\nThe explicit conversion flag is used to transform the format field value\nbefore it is formatted.  This can be used to override the type-specific\nformatting behavior, and format the value as if it were a more\ngeneric type.  Currently, two explicit conversion flags are\nrecognized::\n\n    !r - convert the value to a string using repr().\n    !s - convert the value to a string using str().\n\nThese flags are placed before the format specifier::\n\n    \"{0!r:20}\".format(\"Hello\")\n\nIn the preceding example, the string \"Hello\" will be printed, with quotes,\nin a field of at least 20 characters width.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1386,
                      1647
                    ],
                    "doc_id": "0080ddf63825baab764048b3e068878bd23701f44610365cd5808be57d4fe36d"
                  },
                  {
                    "range": [
                      0,
                      255
                    ],
                    "doc_id": "2629b8672811bd4a8a6da1adaa55dc166d2fc0e3ba1b8336690e7599c77cc5f2"
                  }
                ],
                "split_idx_start": 12752,
                "file_name": "pep-3101.txt",
                "_file_created_at": "2024-10-18T09:03:29.826858+00:00",
                "split_id": 11,
                "_file_size": 33149,
                "page_number": 1,
                "source_id": "b42e3a8de46bd3686eb4e0ec3015b34e916f424f29e9398acb58d062e89c15bf"
              },
              "score": 0.0701904296875,
              "file": {
                "id": "d6987234-60e7-4651-864d-017631ca53b3",
                "name": "pep-3101.txt"
              }
            },
            {
              "id": "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "content": "However, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1194,
                      1425
                    ],
                    "doc_id": "d873a90f56222b0c02ef2987a6ef2390aa5f7400bb6f8fe5c1cfafebaba3a9d4"
                  },
                  {
                    "range": [
                      0,
                      548
                    ],
                    "doc_id": "76db0307a81ca4d9012184b0066414935f4342f14219f177170a61737d6bfd2c"
                  }
                ],
                "split_idx_start": 3396,
                "file_name": "pep-0498.txt",
                "_file_created_at": "2024-10-18T09:03:54.839485+00:00",
                "split_id": 3,
                "_file_size": 25320,
                "page_number": 1,
                "source_id": "51927b0152d7c0504de7a4e0a4f5265617143fce6a5f763d17118f6afdc92298"
              },
              "score": 0.06805419921875,
              "file": {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              }
            },
            {
              "id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
              "content": "Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1582,
                      1892
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 3041,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 2,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.035064697265625,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0",
              "content": "Options:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.::\n\n        import datetime\n        d = datetime.date.parse_iso8601(\"2003-09-15T10:34:54\")\n\n3) Add a separate module (possible names: date, date_parse, parse_date)\n   or subpackage (possible names: datetime.parser) containing parsing\n   functions::\n\n        import datetime\n        d = datetime.parser.parse_iso8601(\"2003-09-15T10:34:54\")\n\n\nUnresolved questions:\n\n* Naming convention to use.\n* What exception to raise on errors?  ValueError, or a specialized exception?\n* Should you know what type you're expecting, or should the parsing figure\n  it out?  (e.g. ``parse_iso8601(\"yyyy-mm-dd\")`` returns a ``date`` instance,\n  but parsing \"yyyy-mm-ddThh:mm:ss\" returns a ``datetime``.)  Should\n  there be an option to signal an error if a time is provided where\n  none is expected, or if no time is provided?\n* Anything special required for I18N?  For time zones?\n\n\nGeneric Input Parsing\n=======================\n\nIs a strptime() implementation that returns ``datetime`` types sufficient?\n\nXXX if yes, describe strptime here.  Can the existing pure-Python\nimplementation be easily retargeted?\n\n\nOutput Formats\n=======================\n\nNot all input formats need to be supported as output formats, because it's\npretty trivial to get the ``strftime()`` argument right for simple things\nsuch as YYYY/MM/DD.   Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1459,
                      1738
                    ],
                    "doc_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040"
                  },
                  {
                    "range": [
                      0,
                      310
                    ],
                    "doc_id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b"
                  }
                ],
                "split_idx_start": 1459,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 1,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.0234222412109375,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "d707bfed2ede5435c51068efc5690033457d7e3106572b2221ee30097e16c20e",
              "content": "There is also an ordering issues with daylight saving time (DST) in\nthe duplicate hour of switching from DST to normal time.\n\ndatetime.datetime has been rejected because it cannot be used for functions\nusing an unspecified starting point like os.times() or time.clock().\n\nFor time.time() and time.clock_gettime(time.CLOCK_GETTIME): it is already\npossible to get the current time as a datetime.datetime object using::\n\n    datetime.datetime.now(datetime.timezone.utc)\n\nFor os.stat(), it is simple to create a datetime.datetime object from a\ndecimal.Decimal timestamp in the UTC timezone::\n\n    datetime.datetime.fromtimestamp(value, datetime.timezone.utc)\n\n.. note::\n   datetime.datetime only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\ndatetime.timedelta\n------------------\n\ndatetime.timedelta is the natural choice for a relative timestamp because it is\nclear that this type contains a timestamp, whereas int, float and Decimal are\nraw numbers. It can be used with datetime.datetime to get an absolute timestamp\nwhen the starting point is known.\n\ndatetime.timedelta has been rejected because it cannot be coerced to float and\nhas a fixed resolution. One new standard timestamp type is enough, Decimal is\npreferred over datetime.timedelta. Converting a datetime.timedelta to float\nrequires an explicit call to the datetime.timedelta.total_seconds() method.\n\n.. note::\n   datetime.timedelta only supports microsecond resolution, but can be enhanced\n   to support nanosecond.\n\n\n.. _tuple:\n\nTuple of integers\n-----------------\n\nTo expose C functions in Python, a tuple of integers is the natural choice to\nstore a timestamp because the C language uses structures with integers fields\n(e.g. timeval and timespec structures). Using only integers avoids the loss of\nprecision (Python supports integers of arbitrary length). ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1272,
                      1544
                    ],
                    "doc_id": "2f29a4a6323783368c1160597feb0d31e710bffb8f3df64f28bc205d88de1698"
                  },
                  {
                    "range": [
                      0,
                      342
                    ],
                    "doc_id": "c7a17a8edafad008f36b5244fcd85b81d3cb50261f11ba6159fe1297112fb956"
                  }
                ],
                "split_idx_start": 8032,
                "file_name": "pep-0410.txt",
                "_file_created_at": "2024-10-18T09:04:01.074298+00:00",
                "split_id": 6,
                "_file_size": 20703,
                "page_number": 1,
                "source_id": "0a5ffe8e2eae3b854132370ba3ee43c31cba6d88fb72c635690acb723fcadeae"
              },
              "score": 0.0228424072265625,
              "file": {
                "id": "5eda3f1a-74b9-4887-9772-35ca44be1e99",
                "name": "pep-0410.txt"
              }
            },
            {
              "id": "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "content": "PEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      185
                    ],
                    "doc_id": "2491a8b58f7bb1979fdf5061006dfc72c54b6e9e287f06f9b8a5dd669967c874"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0500.txt",
                "_file_created_at": "2024-10-18T09:03:51.944443+00:00",
                "split_id": 0,
                "_file_size": 7045,
                "page_number": 1,
                "source_id": "5180621105b359308fb5b39c5455b227c26cb8533a69672335202ed14e8d568d"
              },
              "score": 0.0216522216796875,
              "file": {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              }
            },
            {
              "id": "206db8bf767c74b017f25da906f9fa3a11d690b86fd0449816fd61fba941999b",
              "content": "It is\nproposed to mimic how ``repr(container)`` works except one detail - call\n``str`` on items instead of ``repr``.  This allows a user to choose\nwhat results she want to get - from ``item.__repr__`` or ``item.__str__``.\n\n\nCurrent situation\n=================\n\nMost container types (tuples, lists, dicts, sets, etc.) do not\nimplement ``__str__`` method, so ``str(container)`` calls\n``container.__repr__``, and ``container.__repr__``, once called, forgets\nit is called from ``str`` and always calls ``repr`` on the container's\nitems.\n\nThis behaviour has advantages and disadvantages.  One advantage is\nthat most items are represented with type information - strings\nare surrounded by apostrophes, instances may have both class name\nand instance data::\n\n    >>> print([42, '42'])\n    [42, '42']\n    >>> print([Decimal('42'), datetime.now()])\n    [Decimal(\"42\"), datetime.datetime(2008, 5, 27, 19, 57, 43, 485028)]\n\nThe disadvantage is that ``__repr__`` often returns technical data\n(like '``<object at address>``') or unreadable string (hex-encoded\nstring if the input is non-ASCII string)::\n\n    >>> print(['тест'])\n    ['\\xd4\\xc5\\xd3\\xd4']\n\nOne of the motivations for :pep:`3138` is that neither ``repr`` nor ``str``\nwill allow the sensible printing of dicts whose keys are non-ASCII\ntext strings.  Now that Unicode identifiers are allowed, it\nincludes Python's own attribute dicts.  This also includes JSON\nserialization (and caused some hoops for the json lib).\n\n:pep:`3138` proposes to fix this by breaking the \"repr is safe ASCII\"\ninvariant, and changing the way ``repr`` (which is used for\npersistence) outputs some objects, with system-dependent failures.\n\nChanging how ``str(container)`` works would allow easy debugging in\nthe normal case, and retain the safety of ASCII-only for the\nmachine-readable  case.  ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1448,
                      1672
                    ],
                    "doc_id": "a93ad6d29fa48994170a64d5f035d034ee9cb7eed54c0f382a9e70da3935d231"
                  },
                  {
                    "range": [
                      0,
                      352
                    ],
                    "doc_id": "42eded5001258515a0e242c78b6f86445dc98e8bdd6704c28cd8d759ace83ab5"
                  }
                ],
                "split_idx_start": 1448,
                "file_name": "pep-3140.txt",
                "_file_created_at": "2024-10-18T09:03:27.060477+00:00",
                "split_id": 1,
                "_file_size": 6643,
                "page_number": 1,
                "source_id": "1885edad78357f10823cfe7dbaadeb2dc8edacc4604cb7589cf6a12fa4929b11"
              },
              "score": 0.0210113525390625,
              "file": {
                "id": "09b2172b-94f0-46c3-95dd-5c7f444b8444",
                "name": "pep-3140.txt"
              }
            }
          ],
          "score": null
        }
      ],
      "session_id": "b826bb58-4f17-466e-a770-3f9ae89c5f4f",
      "time": "2024-10-18T09:48:40.259617Z",
      "duration": 8.651193380355835,
      "user": {
        "given_name": "Agnieszka",
        "family_name": "Marzec",
        "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
      },
      "pipeline": {
        "name": "rag-chat"
      }
    },
    {
      "search_history_id": "76eac4e9-78f6-4b88-b029-4b952c6baba1",
      "request": {
        "query": "How do I format and parse datetime objects ?",
        "filters": {
          "operator": "AND",
          "conditions": []
        },
        "params": {}
      },
      "response": [
        {
          "search_result_history_id": "26eedb3b-6bbe-4c84-9abd-3349305080bd",
          "result": {
            "answer": "To format and parse datetime objects in Python, you can use the `datetime` module, which provides various methods for these tasks. Here are the specific standards and methods mentioned in the documents:\n\n1. **ISO 8601**: You can parse ISO 8601 formatted strings using the `datetime` module. For example, to parse an ISO 8601 string, you might use:\n   ```python\n   import datetime\n   d = datetime.datetime.fromisoformat('2021-09-15T10:34:54')\n   ```\n   This method directly supports the ISO 8601 format .\n\n2. **RFC 2822/ARPA**: For formatting dates according to RFC 2822, which is commonly used in email headers, you can use the `strftime` method with a specific format string. For example:\n   ```python\n   import datetime\n   d = datetime.datetime.now()\n   print(d.strftime('%a, %d %b %Y %H:%M:%S %z'))\n   ```\n   This will output the date in a format similar to what is used in RFC 2822 .\n\n3. **ctime**: The `ctime` method of datetime objects provides a way to get a string representation of the date and time in a format similar to the C function `asctime()`:\n   ```python\n   import datetime\n   d = datetime.datetime.now()\n   print(d.ctime())\n   ```\n   This outputs the datetime in the format: 'Day Mon Date HH:MM:SS YYYY' .\n\n4. **Custom Human-Readable Formats**: For more human-friendly formats like \"MM/DD/YYYY\" or \"DD-Month-YYYY\", you can use the `strftime` method to specify custom format strings:\n   ```python\n   import datetime\n   d = datetime.datetime.now()\n   print(d.strftime('%m/%d/%Y'))  # MM/DD/YYYY\n   print(d.strftime('%d-%B",
            "type": "generative",
            "score": null,
            "context": null,
            "offsets_in_document": [],
            "offsets_in_context": [],
            "document_id": null,
            "document_ids": [
              "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "c66e138f5d63b1a3761a8885fc5115873f015b44a671f5e1626abc5751a8940c",
              "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
              "f5c54070517794b55163859458e25a4ccc1eccecc4d17732e052fe51598ec356",
              "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "0208013b140d15f0db841a05a091c846e553ede10e869ad01f79c2b4e4cf455e",
              "100b3fc66bf034afd632c5e7172924cbf5f7d1f49ddb0a8d88183f49368d8d77"
            ],
            "meta": {
              "_references": [
                {
                  "answer_end_idx": 502,
                  "answer_start_idx": 502,
                  "document_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
                  "document_position": 1,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1738,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 886,
                  "answer_start_idx": 886,
                  "document_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
                  "document_position": 1,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1738,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 886,
                  "answer_start_idx": 886,
                  "document_id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
                  "document_position": 4,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1330,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 1223,
                  "answer_start_idx": 1223,
                  "document_id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
                  "document_position": 1,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1738,
                  "doc_start_idx": 0,
                  "origin": "llm"
                }
              ]
            },
            "file": {
              "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
              "name": "pep-0321.txt"
            },
            "files": [
              {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              },
              {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              },
              {
                "id": "e1f78630-6eea-4edd-aab9-d635d49d61d6",
                "name": "pep-0680.txt"
              },
              {
                "id": "cd992ee0-350b-48eb-88bb-968d59749fd3",
                "name": "pep-0615.txt"
              },
              {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              },
              {
                "id": "09712c03-b4a5-4fc2-b243-50a5e25d4037",
                "name": "pep-0700.txt"
              },
              {
                "id": "847eb370-ab07-47c1-af48-2f30c51cb4c9",
                "name": "pep-0722.txt"
              }
            ],
            "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nPEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.\n\nDocument[2]:\nPEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n\n\nDocument[3]:\nSpecification\n=============\n\nA new module ``tomllib`` will be added to the Python standard library,\nexposing the following public functions:\n\n.. code-block::\n\n   def load(\n       fp: SupportsRead[bytes],\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n    ) -> dict[str, Any]: ...\n\n   def loads(\n       s: str,\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n   ) -> dict[str, Any]: ...\n\n``tomllib.load`` deserializes a binary file-like object containing a\nTOML document to a Python ``dict``.\nThe ``fp`` argument must have a ``read()`` method with the same API as\n``io.RawIOBase.read()``.\n\n``tomllib.loads`` deserializes a ``str`` instance containing a TOML document\nto a Python ``dict``.\n\nThe ``parse_float`` argument is a callable object that takes as input the\noriginal string representation of a TOML float, and returns a corresponding\nPython object (similar to ``parse_float`` in ``json.load``).\nFor example, the user may pass a function returning a ``decimal.Decimal``,\nfor use cases where exact precision is important. By default, TOML floats\nare parsed as instances of the Python ``float`` type.\n\nThe returned object contains only basic Python objects (``str``, ``int``,\n``bool``, ``float``, ``datetime.{datetime,date,time}``, ``list``, ``dict`` with\nstring keys), and the results of ``parse_float``.\n\n``tomllib.TOMLDecodeError`` is raised in the case of invalid TOML.\n\nNote that this PEP does not propose ``tomllib.dump`` or ``tomllib.dumps``\nfunctions; see `Including an API for writing TOML`_ for details.\n\n\nMaintenance Implications\n========================\n\nStability of TOML\n-----------------\n\nThe release of TOML 1.0.0 in January 2021 indicates the TOML format should\nnow be officially considered stable. \n\nDocument[4]:\nOnly complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:\n\nDocument[5]:\nFinally, while it is true that someone who needs the ``zoneinfo`` module also\nneeds the ``datetime`` module, the reverse is not necessarily true: many people\nwill want to use ``datetime`` without ``zoneinfo``.  Considering that\n``zoneinfo`` will likely pull in additional, possibly more heavy-weight\nstandard library modules, it would be preferable to allow the two to be\nimported separately — particularly if potential \"tree shaking\" distributions\nare in Python's future. [#tree-shaking]_\n\nIn the final analysis, it makes sense to keep ``zoneinfo`` a separate module\nwith a separate documentation page rather than to put its classes and functions\ndirectly into ``datetime``.\n\nUsing ``datetime.zoneinfo`` instead of ``zoneinfo``\n###################################################\n\nA more palatable configuration may be to nest ``zoneinfo`` as a module under\n``datetime``, as ``datetime.zoneinfo``.\n\nArguments in favor of this:\n\n1. It neatly namespaces ``zoneinfo`` together with ``datetime``\n\n2. The ``timezone`` class is already in ``datetime``, and it may seem strange\n   that some time zones are in ``datetime`` and others are in a top-level\n   module.\n\n3. As mentioned earlier, importing ``zoneinfo`` necessarily requires importing\n   ``datetime``, so it is no imposition to require importing the parent module.\n\nArguments against this:\n\n1. In order to avoid forcing all ``datetime`` users to import ``zoneinfo``, the\n   ``zoneinfo`` module would need to be lazily imported, which means that\n   end-users would need to explicitly import ``datetime.zoneinfo`` (as opposed\n   to importing ``datetime`` and accessing the ``zoneinfo`` attribute on the\n   module). \n\nDocument[6]:\nHowever, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. \n\nDocument[7]:\nHowever, while this PEP brings the simple API closer to being able to replace\nthe JSON API, there is no formal policy that the simple API will replicate all\nof the functionality covered by the existing Warehouse APIs. Proposed additions\nto the simple API will still be considered on their individual merits, and the\nrequirement that the API should be simple and fast for the primary use case of\nlocating files for a project will remain the overriding consideration.\n\nWhy not allow other date formats?\n---------------------------------\n\nThe ISO 8601 standard is complex, and there seems little value in requiring\nclients to deal with that. The standard library ``datetime`` module provides\nmethods to parse ISO 8601 strings, but it is possible that users may want to\naccess index data *without* using Python (for example, piping the output of\n``curl`` into ``jq``). Having a single, well-defined format makes this easier,\nand doesn't have any significant disadvantages.\n\nWhat if file sizes are too big for a JSON number?\n-------------------------------------------------\n\nThe JSON standard does not specify how numbers are to be interpreted. Python can\nread and write arbitrary-length integers in a JSON file, so this should not be\nan issue for code written in Python. Non-Python implementations may need to take\ncare to handle large integers correctly, but this is not expected to be a\nsignificant problem.\n\nWhy not require PEP 440 versions?\n---------------------------------\n\nAt the time this PEP was written, PyPI still contains (and serves) projects and\nfiles with \"legacy\" versions. \n\nDocument[8]:\nThere is currently no standard tool that addresses this\nissue, and this PEP does *not* attempt to define one. However, any tool that\n*does* address this issue will need to know what 3rd party dependencies a script\nrequires. By defining a standard format for storing such data, existing tools,\nas well as any future tools, will be able to obtain that information without\nrequiring users to include tool-specific metadata in their scripts.\n\n\nRationale\n=========\n\nBecause a key requirement is writing single-file scripts, and simple sharing by\ngiving someone a copy of the script, the PEP defines a mechanism for embedding\ndependency data *within the script itself*, and not in an external file.\n\nWe define the concept of a *dependency block* that contains information about\nwhat 3rd party packages a script depends on.\n\nIn order to identify dependency blocks, the script can simply be read as a text\nfile. This is deliberate, as Python syntax changes over time, so attempting to\nparse the script as Python code would require choosing a specific version of\nPython syntax. Also, it is likely that at least some tools will not be written\nin Python, and expecting them to implement a Python parser is too much of a\nburden.\n\nHowever, to avoid needing changes to core Python, the format is designed to\nappear as comments to the Python parser. \n\nQuestion: How do I format and parse datetime objects in Python, considering the specific standards mentioned in the documents?\nAnswer:"
          },
          "type": 1,
          "rank": 1,
          "documents": [
            {
              "id": "7001548c9e254ad0d2a35c1fea7a93ebaca5edc7f7e58ccbdf9bb2c665960040",
              "content": "PEP: 321\nTitle: Date/Time Parsing and Formatting\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: A.M. Kuchling <[email protected]>\nStatus: Withdrawn\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 16-Sep-2003\nPython-Version: 2.4\nPost-History:\n\n\nAbstract\n========\n\nPython 2.3 added a number of simple date and time types in the\n``datetime`` module.  There's no support for parsing strings in various\nformats and returning a corresponding instance of one of the types.\nThis PEP proposes adding a family of predefined parsing function for\nseveral commonly used date and time formats, and a facility for generic\nparsing.\n\nThe types provided by the ``datetime`` module all have\n``.isoformat()`` and ``.ctime()`` methods that return string\nrepresentations of a time, and the ``.strftime()`` method can be used\nto construct new formats.  There are a number of additional\ncommonly-used formats that would be useful to have as part of the\nstandard library; this PEP also suggests how to add them.\n\n\nInput Formats\n=======================\n\nUseful formats to support include:\n\n* `ISO8601`_\n* ARPA/:rfc:`2822`\n* `ctime`_\n* Formats commonly written by humans such as the American\n  \"MM/DD/YYYY\", the European \"YYYY/MM/DD\", and variants such as\n  \"DD-Month-YYYY\".\n* CVS-style or tar-style dates (\"tomorrow\", \"12 hours ago\", etc.)\n\nXXX The Perl `ParseDate.pm`_ module supports many different input formats,\nboth absolute and relative.  Should we try to support them all?\n\nOptions:\n\n1) Add functions to the ``datetime`` module::\n\n        import datetime\n        d = datetime.parse_iso8601(\"2003-09-15T10:34:54\")\n\n2) Add class methods to the various types.  There are already various\n   class methods such as ``.now()``, so this would be pretty natural.",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      279
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 0,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.6826171875,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "content": "PEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      185
                    ],
                    "doc_id": "2491a8b58f7bb1979fdf5061006dfc72c54b6e9e287f06f9b8a5dd669967c874"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0500.txt",
                "_file_created_at": "2024-10-18T09:03:51.944443+00:00",
                "split_id": 0,
                "_file_size": 7045,
                "page_number": 1,
                "source_id": "5180621105b359308fb5b39c5455b227c26cb8533a69672335202ed14e8d568d"
              },
              "score": 0.353759765625,
              "file": {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              }
            },
            {
              "id": "c66e138f5d63b1a3761a8885fc5115873f015b44a671f5e1626abc5751a8940c",
              "content": "Specification\n=============\n\nA new module ``tomllib`` will be added to the Python standard library,\nexposing the following public functions:\n\n.. code-block::\n\n   def load(\n       fp: SupportsRead[bytes],\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n    ) -> dict[str, Any]: ...\n\n   def loads(\n       s: str,\n       /,\n       *,\n       parse_float: Callable[[str], Any] = ...,\n   ) -> dict[str, Any]: ...\n\n``tomllib.load`` deserializes a binary file-like object containing a\nTOML document to a Python ``dict``.\nThe ``fp`` argument must have a ``read()`` method with the same API as\n``io.RawIOBase.read()``.\n\n``tomllib.loads`` deserializes a ``str`` instance containing a TOML document\nto a Python ``dict``.\n\nThe ``parse_float`` argument is a callable object that takes as input the\noriginal string representation of a TOML float, and returns a corresponding\nPython object (similar to ``parse_float`` in ``json.load``).\nFor example, the user may pass a function returning a ``decimal.Decimal``,\nfor use cases where exact precision is important. By default, TOML floats\nare parsed as instances of the Python ``float`` type.\n\nThe returned object contains only basic Python objects (``str``, ``int``,\n``bool``, ``float``, ``datetime.{datetime,date,time}``, ``list``, ``dict`` with\nstring keys), and the results of ``parse_float``.\n\n``tomllib.TOMLDecodeError`` is raised in the case of invalid TOML.\n\nNote that this PEP does not propose ``tomllib.dump`` or ``tomllib.dumps``\nfunctions; see `Including an API for writing TOML`_ for details.\n\n\nMaintenance Implications\n========================\n\nStability of TOML\n-----------------\n\nThe release of TOML 1.0.0 in January 2021 indicates the TOML format should\nnow be officially considered stable. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1087,
                      1817
                    ],
                    "doc_id": "be319d32085d060af6147769231452042e5a2989156f5a50a6ba8310bf4fa224"
                  },
                  {
                    "range": [
                      0,
                      341
                    ],
                    "doc_id": "7a62c449f153d6c1b554673e317af0c33674d2a7cef2eb4405286bbfce1799c1"
                  }
                ],
                "split_idx_start": 2900,
                "file_name": "pep-0680.txt",
                "_file_created_at": "2024-10-18T09:03:37.652307+00:00",
                "split_id": 2,
                "_file_size": 23382,
                "page_number": 1,
                "source_id": "40ebf955c9de2779a5e7e6a5ffc362d402093444d3fe6f5d6110c230e184739e"
              },
              "score": 0.318603515625,
              "file": {
                "id": "e1f78630-6eea-4edd-aab9-d635d49d61d6",
                "name": "pep-0680.txt"
              }
            },
            {
              "id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
              "content": "Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1582,
                      1892
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 3041,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 2,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.282958984375,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            },
            {
              "id": "f5c54070517794b55163859458e25a4ccc1eccecc4d17732e052fe51598ec356",
              "content": "Finally, while it is true that someone who needs the ``zoneinfo`` module also\nneeds the ``datetime`` module, the reverse is not necessarily true: many people\nwill want to use ``datetime`` without ``zoneinfo``.  Considering that\n``zoneinfo`` will likely pull in additional, possibly more heavy-weight\nstandard library modules, it would be preferable to allow the two to be\nimported separately — particularly if potential \"tree shaking\" distributions\nare in Python's future. [#tree-shaking]_\n\nIn the final analysis, it makes sense to keep ``zoneinfo`` a separate module\nwith a separate documentation page rather than to put its classes and functions\ndirectly into ``datetime``.\n\nUsing ``datetime.zoneinfo`` instead of ``zoneinfo``\n###################################################\n\nA more palatable configuration may be to nest ``zoneinfo`` as a module under\n``datetime``, as ``datetime.zoneinfo``.\n\nArguments in favor of this:\n\n1. It neatly namespaces ``zoneinfo`` together with ``datetime``\n\n2. The ``timezone`` class is already in ``datetime``, and it may seem strange\n   that some time zones are in ``datetime`` and others are in a top-level\n   module.\n\n3. As mentioned earlier, importing ``zoneinfo`` necessarily requires importing\n   ``datetime``, so it is no imposition to require importing the parent module.\n\nArguments against this:\n\n1. In order to avoid forcing all ``datetime`` users to import ``zoneinfo``, the\n   ``zoneinfo`` module would need to be lazily imported, which means that\n   end-users would need to explicitly import ``datetime.zoneinfo`` (as opposed\n   to importing ``datetime`` and accessing the ``zoneinfo`` attribute on the\n   module). ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1267,
                      1478
                    ],
                    "doc_id": "06e276d91e64059adfa6227889151bd7067d62a7c60a4f1a647177984bd1422f"
                  },
                  {
                    "range": [
                      0,
                      319
                    ],
                    "doc_id": "e273d147d9be91c7cbfd1155edaf48cc5d3fc41f0254f5cecfdd9c5ceff8136e"
                  }
                ],
                "split_idx_start": 34730,
                "file_name": "pep-0615.txt",
                "_file_created_at": "2024-10-18T09:03:42.989180+00:00",
                "split_id": 28,
                "_file_size": 41856,
                "page_number": 1,
                "source_id": "23ee2e2bcb086a346096655861d62107d40633e92d6de79441aff79ce2469b62"
              },
              "score": 0.277099609375,
              "file": {
                "id": "cd992ee0-350b-48eb-88bb-968d59749fd3",
                "name": "pep-0615.txt"
              }
            },
            {
              "id": "b4f79b5862793f5fa1c3f9b669a1c27e1a9aa9cff9b6481fa0de2513b3c3264d",
              "content": "However, ``str.format()`` is not without its issues. Chief among them\nis its verbosity. For example, the text ``value`` is repeated here::\n\n  >>> value = 4 * 20\n  >>> 'The value is {value}.'.format(value=value)\n  'The value is 80.'Even in its simplest form there is a bit of boilerplate, and the value\nthat's inserted into the placeholder is sometimes far removed from\nwhere the placeholder is situated::\n\n  >>> 'The value is {}.'.format(value)\n  'The value is 80.'With an f-string, this becomes::\n\n  >>> f'The value is {value}.''The value is 80.'F-strings provide a concise, readable way to include the value of\nPython expressions inside strings.\n\nIn this sense, ``string.Template`` and %-formatting have similar\nshortcomings to ``str.format()``, but also support fewer formatting\noptions. In particular, they do not support the ``__format__``\nprotocol, so that there is no way to control how a specific object is\nconverted to a string, nor can it be extended to additional types that\nwant to control how they are converted to strings (such as ``Decimal``\nand ``datetime``). This example is not possible with\n``string.Template``::\n\n  >>> value = 1234\n  >>> f'input={value:#06x}'\n  'input=0x04d2'\n\nAnd neither %-formatting nor ``string.Template`` can control\nformatting such as::\n\n  >>> date = datetime.date(1991, 10, 12)\n  >>> f'{date} was on a {date:%A}'\n  '1991-10-12 was on a Saturday'\n\nNo use of globals() or locals()\n-------------------------------\n\nIn the discussions on python-dev [#]_, a number of solutions where\npresented that used locals() and globals() or their equivalents. All\nof these have various problems. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1194,
                      1425
                    ],
                    "doc_id": "d873a90f56222b0c02ef2987a6ef2390aa5f7400bb6f8fe5c1cfafebaba3a9d4"
                  },
                  {
                    "range": [
                      0,
                      548
                    ],
                    "doc_id": "76db0307a81ca4d9012184b0066414935f4342f14219f177170a61737d6bfd2c"
                  }
                ],
                "split_idx_start": 3396,
                "file_name": "pep-0498.txt",
                "_file_created_at": "2024-10-18T09:03:54.839485+00:00",
                "split_id": 3,
                "_file_size": 25320,
                "page_number": 1,
                "source_id": "51927b0152d7c0504de7a4e0a4f5265617143fce6a5f763d17118f6afdc92298"
              },
              "score": 0.270263671875,
              "file": {
                "id": "c549dad4-9306-417e-9e31-72eff4db300c",
                "name": "pep-0498.txt"
              }
            },
            {
              "id": "0208013b140d15f0db841a05a091c846e553ede10e869ad01f79c2b4e4cf455e",
              "content": "However, while this PEP brings the simple API closer to being able to replace\nthe JSON API, there is no formal policy that the simple API will replicate all\nof the functionality covered by the existing Warehouse APIs. Proposed additions\nto the simple API will still be considered on their individual merits, and the\nrequirement that the API should be simple and fast for the primary use case of\nlocating files for a project will remain the overriding consideration.\n\nWhy not allow other date formats?\n---------------------------------\n\nThe ISO 8601 standard is complex, and there seems little value in requiring\nclients to deal with that. The standard library ``datetime`` module provides\nmethods to parse ISO 8601 strings, but it is possible that users may want to\naccess index data *without* using Python (for example, piping the output of\n``curl`` into ``jq``). Having a single, well-defined format makes this easier,\nand doesn't have any significant disadvantages.\n\nWhat if file sizes are too big for a JSON number?\n-------------------------------------------------\n\nThe JSON standard does not specify how numbers are to be interpreted. Python can\nread and write arbitrary-length integers in a JSON file, so this should not be\nan issue for code written in Python. Non-Python implementations may need to take\ncare to handle large integers correctly, but this is not expected to be a\nsignificant problem.\n\nWhy not require PEP 440 versions?\n---------------------------------\n\nAt the time this PEP was written, PyPI still contains (and serves) projects and\nfiles with \"legacy\" versions. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1258,
                      1476
                    ],
                    "doc_id": "0dbd4d9f67ed1debe2d2d01388adb418fd7680300e1c5dd65304ab08a06f998c"
                  },
                  {
                    "range": [
                      0,
                      319
                    ],
                    "doc_id": "93c1e003bf05b1c4a50ceeb9e663c8faca3781e50f679ad1dae90df795ecd09a"
                  }
                ],
                "split_idx_start": 5268,
                "file_name": "pep-0700.txt",
                "_file_created_at": "2024-10-18T09:03:35.846894+00:00",
                "split_id": 4,
                "_file_size": 8166,
                "page_number": 1,
                "source_id": "aea4713fd8d547e4b1021bea40baa136345619dfef2bc8fad5189da151d27ee3"
              },
              "score": 0.2198486328125,
              "file": {
                "id": "09712c03-b4a5-4fc2-b243-50a5e25d4037",
                "name": "pep-0700.txt"
              }
            },
            {
              "id": "100b3fc66bf034afd632c5e7172924cbf5f7d1f49ddb0a8d88183f49368d8d77",
              "content": "There is currently no standard tool that addresses this\nissue, and this PEP does *not* attempt to define one. However, any tool that\n*does* address this issue will need to know what 3rd party dependencies a script\nrequires. By defining a standard format for storing such data, existing tools,\nas well as any future tools, will be able to obtain that information without\nrequiring users to include tool-specific metadata in their scripts.\n\n\nRationale\n=========\n\nBecause a key requirement is writing single-file scripts, and simple sharing by\ngiving someone a copy of the script, the PEP defines a mechanism for embedding\ndependency data *within the script itself*, and not in an external file.\n\nWe define the concept of a *dependency block* that contains information about\nwhat 3rd party packages a script depends on.\n\nIn order to identify dependency blocks, the script can simply be read as a text\nfile. This is deliberate, as Python syntax changes over time, so attempting to\nparse the script as Python code would require choosing a specific version of\nPython syntax. Also, it is likely that at least some tools will not be written\nin Python, and expecting them to implement a Python parser is too much of a\nburden.\n\nHowever, to avoid needing changes to core Python, the format is designed to\nappear as comments to the Python parser. ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1519,
                      1743
                    ],
                    "doc_id": "972b2f23b91c65d6dacbff574ab2caa9d48563463d50de4d7381592f91cd7dfb"
                  },
                  {
                    "range": [
                      0,
                      266
                    ],
                    "doc_id": "7a66c6d890ecf208a867a8fae4d5fb6ac0c261dd194415abdaf101f41e96b6b3"
                  }
                ],
                "split_idx_start": 1519,
                "file_name": "pep-0722.txt",
                "_file_created_at": "2024-10-18T09:03:34.758975+00:00",
                "split_id": 1,
                "_file_size": 34243,
                "page_number": 1,
                "source_id": "f708ec2e95e0f2fff731e8bd6c2d20868b881870a33e3e7a7afc1b8468a710f8"
              },
              "score": 0.1983642578125,
              "file": {
                "id": "847eb370-ab07-47c1-af48-2f30c51cb4c9",
                "name": "pep-0722.txt"
              }
            }
          ],
          "score": null
        }
      ],
      "session_id": "b826bb58-4f17-466e-a770-3f9ae89c5f4f",
      "time": "2024-10-18T09:47:31.670226Z",
      "duration": 16.24975562095642,
      "user": {
        "given_name": "Agnieszka",
        "family_name": "Marzec",
        "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
      },
      "pipeline": {
        "name": "rag-chat"
      }
    },
    {
      "search_history_id": "98da25ba-584e-417b-94b6-b91c3df45275",
      "request": {
        "query": "How do I handle datetime objects in python?",
        "filters": {
          "operator": "AND",
          "conditions": []
        },
        "params": {}
      },
      "response": [
        {
          "search_result_history_id": "6593cc35-bb37-4006-9551-7e1baaddb71a",
          "result": {
            "answer": "To handle datetime objects in Python, especially in the context of the documents provided, you can consider the following points:\n\n1. **Delegating datetime methods to tzinfo implementations**: Document discusses a proposed protocol (PDDM) for delegating datetime methods to their tzinfo implementations. This protocol was intended to allow datetime objects with tzinfo to override aware datetime arithmetics, formatting, and parsing. Although this PEP was rejected, it highlights the complexity and considerations involved in handling datetime objects, particularly in time zone-aware calculations.\n\n2. **Local Time Disambiguation**: Document introduces the `fold` attribute in the `datetime.time` and `datetime.datetime` classes to handle ambiguous local times, such as those occurring during the end of daylight saving time. The `fold` attribute can take values of 0 or 1, where 0 corresponds to the earlier and 1 to the later of the two possible readings of an ambiguous local time. This addition helps in differentiating between two moments in time where local times are the same due to clock adjustments.\n\n3. **Formatting and Parsing Options**: Document suggests providing predefined format strings or new methods on datetime objects to support complex formatting needs, such as RFC 2822. This approach would simplify the process of formatting datetime objects according to specific standards.\n\nThese documents collectively provide insights into handling datetime objects in Python, focusing on time zone management, disambiguation of local times, and formatting for compliance with specific standards .",
            "type": "generative",
            "score": null,
            "context": null,
            "offsets_in_document": [],
            "offsets_in_context": [],
            "document_id": null,
            "document_ids": [
              "b24b527b003a8b99417cc419163e7fc110f928700808a4b4514f206b7751da6a",
              "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "42eded5001258515a0e242c78b6f86445dc98e8bdd6704c28cd8d759ace83ab5",
              "bea17094c4dd9e80d90e55a9d07c036d7ea90b3062746cdcd94f35fdf62cae57",
              "c2fe9e54ae2ec2c66d129084630375b7c89d8d5b00a19a4a52c4966fbda70640",
              "7839a99779428c57fd79763e525bcd809bdcf6d5b8cbe3b2f126aeeaa4fd0bb3",
              "c03ae09b5c8cfa92d97dea762fe7892e5066cd974767a847be2a888d8f8f2a6e",
              "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b"
            ],
            "meta": {
              "_references": [
                {
                  "answer_end_idx": 201,
                  "answer_start_idx": 201,
                  "document_id": "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
                  "document_position": 2,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1864,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 642,
                  "answer_start_idx": 642,
                  "document_id": "c03ae09b5c8cfa92d97dea762fe7892e5066cd974767a847be2a888d8f8f2a6e",
                  "document_position": 7,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1669,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 1158,
                  "answer_start_idx": 1158,
                  "document_id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
                  "document_position": 8,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1330,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 1607,
                  "answer_start_idx": 1607,
                  "document_id": "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
                  "document_position": 2,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1864,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 1607,
                  "answer_start_idx": 1607,
                  "document_id": "c03ae09b5c8cfa92d97dea762fe7892e5066cd974767a847be2a888d8f8f2a6e",
                  "document_position": 7,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1669,
                  "doc_start_idx": 0,
                  "origin": "llm"
                },
                {
                  "answer_end_idx": 1607,
                  "answer_start_idx": 1607,
                  "document_id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
                  "document_position": 8,
                  "label": "grounded",
                  "score": 0,
                  "doc_end_idx": 1330,
                  "doc_start_idx": 0,
                  "origin": "llm"
                }
              ]
            },
            "file": {
              "id": "4c6c9315-9b82-46fe-8e63-cc0b81aa8cb0",
              "name": "pep-3151.txt"
            },
            "files": [
              {
                "id": "4c6c9315-9b82-46fe-8e63-cc0b81aa8cb0",
                "name": "pep-3151.txt"
              },
              {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              },
              {
                "id": "09b2172b-94f0-46c3-95dd-5c7f444b8444",
                "name": "pep-3140.txt"
              },
              {
                "id": "23ad27f6-20ac-49cc-952a-ccd173481a7a",
                "name": "pep-0001.txt"
              },
              {
                "id": "efc377d8-35ea-491a-b8e2-0c9b8bf36a6f",
                "name": "pep-0249.txt"
              },
              {
                "id": "ccad3e0d-cb89-4d2b-b4c2-6f3ca14e4c68",
                "name": "pep-0417.txt"
              },
              {
                "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
                "name": "pep-0495.txt"
              },
              {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            ],
            "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nPEP: 3151\nTitle: Reworking the OS and IO exception hierarchy\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Antoine Pitrou <[email protected]>\nBDFL-Delegate: Barry Warsaw\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 21-Jul-2010\nPython-Version: 3.3\nPost-History:\nResolution: https://mail.python.org/pipermail/python-dev/2011-October/114033.html\n\nAbstract\n========\n\nThe standard exception hierarchy is an important part of the Python\nlanguage.  It has two defining qualities: it is both generic and\nselective.  Generic in that the same exception type can be raised\n- and handled - regardless of the context (for example, whether you are\ntrying to add something to an integer, to call a string method, or to write\nan object on a socket, a TypeError will be raised for bad argument types).\nSelective in that it allows the user to easily handle (silence, examine,\nprocess, store or encapsulate...) specific kinds of error conditions\nwhile letting other errors bubble up to higher calling contexts.  For\nexample, you can choose to catch ZeroDivisionErrors without affecting\nthe default handling of other ArithmeticErrors (such as OverflowErrors).\n\nThis PEP proposes changes to a part of the exception hierarchy in\norder to better embody the qualities mentioned above: the errors\nrelated to operating system calls (OSError, IOError, mmap.error,\nselect.error, and all their subclasses).\n\n\n\n\nDocument[2]:\nPEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n\n\nDocument[3]:\n:pep:`3138` proposes to fix this by breaking the \"repr is safe ASCII\"\ninvariant, and changing the way ``repr`` (which is used for\npersistence) outputs some objects, with system-dependent failures.\n\nChanging how ``str(container)`` works would allow easy debugging in\nthe normal case, and retain the safety of ASCII-only for the\nmachine-readable  case.  The only downside is that ``str(x)`` and\n``repr(x)`` would more often be different -- but only in those cases\nwhere the current almost-the-same version is insufficient.\n\nIt also seems illogical that ``str(container)`` calls ``repr`` on items\ninstead of ``str``.  It's only logical to expect following code::\n\n    class Test:\n        def __str__(self):\n            return \"STR\"\n\n        def __repr__(self):\n            return \"REPR\"\n\n\n    test = Test()\n    print(test)\n    print(repr(test))\n    print([test])\n    print(str([test]))\n\nto print::\n\n    STR\n    REPR\n    [STR]\n    [STR]\n\nwhere it actually prints::\n\n    STR\n    REPR\n    [REPR]\n    [REPR]\n\nEspecially it is illogical to see that print in Python 2 uses ``str``\nif it is called on what seems to be a tuple::\n\n    >>> print Decimal('42'), datetime.now()\n    42 2008-05-27 20:16:22.534285\n\nwhere on an actual tuple it prints::\n\n    >>> print((Decimal('42'), datetime.now()))\n    (Decimal(\"42\"), datetime.datetime(2008, 5, 27, 20, 16, 27, 937911))\n\n\nA different approach - call ``str(item)``\n=========================================\n\nFor example, with numbers it is often only the value that people\ncare about.\n\n\n\nDocument[4]:\nOnce the review process is complete, and the PEP editors approve it (note that\nthis is *not* the same as accepting your PEP!), they will squash commit your\npull request onto main.\n\nThe PEP editors will not unreasonably deny publication of a PEP.  Reasons for\ndenying PEP status include duplication of effort, being technically unsound,\nnot providing proper motivation or addressing backwards compatibility, or not\nin keeping with the Python philosophy.  The Steering Council can be consulted\nduring the approval phase, and are the final arbiter of a draft's PEP-ability.\n\nDevelopers with write access to the `PEP repository`_ may claim PEP\nnumbers directly by creating and committing a new PEP. When doing so, the\ndeveloper must handle the tasks that would normally be taken care of by the\nPEP editors (see `PEP Editor Responsibilities & Workflow`_). This includes\nensuring the initial version meets the expected standards for submitting a\nPEP.  Alternately, even developers should submit PEPs via pull request.\nWhen doing so, you are generally expected to handle the process yourself;\nif you need assistance from PEP editors, mention ``@python/pep-editors``\non GitHub.\n\nAs updates are necessary, the PEP author can check in new versions if they\n(or a collaborating developer) have write access to the `PEP repository`_.\nGetting a PEP number assigned early can be useful for ease of\nreference, especially when multiple draft PEPs are being considered at the\nsame time.\n\nStandards Track PEPs consist of two parts, a design document and a\nreference implementation.  \n\nDocument[5]:\nWhen the database module sees\na Python string object, it doesn't know if it should be bound as a\nsimple ``CHAR`` column, as a raw ``BINARY`` item, or as a ``DATE``.\n\nTo overcome this problem, a module must provide the constructors\ndefined below to create objects that can hold special values.  When\npassed to the cursor methods, the module can then detect the proper\ntype of the input parameter and bind it accordingly.\n\nA Cursor_ Object's description attribute returns information about\neach of the result columns of a query.  The ``type_code`` must compare\nequal to one of Type Objects defined below. Type Objects may be equal\nto more than one type code (e.g. ``DATETIME`` could be equal to the\ntype codes for date, time and timestamp columns; see the\n`Implementation Hints`_ below for details).\n\nThe module exports the following constructors and singletons:\n\n.. _Date:\n\n`Date`_\\ (*year*, *month*, *day*)\n    This function constructs an object holding a date value.\n\n\n.. _Time:\n\n`Time`_\\ (*hour*, *minute*, *second*)\n    This function constructs an object holding a time value.\n\n\n.. _Timestamp:\n\n`Timestamp`_\\ (*year*, *month*, *day*, *hour*, *minute*, *second*)\n    This function constructs an object holding a time stamp value.\n\n\n.. _DateFromTicks:\n\n`DateFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a date value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of `the standard Python time module\n    <http://docs.python.org/library/time.html>`__ for details).\n\n\n\nDocument[6]:\nPEP: 417\nTitle: Including mock in the Standard Library\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Michael Foord <[email protected]>\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 12-Mar-2012\nPython-Version: 3.3\nPost-History: 12-Mar-2012\nResolution: https://mail.python.org/pipermail/python-dev/2012-March/117507.html\n\n\nAbstract\n========\n\nThis PEP proposes adding the mock [1]_ testing library\nto the Python standard library as ``unittest.mock``.\n\n\nRationale\n=========\n\nCreating mock objects for testing is a common need in Python.\nMany developers create ad-hoc mocks, as needed, in their test\nsuites. This is currently what we do in the Python test suite,\nwhere a standardised mock object library would be helpful.\n\nThere are many mock object libraries available for Python [2]_.\nOf these, mock is overwhelmingly the most popular, with as many\ndownloads on PyPI as the other mocking libraries combined.\n\nAn advantage of mock is that it is a mocking library and not a\nframework. It provides a configurable and flexible mock object,\nwithout being opinionated about how you write your tests. The\nmock api is now well battle-tested and stable.\n\nmock also handles safely monkeypatching and unmonkeypatching\nobjects during the scope of a test. This is hard to do safely\nand many developers / projects mimic this functionality\n(often incorrectly). A standardised way to do this, handling\nthe complexity of patching in the presence of the descriptor\nprotocol (etc) is useful. People are asking for a \"patch\" [3]_\nfeature to unittest. Doing this via mock.patch is preferable\nto re-implementing part of this functionality in unittest.\n\n\n\n\nDocument[7]:\nPEP: 495\nTitle: Local Time Disambiguation\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 02-Aug-2015\nPython-Version: 3.6\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-September/000900.html\n\n\nAbstract\n========\n\nThis PEP adds a new attribute ``fold`` to instances of the\n``datetime.time`` and ``datetime.datetime`` classes that can be used\nto differentiate between two moments in time for which local times are\nthe same.  The allowed values for the ``fold`` attribute will be 0 and 1\nwith 0 corresponding to the earlier and 1 to the later of the two\npossible readings of an ambiguous local time.\n\n\nRationale\n=========\n\nIn most world locations, there have been and will be times when\nlocal clocks are moved back. [#]_ In those times, intervals are\nintroduced in which local clocks show the same time twice in the same\nday.  In these situations, the information displayed on a local clock\n(or stored in a Python datetime instance) is insufficient to identify\na particular moment in time.  The proposed solution is to add an\nattribute to the ``datetime`` instances taking values of 0 and 1 that\nwill enumerate the two ambiguous times.\n\n.. image:: pep-0495-daylightsavings.png\n   :align: center\n   :alt: A cartoon of a strong man struggling to stop the hands of a large clock.\n         The caption reads: You can't stop time... but you can turn it back one\n         hour at 2 a.m. Oct. 28 when daylight-saving time ends and standard time\n         begins.\"\n\nDocument[8]:\nOnly complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:\n\nQuestion: How do I handle datetime objects in Python, especially in the context of the documents you mentioned?\nAnswer:"
          },
          "type": 1,
          "rank": 1,
          "documents": [
            {
              "id": "b24b527b003a8b99417cc419163e7fc110f928700808a4b4514f206b7751da6a",
              "content": "PEP: 3151\nTitle: Reworking the OS and IO exception hierarchy\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Antoine Pitrou <[email protected]>\nBDFL-Delegate: Barry Warsaw\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 21-Jul-2010\nPython-Version: 3.3\nPost-History:\nResolution: https://mail.python.org/pipermail/python-dev/2011-October/114033.html\n\nAbstract\n========\n\nThe standard exception hierarchy is an important part of the Python\nlanguage.  It has two defining qualities: it is both generic and\nselective.  Generic in that the same exception type can be raised\n- and handled - regardless of the context (for example, whether you are\ntrying to add something to an integer, to call a string method, or to write\nan object on a socket, a TypeError will be raised for bad argument types).\nSelective in that it allows the user to easily handle (silence, examine,\nprocess, store or encapsulate...) specific kinds of error conditions\nwhile letting other errors bubble up to higher calling contexts.  For\nexample, you can choose to catch ZeroDivisionErrors without affecting\nthe default handling of other ArithmeticErrors (such as OverflowErrors).\n\nThis PEP proposes changes to a part of the exception hierarchy in\norder to better embody the qualities mentioned above: the errors\nrelated to operating system calls (OSError, IOError, mmap.error,\nselect.error, and all their subclasses).\n\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      239
                    ],
                    "doc_id": "05d9f55c7bba21cb7c5c972bad5726448cafe8b6e3581ebc5e98ce9c3e4fa99e"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-3151.txt",
                "_file_created_at": "2024-10-18T09:03:27.078374+00:00",
                "split_id": 0,
                "_file_size": 34451,
                "page_number": 1,
                "source_id": "c38e6859f0b4ce9910f2404ea5c5c79510b77ba98f48602e0ef2fb7f33552f75"
              },
              "score": 0.123779296875,
              "file": {
                "id": "4c6c9315-9b82-46fe-8e63-cc0b81aa8cb0",
                "name": "pep-3151.txt"
              }
            },
            {
              "id": "66722fd08f8adab75357847e2d8ab324d6175816435c99063e2c2d8a96171d74",
              "content": "PEP: 500\nTitle: A protocol for delegating datetime methods to their tzinfo implementations\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Rejected\nType: Standards Track\nContent-Type: text/x-rst\nRequires: 495\nCreated: 08-Aug-2015\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-August/000354.html\n\nAbstract\n========\n\nThis PEP specifies a new protocol (PDDM - \"A Protocol for Delegating\nDatetime Methods\") that can be used by concrete implementations of the\n``datetime.tzinfo`` interface to override aware datetime arithmetics,\nformatting and parsing.  We describe changes to the\n``datetime.datetime`` class to support the new protocol and propose a\nnew abstract class ``datetime.tzstrict`` that implements parts of this\nprotocol necessary to make aware datetime instances to follow \"strict\"\narithmetic rules.\n\n\nRationale\n=========\n\nAs of Python 3.5, aware datetime instances that share a ``tzinfo``\nobject follow the rules of arithmetics that are induced by a simple\nbijection between (year, month, day, hour, minute, second,\nmicrosecond) 7-tuples and large integers.  In this arithmetics, the\ndifference between YEAR-11-02T12:00 and YEAR-11-01T12:00 is always 24\nhours, even though in the US/Eastern timezone, for example, there are\n25 hours between 2014-11-01T12:00 and 2014-11-02T12:00 because the\nlocal clocks were rolled back one hour at 2014-11-02T02:00,\nintroducing an extra hour in the night between 2014-11-01 and\n2014-11-02.\n\nMany business applications require the use of Python's simplified view\nof local dates.  No self-respecting car rental company will charge its\ncustomers more for a week that straddles the end of DST than for any\nother week or require that they return the car an hour early.\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      185
                    ],
                    "doc_id": "2491a8b58f7bb1979fdf5061006dfc72c54b6e9e287f06f9b8a5dd669967c874"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0500.txt",
                "_file_created_at": "2024-10-18T09:03:51.944443+00:00",
                "split_id": 0,
                "_file_size": 7045,
                "page_number": 1,
                "source_id": "5180621105b359308fb5b39c5455b227c26cb8533a69672335202ed14e8d568d"
              },
              "score": 0.1055908203125,
              "file": {
                "id": "cf52312b-26b9-4ded-ac2b-cb6faf344a86",
                "name": "pep-0500.txt"
              }
            },
            {
              "id": "42eded5001258515a0e242c78b6f86445dc98e8bdd6704c28cd8d759ace83ab5",
              "content": ":pep:`3138` proposes to fix this by breaking the \"repr is safe ASCII\"\ninvariant, and changing the way ``repr`` (which is used for\npersistence) outputs some objects, with system-dependent failures.\n\nChanging how ``str(container)`` works would allow easy debugging in\nthe normal case, and retain the safety of ASCII-only for the\nmachine-readable  case.  The only downside is that ``str(x)`` and\n``repr(x)`` would more often be different -- but only in those cases\nwhere the current almost-the-same version is insufficient.\n\nIt also seems illogical that ``str(container)`` calls ``repr`` on items\ninstead of ``str``.  It's only logical to expect following code::\n\n    class Test:\n        def __str__(self):\n            return \"STR\"\n\n        def __repr__(self):\n            return \"REPR\"\n\n\n    test = Test()\n    print(test)\n    print(repr(test))\n    print([test])\n    print(str([test]))\n\nto print::\n\n    STR\n    REPR\n    [STR]\n    [STR]\n\nwhere it actually prints::\n\n    STR\n    REPR\n    [REPR]\n    [REPR]\n\nEspecially it is illogical to see that print in Python 2 uses ``str``\nif it is called on what seems to be a tuple::\n\n    >>> print Decimal('42'), datetime.now()\n    42 2008-05-27 20:16:22.534285\n\nwhere on an actual tuple it prints::\n\n    >>> print((Decimal('42'), datetime.now()))\n    (Decimal(\"42\"), datetime.datetime(2008, 5, 27, 20, 16, 27, 937911))\n\n\nA different approach - call ``str(item)``\n=========================================\n\nFor example, with numbers it is often only the value that people\ncare about.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1465,
                      1817
                    ],
                    "doc_id": "206db8bf767c74b017f25da906f9fa3a11d690b86fd0449816fd61fba941999b"
                  },
                  {
                    "range": [
                      0,
                      905
                    ],
                    "doc_id": "64d77c2557676fd71054d6b8505ad003422f3c171ec42b7c891051b8ea1cd378"
                  }
                ],
                "split_idx_start": 2913,
                "file_name": "pep-3140.txt",
                "_file_created_at": "2024-10-18T09:03:27.060477+00:00",
                "split_id": 2,
                "_file_size": 6643,
                "page_number": 1,
                "source_id": "1885edad78357f10823cfe7dbaadeb2dc8edacc4604cb7589cf6a12fa4929b11"
              },
              "score": 0.07305908203125,
              "file": {
                "id": "09b2172b-94f0-46c3-95dd-5c7f444b8444",
                "name": "pep-3140.txt"
              }
            },
            {
              "id": "bea17094c4dd9e80d90e55a9d07c036d7ea90b3062746cdcd94f35fdf62cae57",
              "content": "Once the review process is complete, and the PEP editors approve it (note that\nthis is *not* the same as accepting your PEP!), they will squash commit your\npull request onto main.\n\nThe PEP editors will not unreasonably deny publication of a PEP.  Reasons for\ndenying PEP status include duplication of effort, being technically unsound,\nnot providing proper motivation or addressing backwards compatibility, or not\nin keeping with the Python philosophy.  The Steering Council can be consulted\nduring the approval phase, and are the final arbiter of a draft's PEP-ability.\n\nDevelopers with write access to the `PEP repository`_ may claim PEP\nnumbers directly by creating and committing a new PEP. When doing so, the\ndeveloper must handle the tasks that would normally be taken care of by the\nPEP editors (see `PEP Editor Responsibilities & Workflow`_). This includes\nensuring the initial version meets the expected standards for submitting a\nPEP.  Alternately, even developers should submit PEPs via pull request.\nWhen doing so, you are generally expected to handle the process yourself;\nif you need assistance from PEP editors, mention ``@python/pep-editors``\non GitHub.\n\nAs updates are necessary, the PEP author can check in new versions if they\n(or a collaborating developer) have write access to the `PEP repository`_.\nGetting a PEP number assigned early can be useful for ease of\nreference, especially when multiple draft PEPs are being considered at the\nsame time.\n\nStandards Track PEPs consist of two parts, a design document and a\nreference implementation.  ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1339,
                      1520
                    ],
                    "doc_id": "e42b7ce9c39d4ce5f2b7aaffb6a648b9192ef414529d34ca2b85624ecde71d81"
                  },
                  {
                    "range": [
                      0,
                      243
                    ],
                    "doc_id": "cdddf0aadb84b61db6192853cd1ba5cc76780fd34e9eb2b02d38150bb736e0a7"
                  }
                ],
                "split_idx_start": 10213,
                "file_name": "pep-0001.txt",
                "_file_created_at": "2024-10-18T09:04:17.058139+00:00",
                "split_id": 8,
                "_file_size": 40494,
                "page_number": 1,
                "source_id": "8544bfee60e1f047f10d22aece865c99744e861aa933af0e48e4bae1891ccff2"
              },
              "score": 0.07183837890625,
              "file": {
                "id": "23ad27f6-20ac-49cc-952a-ccd173481a7a",
                "name": "pep-0001.txt"
              }
            },
            {
              "id": "c2fe9e54ae2ec2c66d129084630375b7c89d8d5b00a19a4a52c4966fbda70640",
              "content": "When the database module sees\na Python string object, it doesn't know if it should be bound as a\nsimple ``CHAR`` column, as a raw ``BINARY`` item, or as a ``DATE``.\n\nTo overcome this problem, a module must provide the constructors\ndefined below to create objects that can hold special values.  When\npassed to the cursor methods, the module can then detect the proper\ntype of the input parameter and bind it accordingly.\n\nA Cursor_ Object's description attribute returns information about\neach of the result columns of a query.  The ``type_code`` must compare\nequal to one of Type Objects defined below. Type Objects may be equal\nto more than one type code (e.g. ``DATETIME`` could be equal to the\ntype codes for date, time and timestamp columns; see the\n`Implementation Hints`_ below for details).\n\nThe module exports the following constructors and singletons:\n\n.. _Date:\n\n`Date`_\\ (*year*, *month*, *day*)\n    This function constructs an object holding a date value.\n\n\n.. _Time:\n\n`Time`_\\ (*hour*, *minute*, *second*)\n    This function constructs an object holding a time value.\n\n\n.. _Timestamp:\n\n`Timestamp`_\\ (*year*, *month*, *day*, *hour*, *minute*, *second*)\n    This function constructs an object holding a time stamp value.\n\n\n.. _DateFromTicks:\n\n`DateFromTicks`_\\ (*ticks*)\n    This function constructs an object holding a date value from the\n    given ticks value (number of seconds since the epoch; see the\n    documentation of `the standard Python time module\n    <http://docs.python.org/library/time.html>`__ for details).\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1386,
                      1552
                    ],
                    "doc_id": "467d2872382327256d3b1321156980966fb1c294bcc08596d8fb3c04d97c1052"
                  },
                  {
                    "range": [
                      0,
                      302
                    ],
                    "doc_id": "644f3cfbb8321ab100fc130d5f0ee054c64a7c11f2d2955995b96b311aa8a3ea"
                  }
                ],
                "split_idx_start": 18317,
                "file_name": "pep-0249.txt",
                "_file_created_at": "2024-10-18T09:04:14.063065+00:00",
                "split_id": 13,
                "_file_size": 46420,
                "page_number": 1,
                "source_id": "844df4c20398c29318a2ab1a588f79da140a39b37bc7138536f9bf64fb19b378"
              },
              "score": 0.06610107421875,
              "file": {
                "id": "efc377d8-35ea-491a-b8e2-0c9b8bf36a6f",
                "name": "pep-0249.txt"
              }
            },
            {
              "id": "7839a99779428c57fd79763e525bcd809bdcf6d5b8cbe3b2f126aeeaa4fd0bb3",
              "content": "PEP: 417\nTitle: Including mock in the Standard Library\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Michael Foord <[email protected]>\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 12-Mar-2012\nPython-Version: 3.3\nPost-History: 12-Mar-2012\nResolution: https://mail.python.org/pipermail/python-dev/2012-March/117507.html\n\n\nAbstract\n========\n\nThis PEP proposes adding the mock [1]_ testing library\nto the Python standard library as ``unittest.mock``.\n\n\nRationale\n=========\n\nCreating mock objects for testing is a common need in Python.\nMany developers create ad-hoc mocks, as needed, in their test\nsuites. This is currently what we do in the Python test suite,\nwhere a standardised mock object library would be helpful.\n\nThere are many mock object libraries available for Python [2]_.\nOf these, mock is overwhelmingly the most popular, with as many\ndownloads on PyPI as the other mocking libraries combined.\n\nAn advantage of mock is that it is a mocking library and not a\nframework. It provides a configurable and flexible mock object,\nwithout being opinionated about how you write your tests. The\nmock api is now well battle-tested and stable.\n\nmock also handles safely monkeypatching and unmonkeypatching\nobjects during the scope of a test. This is hard to do safely\nand many developers / projects mimic this functionality\n(often incorrectly). A standardised way to do this, handling\nthe complexity of patching in the presence of the descriptor\nprotocol (etc) is useful. People are asking for a \"patch\" [3]_\nfeature to unittest. Doing this via mock.patch is preferable\nto re-implementing part of this functionality in unittest.\n\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      286
                    ],
                    "doc_id": "4ba11d485552ba8acf44ff2101aa6ebc86ef97ccc22702b6f26eaa806219e2a6"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0417.txt",
                "_file_created_at": "2024-10-18T09:03:58.818979+00:00",
                "split_id": 0,
                "_file_size": 2669,
                "page_number": 1,
                "source_id": "38269e4f5bfe5e952201c1bfc3378e35917c472e2f3a64719b34673ef4a964d7"
              },
              "score": 0.0631103515625,
              "file": {
                "id": "ccad3e0d-cb89-4d2b-b4c2-6f3ca14e4c68",
                "name": "pep-0417.txt"
              }
            },
            {
              "id": "c03ae09b5c8cfa92d97dea762fe7892e5066cd974767a847be2a888d8f8f2a6e",
              "content": "PEP: 495\nTitle: Local Time Disambiguation\nVersion: $Revision$\nLast-Modified: $Date$\nAuthor: Alexander Belopolsky <[email protected]>, Tim Peters <[email protected]>\nDiscussions-To: [email protected]\nStatus: Final\nType: Standards Track\nContent-Type: text/x-rst\nCreated: 02-Aug-2015\nPython-Version: 3.6\nResolution: https://mail.python.org/pipermail/datetime-sig/2015-September/000900.html\n\n\nAbstract\n========\n\nThis PEP adds a new attribute ``fold`` to instances of the\n``datetime.time`` and ``datetime.datetime`` classes that can be used\nto differentiate between two moments in time for which local times are\nthe same.  The allowed values for the ``fold`` attribute will be 0 and 1\nwith 0 corresponding to the earlier and 1 to the later of the two\npossible readings of an ambiguous local time.\n\n\nRationale\n=========\n\nIn most world locations, there have been and will be times when\nlocal clocks are moved back. [#]_ In those times, intervals are\nintroduced in which local clocks show the same time twice in the same\nday.  In these situations, the information displayed on a local clock\n(or stored in a Python datetime instance) is insufficient to identify\na particular moment in time.  The proposed solution is to add an\nattribute to the ``datetime`` instances taking values of 0 and 1 that\nwill enumerate the two ambiguous times.\n\n.. image:: pep-0495-daylightsavings.png\n   :align: center\n   :alt: A cartoon of a strong man struggling to stop the hands of a large clock.\n         The caption reads: You can't stop time... but you can turn it back one\n         hour at 2 a.m. Oct. 28 when daylight-saving time ends and standard time\n         begins.\"",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      0,
                      318
                    ],
                    "doc_id": "5df9f4920337c54bcc463cfb90aa219725415f560f6032508c0c71090bafef23"
                  }
                ],
                "split_idx_start": 0,
                "file_name": "pep-0495.txt",
                "_file_created_at": "2024-10-18T09:03:54.819307+00:00",
                "split_id": 0,
                "_file_size": 34899,
                "page_number": 1,
                "source_id": "04ae5810b522e53d51d5bb1f7e708f045a1e09977cde5b7e18a54646ffa0575f"
              },
              "score": 0.060638427734375,
              "file": {
                "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
                "name": "pep-0495.txt"
              }
            },
            {
              "id": "a83b9c8fdf043d00e92fe0247e5913ea5de8234b6c5a793efbafd410f01e418b",
              "content": "Only complicated formats need to be supported; :rfc:`2822`\nis currently the only one I can think of.\n\nOptions:\n\n1) Provide predefined format strings, so you could write this::\n\n        import datetime\n        d = datetime.datetime(...)\n        print d.strftime(d.RFC2822_FORMAT) # or datetime.RFC2822_FORMAT?\n\n2) Provide new methods on all the objects::\n\n        d = datetime.datetime(...)\n        print d.rfc822_time()\n\n\nRelevant functionality in other languages includes the `PHP date`_\nfunction (Python implementation by Simon Willison at\nhttp://simon.incutio.com/archive/2003/10/07/dateInPython)\n\n\nReferences\n==========\n\n.. _ISO8601: http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n\n.. _ParseDate.pm: http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm\n\n.. _ctime: http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\n\n.. _PHP date: http://www.php.net/date\n\nOther useful links:\n\nhttp://www.egenix.com/files/python/mxDateTime.html\nhttp://ringmaster.arc.nasa.gov/tools/time_formats.html\nhttp://www.thinkage.ca/english/gcos/expl/b/lib/0tosec.html\nhttps://moin.conectiva.com.br/DateUtil\n\n\nCopyright\n=========\n\nThis document has been placed in the public domain.\n\n\n\f\n..\n   Local Variables:\n   mode: indented-text\n   indent-tabs-mode: nil\n   sentence-end-double-space: t\n   fill-column: 70\n   End:",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1582,
                      1892
                    ],
                    "doc_id": "850d4b3a9055c249407bc6c2577ffd340ffb1e297f532513274d584b899f42c0"
                  }
                ],
                "split_idx_start": 3041,
                "file_name": "pep-0321.txt",
                "_file_created_at": "2024-10-18T09:04:08.908838+00:00",
                "split_id": 2,
                "_file_size": 4372,
                "page_number": 1,
                "source_id": "0f5123e030c45b644e8c5db6c65c4beadbf11c82bf30e48a99f7b9ed02c696e9"
              },
              "score": 0.04486083984375,
              "file": {
                "id": "3ee143f6-47b8-4ceb-bd69-0b0eede32aac",
                "name": "pep-0321.txt"
              }
            }
          ],
          "score": null
        }
      ],
      "session_id": "b826bb58-4f17-466e-a770-3f9ae89c5f4f",
      "time": "2024-10-18T09:44:52.562874Z",
      "duration": 14.420327425003052,
      "user": {
        "given_name": "Agnieszka",
        "family_name": "Marzec",
        "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
      },
      "pipeline": {
        "name": "rag-chat"
      }
    },
    {
      "search_history_id": "4f0fbb7a-161f-4e1c-91eb-ec2032fe2681",
      "request": {
        "query": "what questions can I ask?",
        "filters": {
          "operator": "AND",
          "conditions": []
        },
        "params": {}
      },
      "response": [
        {
          "search_result_history_id": "93697124-27b1-4331-8a8c-c1d6382df888",
          "result": {
            "answer": "You can ask questions related to the content and information provided in the documents I have access to. These documents cover topics such as decision-making processes within teams, details about projects hosted on PyPI, handling of datetime instances in Python, CVP decision-making criteria, database transaction processes, Python string methods, and Python's existence checking protocol. Feel free to ask specific questions about these topics or any other information that might be contained within these documents.",
            "type": "generative",
            "score": null,
            "context": null,
            "offsets_in_document": [],
            "offsets_in_context": [],
            "document_id": null,
            "document_ids": [
              "bb64450577396d87c46dff5d5c5f7c2bd7ec13b8fd63f57ec0962c9b1cad7aee",
              "1220ac6239bf67cd9bdf13f93000ede6faac31fb997dcf0ec2b1b2af9cf487d1",
              "bdf4d62f2f52e9a3d1e87e6e41b9679ada4a930c321d33d3e77544c137cb88fb",
              "cf8c7d2a1dcd45fa027ffa224c75144827ba3916e5ef1df23b7149e5e4de6485",
              "cd52a90392d01c2980b1d019aeec65f3c8c5b79021d27d1592efaaf298b5dce5",
              "d8487b5a413b2f4b639680d901631057f10f0d66b3614aafaa2e682a492b98bd",
              "e5205082f27c41144770390df9af0a63d4e0b14aeffed54a0be58fff7e7cab96",
              "df278bc9036506850e48f21aa0f2576edfb3c9e2fbd414d522dd49d1c153d13a"
            ],
            "meta": {
              "_references": []
            },
            "file": {
              "id": "6baf5e50-8a6c-4394-80ba-7a06f5863d74",
              "name": "pep-8002.txt"
            },
            "files": [
              {
                "id": "6baf5e50-8a6c-4394-80ba-7a06f5863d74",
                "name": "pep-8002.txt"
              },
              {
                "id": "03b7d7db-816e-45a1-9480-80669fb8af22",
                "name": "pep-0470.txt"
              },
              {
                "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
                "name": "pep-0495.txt"
              },
              {
                "id": "efc377d8-35ea-491a-b8e2-0c9b8bf36a6f",
                "name": "pep-0249.txt"
              },
              {
                "id": "3b5a486a-e520-466c-a914-6d0c20a63037",
                "name": "pep-0358.txt"
              },
              {
                "id": "f8210692-e95d-4629-bd4d-a9a2d92ffc55",
                "name": "pep-0531.txt"
              },
              {
                "id": "7d0f4816-4c6d-487b-b2df-86ff3fb4ced9",
                "name": "pep-0666.txt"
              }
            ],
            "prompt": "You are a technical expert.\nYou answer questions truthfully based on provided documents.\nIf the answer exists in several documents, summarize them.\nIgnore documents that don't contain the answer to the question.\nOnly answer based on the documents provided. Don't make things up.\nIf no information related to the question can be found in the document, say so.\nAlways use references in the form [NUMBER OF DOCUMENT] when using information from a document, e.g. [3] for Document[3].\nNever name the documents, only enter a number in square brackets as a reference.\nThe reference must only refer to the number that comes in square brackets after the document.\nOtherwise, do not use brackets in your answer and reference ONLY the number of the document without mentioning the word document.\nThese are the documents:\n\nDocument[1]:\nSenior members of Engineering and PM teams for a feature are expected to\nmake decisions in the spirit of the direction set by their CVP. Teams\nhave regular meetings with their CVP to discuss recent decisions and\nensure consistency. Decisions that are not obviously in line with CVP\nexpectations are escalated to the controversial process.\n\nControversial decision process\n------------------------------\n\nWhen decisions require cross-team coordination, or do not obviously\nalign with previous CVP guidance, teams will escalate decision making.\nThese often include decisions that involve changing direction,\nattempting to reach a new or different group of users, deprecating and\nremoving significant features (or on a short timeframe), or changes that\nrequire quick releases.\n\nIn general, CVPs are not intimately familiar with all aspects of the\nfeature team's work. As a result, the feature team must provide both a\nrecommendation and sufficient context for the decision that the CVP can\ndecide *without additional knowledge*. Most of the time, the first\nattempt results in a series of questions from the CVP, which the team\nwill research, answer and attempt the decision again at a later date.\n\nCommon questions asked by CVPs are:\n\n* how many users are affected by this decision?\n* what is the plan for minimizing impact on current users?\n* how will the change be \"sold\"/described to potential users?\n\n\n\nDocument[2]:\nAt the time of this writing there are 65,232 projects hosted on PyPI and of\nthose, 59 of them rely on external files that are safely hosted outside of PyPI\nand 931 of them rely on external files which are unsafely hosted outside of\nPyPI. This shows us that 1.5% of projects will be affected in some way by this\nchange while 98.5% will continue to function as they always have. In addition,\nonly 5% of the projects affected are using the features provided by :pep:`438` to\nsafely host outside of PyPI while 95% of them are exposing their users to\nRemote Code Execution via a Man In The Middle attack.\n\n\nFrequently Asked Questions\n==========================\n\nI can't host my project on PyPI because of <X>, what should I do?\n-----------------------------------------------------------------\n\nFirst you should decide if <X> is something inherent to PyPI, or if PyPI could\ngrow a feature to solve <X> for you. If PyPI can add a feature to enable you to\nhost your project on PyPI then you should propose that feature. However, if <X>\nis something inherent to PyPI, such as wanting to maintain control over your\nown files, then you should setup your own package repository and instruct your\nusers in your project's description to add it to the list of repositories their\ninstaller of choice will use.\n\n\nMy users have a worse experience with this PEP than before, how do I explain that?\n\n\nDocument[3]:\nOnly datetime/time instances with ``fold=1`` pickled\nin the new versions will become unreadable by the older Python\nversions.  Pickles of instances with ``fold=0`` (which is the\ndefault) will remain unchanged.\n\n\nQuestions and Answers\n=====================\n\nWhy not call the new flag \"isdst\"?\n----------------------------------\n\nA non-technical answer\n......................\n\n* Alice: Bob - let's have a stargazing party at 01:30 AM tomorrow!\n* Bob: Should I presume initially that Daylight Saving Time is or is\n  not in effect for the specified time?\n* Alice: Huh?\n\n-------\n\n* Bob: Alice - let's have a stargazing party at 01:30 AM tomorrow!\n* Alice: You know, Bob, 01:30 AM will happen twice tomorrow. Which time do you have in mind?\n* Bob:  I did not think about it, but let's pick the first.\n\n-------\n\n(same characters, an hour later)\n\n-------\n\n* Bob: Alice - this Py-O-Clock gadget of mine asks me to choose\n  between fold=0 and fold=1 when I set it for tomorrow 01:30 AM.\n  What should I do?\n* Alice: I've never hear of a Py-O-Clock, but I guess fold=0 is\n  the first 01:30 AM and fold=1 is the second.\n\n\nA technical reason\n..................\n\nWhile the ``tm_isdst`` field of the ``time.struct_time`` object can be\nused to disambiguate local times in the fold, the semantics of such\ndisambiguation are completely different from the proposal in this PEP.\n\n\n\nDocument[4]:\nCommon questions asked by CVPs are:\n\n* how many users are affected by this decision?\n* what is the plan for minimizing impact on current users?\n* how will the change be \"sold\"/described to potential users?\n\nCVPs are expected to have a strong understanding of the entire field, so\nthat they can evaluate some questions for themselves, such as:\n\n* what similar decisions have been made by other projects within Microsoft?\n* what other projects have plans that may impact this decision?\n* what similar decisions have been made by projects outside Microsoft?\n* do users need it?\n* is it in line with the direction set by their EVP?\n\nDecisions made by CVPs are generally arbitrary and final, though they\ntypically will provide their rationale.\n\nPlanning a new release\n----------------------\n\nReleases involve coordinating a number of feature teams, and so rarely\nattempt to include input from all teams. A schedule will be determined\nbased on broader ecosystem needs, such as planned events/conferences or\nopportunities to take advantage of media attention.\n\nTeams are informed of the release date, the theme of the release, and\nmake their own plans around it following the above decision making\nprocess. Changing the release date is considered a controversial\ndecision.\n\n\nAcknowledgements\n================\n\nThank you to Alex Crichton from the Rust team for an extensive explanation of how the\ncore team governs the project.\n\nJeremy Stanley, Chris Dent, Julia Kreger, Sean McGinnis, Emmet Hikory,\nand Thierry Carrez contributed to the OpenStack section.\n\n\n\nDocument[5]:\nIf an invalid transaction ID is provided, a\n    ProgrammingError_ will be raised.  This form should be called\n    outside of a transaction, and is intended for use in recovery.\n\n    On return, the TPC transaction is ended.\n\n\n.. _.tpc_rollback:\n.. _.tpc_rollback():\n\n`.tpc_rollback`_\\ ([ *xid* ])\n    When called with no arguments, `.tpc_rollback()`_ rolls back a TPC\n    transaction.  It may be called before or after `.tpc_prepare()`_.\n\n    When called with a transaction ID *xid*, it rolls back the given\n    transaction.  If an invalid transaction ID is provided, a\n    ProgrammingError_ is raised.  This form should be called outside\n    of a transaction, and is intended for use in recovery.\n\n    On return, the TPC transaction is ended.\n\n.. _.tpc_recover:\n.. _.tpc_recover():\n\n`.tpc_recover`_\\ ()\n    Returns a list of pending transaction IDs suitable for use with\n    ``.tpc_commit(xid)`` or ``.tpc_rollback(xid)``.\n\n    If the database does not support transaction recovery, it may\n    return an empty list or raise NotSupportedError_.\n\n\n\nFrequently Asked Questions\n==========================\n\nThe database SIG often sees reoccurring questions about the DB API\nspecification. This section covers some of the issues people sometimes\nhave with the specification.\n\n**Question:**\n\nHow can I construct a dictionary out of the tuples returned by\n`.fetch*()`_:\n\n**Answer:**\n\nThere are several existing tools available which provide helpers for\nthis task. Most of them use the approach of using the column names\ndefined in the cursor attribute `.description`_ as basis for the keys\nin the row dictionary.\n\n\n\nDocument[6]:\n* Should all those list methods really be implemented?\n\n* A case could be made for supporting ``.ljust()``, ``.rjust()``,\n  ``.center()`` with a mandatory second argument.\n\n* A case could be made for supporting ``.split()`` with a mandatory\n  argument.\n\n* A case could even be made for supporting ``.islower()``, ``.isupper()``,\n  ``.isspace()``, ``.isalpha()``, ``.isalnum()``, ``.isdigit()`` and the\n  corresponding conversions (``.lower()`` etc.), using the ASCII\n  definitions for letters, digits and whitespace.  If this is\n  accepted, the cases for ``.ljust()``, ``.rjust()``, ``.center()`` and\n  ``.split()`` become much stronger, and they should have default\n  arguments as well, using an ASCII space or all ASCII whitespace\n  (for ``.split()``).\n\n\nFrequently Asked Questions\n==========================\n\n**Q:** Why have the optional encoding argument when the encode method of\nUnicode objects does the same thing?\n\n**A:** In the current version of Python, the encode method returns a str\nobject and we cannot change that without breaking code.  The\nconstruct ``bytes(s.encode(...))`` is expensive because it has to\ncopy the byte sequence multiple times.  Also, Python generally\nprovides two ways of converting an object of type A into an\nobject of type B: ask an A instance to convert itself to a B, or\nask the type B to create a new instance from an A. Depending on\nwhat A and B are, both APIs make sense; sometimes reasons of\ndecoupling require that A can't know about B, in which case you\nhave to use the latter approach; sometimes B can't know about A,\nin which case you have to use the former.\n\n\n\n\nDocument[7]:\n* ``operator.exists(None)`` returns ``False``\n* ``operator.exists(NotImplemented)`` returns ``False``\n* ``operator.exists(Ellipsis)`` returns ``False``\n* ``float``, ``complex`` and ``decimal.Decimal`` will override the existence\n  check such that ``NaN`` values return ``False`` and other values (including\n  zero values) return ``True``\n* for any other type, ``operator.exists(obj)`` returns True by default. Most\n  importantly, values that evaluate to False in a truth checking context\n  (zeroes, empty containers) will still evaluate to True in an existence\n  checking context\n\nPEP Withdrawal\n==============\n\nWhen posting this PEP for discussion on python-ideas [4]_, I asked reviewers to\nconsider 3 high level design questions before moving on to considering the\nspecifics of this particular syntactic proposal:\n\n1. Do we collectively agree that \"existence checking\" is a useful\ngeneral concept that exists in software development and is distinct\nfrom the concept of \"truth checking\"?\n2. Do we collectively agree that the Python ecosystem would benefit\nfrom an existence checking protocol that permits generalisation of\nalgorithms (especially short circuiting ones) across different \"data\nmissing\" indicators, including those defined in the language\ndefinition, the standard library, and custom user code?\n3. Do we collectively agree that it would be easier to use such a\nprotocol effectively if existence-checking equivalents to the\ntruth-checking \"and\" and \"or\" control flow operators were available?\n\nWhile the answers to the first question were generally positive, it quickly\nbecame clear that the answer to the second question is \"No\".\n\n\n\nDocument[8]:\nThey are stuck like\nflies in treacle in this wretched argument, and it is self-evident\nthat they cannot disengage or they would have already done so.\n\nBut today I had to spend time cleaning my keyboard because the 'n'\nkey is sticking.  So, in addition to feeling compassion for these\npeople, I am pretty annoyed.  I figure if I make this PEP, we can\nthen ask Guido to quickly reject it, and then when this argument\nnext starts up again, we can say 'Guido isn't changing things to\nsuit the tab-haters or the only-tabbers, so this conversation is a\nwaste of time.'Then everybody can quietly believe that a) they\nare correct and b) other people are fools and c) they are\nundeniably fortunate to not have to share a lab with idiots, (which\nis something the arguers could do _now_, but apparently have\nforgotten).\n\nAnd python-list can go back to worrying if it is too smug, rather\nthan whether it is too hostile for newcomers.  Possibly somebody\ncould get around to explaining to me what is the difference between\n``__getattr__`` and ``__getattribute__`` in non-Classic classes in 2.2, a\nquestion I have foolishly posted in the middle of the current tab\nthread.  I would like to know the answer to that question [1]_.\n\nThis proposal, if accepted, will probably mean a heck of a lot of\nwork for somebody.  But since I don't want it accepted, I don't\ncare.\n\n\nReferences\n==========\n\n.. [1] Tim Peters already has (private correspondence).  \n\nQuestion: what questions can I ask?\nAnswer:"
          },
          "type": 1,
          "rank": 1,
          "documents": [
            {
              "id": "bb64450577396d87c46dff5d5c5f7c2bd7ec13b8fd63f57ec0962c9b1cad7aee",
              "content": "Senior members of Engineering and PM teams for a feature are expected to\nmake decisions in the spirit of the direction set by their CVP. Teams\nhave regular meetings with their CVP to discuss recent decisions and\nensure consistency. Decisions that are not obviously in line with CVP\nexpectations are escalated to the controversial process.\n\nControversial decision process\n------------------------------\n\nWhen decisions require cross-team coordination, or do not obviously\nalign with previous CVP guidance, teams will escalate decision making.\nThese often include decisions that involve changing direction,\nattempting to reach a new or different group of users, deprecating and\nremoving significant features (or on a short timeframe), or changes that\nrequire quick releases.\n\nIn general, CVPs are not intimately familiar with all aspects of the\nfeature team's work. As a result, the feature team must provide both a\nrecommendation and sufficient context for the decision that the CVP can\ndecide *without additional knowledge*. Most of the time, the first\nattempt results in a series of questions from the CVP, which the team\nwill research, answer and attempt the decision again at a later date.\n\nCommon questions asked by CVPs are:\n\n* how many users are affected by this decision?\n* what is the plan for minimizing impact on current users?\n* how will the change be \"sold\"/described to potential users?\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1363,
                      1595
                    ],
                    "doc_id": "c5c58fcd83f411e5bd721f3b1a34450034ca5b8c7a8715293a8fad6906ab6104"
                  },
                  {
                    "range": [
                      0,
                      207
                    ],
                    "doc_id": "cf8c7d2a1dcd45fa027ffa224c75144827ba3916e5ef1df23b7149e5e4de6485"
                  }
                ],
                "split_idx_start": 40833,
                "file_name": "pep-8002.txt",
                "_file_created_at": "2024-10-18T09:03:25.263525+00:00",
                "split_id": 30,
                "_file_size": 45645,
                "page_number": 1,
                "source_id": "cb82bd07390b495be18125f7fd431abca2bc4cff695a36cf612a6636c9deb59e"
              },
              "score": 0.4296875,
              "file": {
                "id": "6baf5e50-8a6c-4394-80ba-7a06f5863d74",
                "name": "pep-8002.txt"
              }
            },
            {
              "id": "1220ac6239bf67cd9bdf13f93000ede6faac31fb997dcf0ec2b1b2af9cf487d1",
              "content": "At the time of this writing there are 65,232 projects hosted on PyPI and of\nthose, 59 of them rely on external files that are safely hosted outside of PyPI\nand 931 of them rely on external files which are unsafely hosted outside of\nPyPI. This shows us that 1.5% of projects will be affected in some way by this\nchange while 98.5% will continue to function as they always have. In addition,\nonly 5% of the projects affected are using the features provided by :pep:`438` to\nsafely host outside of PyPI while 95% of them are exposing their users to\nRemote Code Execution via a Man In The Middle attack.\n\n\nFrequently Asked Questions\n==========================\n\nI can't host my project on PyPI because of <X>, what should I do?\n-----------------------------------------------------------------\n\nFirst you should decide if <X> is something inherent to PyPI, or if PyPI could\ngrow a feature to solve <X> for you. If PyPI can add a feature to enable you to\nhost your project on PyPI then you should propose that feature. However, if <X>\nis something inherent to PyPI, such as wanting to maintain control over your\nown files, then you should setup your own package repository and instruct your\nusers in your project's description to add it to the list of repositories their\ninstaller of choice will use.\n\n\nMy users have a worse experience with this PEP than before, how do I explain that?\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1137,
                      1375
                    ],
                    "doc_id": "031f525c7f49bf9261f7aa22b06a8e26d70503b4b321681c35895dfcc7211a8d"
                  },
                  {
                    "range": [
                      0,
                      367
                    ],
                    "doc_id": "57ce5e81193d4c5e1717cf42f32e8cd227620840d2e370c23a11fb7d81497b57"
                  }
                ],
                "split_idx_start": 14856,
                "file_name": "pep-0470.txt",
                "_file_created_at": "2024-10-18T09:03:57.211422+00:00",
                "split_id": 13,
                "_file_size": 23628,
                "page_number": 1,
                "source_id": "dec2760fa0c5abcbdec90ddf07767e84b9860d09cc6c1dcbcf7b0df94e18dd4d"
              },
              "score": 0.39306640625,
              "file": {
                "id": "03b7d7db-816e-45a1-9480-80669fb8af22",
                "name": "pep-0470.txt"
              }
            },
            {
              "id": "bdf4d62f2f52e9a3d1e87e6e41b9679ada4a930c321d33d3e77544c137cb88fb",
              "content": "Only datetime/time instances with ``fold=1`` pickled\nin the new versions will become unreadable by the older Python\nversions.  Pickles of instances with ``fold=0`` (which is the\ndefault) will remain unchanged.\n\n\nQuestions and Answers\n=====================\n\nWhy not call the new flag \"isdst\"?\n----------------------------------\n\nA non-technical answer\n......................\n\n* Alice: Bob - let's have a stargazing party at 01:30 AM tomorrow!\n* Bob: Should I presume initially that Daylight Saving Time is or is\n  not in effect for the specified time?\n* Alice: Huh?\n\n-------\n\n* Bob: Alice - let's have a stargazing party at 01:30 AM tomorrow!\n* Alice: You know, Bob, 01:30 AM will happen twice tomorrow. Which time do you have in mind?\n* Bob:  I did not think about it, but let's pick the first.\n\n-------\n\n(same characters, an hour later)\n\n-------\n\n* Bob: Alice - this Py-O-Clock gadget of mine asks me to choose\n  between fold=0 and fold=1 when I set it for tomorrow 01:30 AM.\n  What should I do?\n* Alice: I've never hear of a Py-O-Clock, but I guess fold=0 is\n  the first 01:30 AM and fold=1 is the second.\n\n\nA technical reason\n..................\n\nWhile the ``tm_isdst`` field of the ``time.struct_time`` object can be\nused to disambiguate local times in the fold, the semantics of such\ndisambiguation are completely different from the proposal in this PEP.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1389,
                      1681
                    ],
                    "doc_id": "a1270e82b4dbf104c429342bb71fb0a7fc80db41719f0d2a79ffa88215e9ced6"
                  },
                  {
                    "range": [
                      0,
                      211
                    ],
                    "doc_id": "ea7d03dac129035cacbb28d07304048f31e99487736aecb2df16b8903874ccca"
                  }
                ],
                "split_idx_start": 23551,
                "file_name": "pep-0495.txt",
                "_file_created_at": "2024-10-18T09:03:54.819307+00:00",
                "split_id": 18,
                "_file_size": 34899,
                "page_number": 1,
                "source_id": "04ae5810b522e53d51d5bb1f7e708f045a1e09977cde5b7e18a54646ffa0575f"
              },
              "score": 0.09027099609375,
              "file": {
                "id": "25a9a573-222b-4fc4-b284-a776903ed1ea",
                "name": "pep-0495.txt"
              }
            },
            {
              "id": "cf8c7d2a1dcd45fa027ffa224c75144827ba3916e5ef1df23b7149e5e4de6485",
              "content": "Common questions asked by CVPs are:\n\n* how many users are affected by this decision?\n* what is the plan for minimizing impact on current users?\n* how will the change be \"sold\"/described to potential users?\n\nCVPs are expected to have a strong understanding of the entire field, so\nthat they can evaluate some questions for themselves, such as:\n\n* what similar decisions have been made by other projects within Microsoft?\n* what other projects have plans that may impact this decision?\n* what similar decisions have been made by projects outside Microsoft?\n* do users need it?\n* is it in line with the direction set by their EVP?\n\nDecisions made by CVPs are generally arbitrary and final, though they\ntypically will provide their rationale.\n\nPlanning a new release\n----------------------\n\nReleases involve coordinating a number of feature teams, and so rarely\nattempt to include input from all teams. A schedule will be determined\nbased on broader ecosystem needs, such as planned events/conferences or\nopportunities to take advantage of media attention.\n\nTeams are informed of the release date, the theme of the release, and\nmake their own plans around it following the above decision making\nprocess. Changing the release date is considered a controversial\ndecision.\n\n\nAcknowledgements\n================\n\nThank you to Alex Crichton from the Rust team for an extensive explanation of how the\ncore team governs the project.\n\nJeremy Stanley, Chris Dent, Julia Kreger, Sean McGinnis, Emmet Hikory,\nand Thierry Carrez contributed to the OpenStack section.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1194,
                      1401
                    ],
                    "doc_id": "bb64450577396d87c46dff5d5c5f7c2bd7ec13b8fd63f57ec0962c9b1cad7aee"
                  },
                  {
                    "range": [
                      0,
                      282
                    ],
                    "doc_id": "dfc23c192a3852ba757cb84c461e8efa96bb819c837b132ea439184ba6b66f5a"
                  }
                ],
                "split_idx_start": 42027,
                "file_name": "pep-8002.txt",
                "_file_created_at": "2024-10-18T09:03:25.263525+00:00",
                "split_id": 31,
                "_file_size": 45645,
                "page_number": 1,
                "source_id": "cb82bd07390b495be18125f7fd431abca2bc4cff695a36cf612a6636c9deb59e"
              },
              "score": 0.06463623046875,
              "file": {
                "id": "6baf5e50-8a6c-4394-80ba-7a06f5863d74",
                "name": "pep-8002.txt"
              }
            },
            {
              "id": "cd52a90392d01c2980b1d019aeec65f3c8c5b79021d27d1592efaaf298b5dce5",
              "content": "If an invalid transaction ID is provided, a\n    ProgrammingError_ will be raised.  This form should be called\n    outside of a transaction, and is intended for use in recovery.\n\n    On return, the TPC transaction is ended.\n\n\n.. _.tpc_rollback:\n.. _.tpc_rollback():\n\n`.tpc_rollback`_\\ ([ *xid* ])\n    When called with no arguments, `.tpc_rollback()`_ rolls back a TPC\n    transaction.  It may be called before or after `.tpc_prepare()`_.\n\n    When called with a transaction ID *xid*, it rolls back the given\n    transaction.  If an invalid transaction ID is provided, a\n    ProgrammingError_ is raised.  This form should be called outside\n    of a transaction, and is intended for use in recovery.\n\n    On return, the TPC transaction is ended.\n\n.. _.tpc_recover:\n.. _.tpc_recover():\n\n`.tpc_recover`_\\ ()\n    Returns a list of pending transaction IDs suitable for use with\n    ``.tpc_commit(xid)`` or ``.tpc_rollback(xid)``.\n\n    If the database does not support transaction recovery, it may\n    return an empty list or raise NotSupportedError_.\n\n\n\nFrequently Asked Questions\n==========================\n\nThe database SIG often sees reoccurring questions about the DB API\nspecification. This section covers some of the issues people sometimes\nhave with the specification.\n\n**Question:**\n\nHow can I construct a dictionary out of the tuples returned by\n`.fetch*()`_:\n\n**Answer:**\n\nThere are several existing tools available which provide helpers for\nthis task. Most of them use the approach of using the column names\ndefined in the cursor attribute `.description`_ as basis for the keys\nin the row dictionary.\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1547,
                      1772
                    ],
                    "doc_id": "ef61cb384550a218ca58907875881b7d161b50284ad51bffb5cad3a9c303ad4b"
                  },
                  {
                    "range": [
                      0,
                      336
                    ],
                    "doc_id": "a6820aa8d1caa3a12fdf71f19ed0840284e90b85c41697cb61e159f6cb085102"
                  }
                ],
                "split_idx_start": 35953,
                "file_name": "pep-0249.txt",
                "_file_created_at": "2024-10-18T09:04:14.063065+00:00",
                "split_id": 25,
                "_file_size": 46420,
                "page_number": 1,
                "source_id": "844df4c20398c29318a2ab1a588f79da140a39b37bc7138536f9bf64fb19b378"
              },
              "score": 0.060089111328125,
              "file": {
                "id": "efc377d8-35ea-491a-b8e2-0c9b8bf36a6f",
                "name": "pep-0249.txt"
              }
            },
            {
              "id": "d8487b5a413b2f4b639680d901631057f10f0d66b3614aafaa2e682a492b98bd",
              "content": "* Should all those list methods really be implemented?\n\n* A case could be made for supporting ``.ljust()``, ``.rjust()``,\n  ``.center()`` with a mandatory second argument.\n\n* A case could be made for supporting ``.split()`` with a mandatory\n  argument.\n\n* A case could even be made for supporting ``.islower()``, ``.isupper()``,\n  ``.isspace()``, ``.isalpha()``, ``.isalnum()``, ``.isdigit()`` and the\n  corresponding conversions (``.lower()`` etc.), using the ASCII\n  definitions for letters, digits and whitespace.  If this is\n  accepted, the cases for ``.ljust()``, ``.rjust()``, ``.center()`` and\n  ``.split()`` become much stronger, and they should have default\n  arguments as well, using an ASCII space or all ASCII whitespace\n  (for ``.split()``).\n\n\nFrequently Asked Questions\n==========================\n\n**Q:** Why have the optional encoding argument when the encode method of\nUnicode objects does the same thing?\n\n**A:** In the current version of Python, the encode method returns a str\nobject and we cannot change that without breaking code.  The\nconstruct ``bytes(s.encode(...))`` is expensive because it has to\ncopy the byte sequence multiple times.  Also, Python generally\nprovides two ways of converting an object of type A into an\nobject of type B: ask an A instance to convert itself to a B, or\nask the type B to create a new instance from an A. Depending on\nwhat A and B are, both APIs make sense; sometimes reasons of\ndecoupling require that A can't know about B, in which case you\nhave to use the latter approach; sometimes B can't know about A,\nin which case you have to use the former.\n\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1265,
                      1519
                    ],
                    "doc_id": "a1b099824f5ed8e8f699fc5c4a651727b1396f3acc1ab136b70198b17585455d"
                  },
                  {
                    "range": [
                      0,
                      247
                    ],
                    "doc_id": "7d0d10b64c45c09f452e2e2983fecb0dd0cae729ad1d4bb7683fb27a00fa87be"
                  }
                ],
                "split_idx_start": 7296,
                "file_name": "pep-0358.txt",
                "_file_created_at": "2024-10-18T09:04:05.398200+00:00",
                "split_id": 7,
                "_file_size": 10167,
                "page_number": 1,
                "source_id": "1001da6bc5caefbbab5e166ab7322c211c08d2de32433481a35b40c6ce009f3f"
              },
              "score": 0.0592041015625,
              "file": {
                "id": "3b5a486a-e520-466c-a914-6d0c20a63037",
                "name": "pep-0358.txt"
              }
            },
            {
              "id": "e5205082f27c41144770390df9af0a63d4e0b14aeffed54a0be58fff7e7cab96",
              "content": "* ``operator.exists(None)`` returns ``False``\n* ``operator.exists(NotImplemented)`` returns ``False``\n* ``operator.exists(Ellipsis)`` returns ``False``\n* ``float``, ``complex`` and ``decimal.Decimal`` will override the existence\n  check such that ``NaN`` values return ``False`` and other values (including\n  zero values) return ``True``\n* for any other type, ``operator.exists(obj)`` returns True by default. Most\n  importantly, values that evaluate to False in a truth checking context\n  (zeroes, empty containers) will still evaluate to True in an existence\n  checking context\n\nPEP Withdrawal\n==============\n\nWhen posting this PEP for discussion on python-ideas [4]_, I asked reviewers to\nconsider 3 high level design questions before moving on to considering the\nspecifics of this particular syntactic proposal:\n\n1. Do we collectively agree that \"existence checking\" is a useful\ngeneral concept that exists in software development and is distinct\nfrom the concept of \"truth checking\"?\n2. Do we collectively agree that the Python ecosystem would benefit\nfrom an existence checking protocol that permits generalisation of\nalgorithms (especially short circuiting ones) across different \"data\nmissing\" indicators, including those defined in the language\ndefinition, the standard library, and custom user code?\n3. Do we collectively agree that it would be easier to use such a\nprotocol effectively if existence-checking equivalents to the\ntruth-checking \"and\" and \"or\" control flow operators were available?\n\nWhile the answers to the first question were generally positive, it quickly\nbecame clear that the answer to the second question is \"No\".\n\n",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      1543,
                      1953
                    ],
                    "doc_id": "d37ed076d14690b1ad4b2cb59c6e245fd1104548e56d89e925c8847b76f56a09"
                  },
                  {
                    "range": [
                      0,
                      333
                    ],
                    "doc_id": "50ff59444ce4c43d8403d8b80d35eb45bd4d2e884d6be8abe0a8e474eaf6b7c7"
                  }
                ],
                "split_idx_start": 1543,
                "file_name": "pep-0531.txt",
                "_file_created_at": "2024-10-18T09:03:52.479051+00:00",
                "split_id": 1,
                "_file_size": 27283,
                "page_number": 1,
                "source_id": "458c108716c2cfeb7df82c998ddcdfc3e56f76b0a5ca3f2ea153dd5bf49b5c20"
              },
              "score": 0.053192138671875,
              "file": {
                "id": "f8210692-e95d-4629-bd4d-a9a2d92ffc55",
                "name": "pep-0531.txt"
              }
            },
            {
              "id": "df278bc9036506850e48f21aa0f2576edfb3c9e2fbd414d522dd49d1c153d13a",
              "content": "They are stuck like\nflies in treacle in this wretched argument, and it is self-evident\nthat they cannot disengage or they would have already done so.\n\nBut today I had to spend time cleaning my keyboard because the 'n'\nkey is sticking.  So, in addition to feeling compassion for these\npeople, I am pretty annoyed.  I figure if I make this PEP, we can\nthen ask Guido to quickly reject it, and then when this argument\nnext starts up again, we can say 'Guido isn't changing things to\nsuit the tab-haters or the only-tabbers, so this conversation is a\nwaste of time.'Then everybody can quietly believe that a) they\nare correct and b) other people are fools and c) they are\nundeniably fortunate to not have to share a lab with idiots, (which\nis something the arguers could do _now_, but apparently have\nforgotten).\n\nAnd python-list can go back to worrying if it is too smug, rather\nthan whether it is too hostile for newcomers.  Possibly somebody\ncould get around to explaining to me what is the difference between\n``__getattr__`` and ``__getattribute__`` in non-Classic classes in 2.2, a\nquestion I have foolishly posted in the middle of the current tab\nthread.  I would like to know the answer to that question [1]_.\n\nThis proposal, if accepted, will probably mean a heck of a lot of\nwork for somebody.  But since I don't want it accepted, I don't\ncare.\n\n\nReferences\n==========\n\n.. [1] Tim Peters already has (private correspondence).  ",
              "content_type": "text",
              "meta": {
                "_split_overlap": [
                  {
                    "range": [
                      958,
                      1272
                    ],
                    "doc_id": "8bf08cd4e8415c0f169f4b265eb64d99876a3d3756a964375c2275b376d1fe54"
                  },
                  {
                    "range": [
                      0,
                      218
                    ],
                    "doc_id": "9fb0832ccf6f1e8d9cbd88f403aca7beaf0f421c9d3bbd0b3e6cbf14930a0275"
                  }
                ],
                "split_idx_start": 2242,
                "file_name": "pep-0666.txt",
                "_file_created_at": "2024-10-18T09:03:39.828710+00:00",
                "split_id": 2,
                "_file_size": 4018,
                "page_number": 1,
                "source_id": "793dfd5a5e1edaaf624ccfbf89c06dcd57eb858e050467eb4b2f386dcfba8b72"
              },
              "score": 0.050048828125,
              "file": {
                "id": "7d0f4816-4c6d-487b-b2df-86ff3fb4ced9",
                "name": "pep-0666.txt"
              }
            }
          ],
          "score": null
        }
      ],
      "session_id": "b826bb58-4f17-466e-a770-3f9ae89c5f4f",
      "time": "2024-10-18T09:44:03.240358Z",
      "duration": 6.256662368774414,
      "user": {
        "given_name": "Agnieszka",
        "family_name": "Marzec",
        "user_id": "f6398740-5555-445d-8ae3-ef980ea4191d"
      },
      "pipeline": {
        "name": "rag-chat"
      }
    }
  ],
  "has_more": false
}

Example

This is an example Python script that:

  1. Gets the pipeline ID and starts a new chat in the search session.
  2. Resets the newly created chat.
  3. Retrieves and displays a list of previous chats.

The script is available as Google Colab: Chat application in deepset Cloud.