semvec/pypi-packages huggingface dataset:
BraketLab 1.78
Educational tool for learning quantum theory with Jupyter Notebooks

<img src="https://raw.githubusercontent.com/audunsh/braketlab/master/graphics/braketlab_logo.png" width = 250px>

# Out-of-the-box outside-of-the-box thinking

BraketLab is a pure Python-code for doing quantum theory in Jupyter Notebooks.

BraketLab is being developed by Audun Skau Hansen (a.s.hansen@kjemi.uio.no) at the Department of Chemistry, Hylleraas Centre for Quantum Molecular Sciences, University of Oslo.

# Documentation (in developement)

<a href="https://audunsh.github.io/braketlab/">Documentation on github pages</a>

# Installation

Install the BraketLab-module using <code>pip install braketlab</code> from your terminal.
pfrtf 0.0.1
Pandas fast reading table file by using pickle
Requires Python: >=3.7

# pfrtf - Pandas fast reading table file by using pickle

This module will speed up the loading of data into Pandas from files that rarely change. Supports file formats (.xlsx, .xls, .xlsm, .xlsb and .csv). This module tracks file hashes and saves data in *.pkl format. If the file has already been read, re-reading occurs from the *.pkl file. This significantly speeds up the loading of data. In my case, it speeds up data reading by 100 times.

# Requirements
    Pandas>=1.4.4
    openpyxl>=2.6.0

# Install
    pip install pfrtf

# Tutorial:
    import pfrtf
    import os
    path_file = os.path.join(os.getcwd(),'SampleData.xlsx')
    df = pfrtf.fast_read_file(path_file)

    import pfrtf
    df = pfrtf.fast_read_file(r'C:\Users\user\SampleData.xlsx')
openai-httpx-client 0.1.3
OpenAI async API with client side timeout, retry with exponential backoff and connection reuse
Requires Python: >=3.7.16

# OpenAI client with client timeout and parallel processing

## Quick Install

`pip install openai-httpx-client`

## 🤔 What is this?

This library is aimed at assisting with OpenAI API usage by:

Support for client side timeouts with retry and backoff for completions.

Support for concurrent processing with pandas DataFrames.

##

Example of chat completion with client timeout of 1 second to connect and 10 seconds to read with a maximum of 3
retries.

````
import os
from httpx import Timeout
from rolebotics import OpenAIClient, Message, ChatRequest, SystemMessage

client = OpenAIClient(api_key=os.environ['OPENAI_API_KEY'])

messages = [
    Message(
        role="user",
        content=f"Hello ChatGPT, Give a brief overview of the book Frankenstein by Mary Shelley.",
    )
]

response = client.chat_completion(request=ChatRequest(messages=messages),client_timeout=Timeout(1.0,read=10.0),retries=3)

````

Example of concurrent processing a DataFrame for chat completions with 4 concurrent connections.

 ````
import os
from httpx import Timeout
from rolebotics import OpenAIClient, Message, ChatRequest, SystemMessage
import uuid
import pandas as pd

[//]: # (Example DataFrame)
TEST_INPUTS = [
    "the open society and its enemies by Karl Popper",
    "Das Capital by Karl Marx",
    "Pride and Prejudice by Jane Austen",
    "Frankenstein by Mary Shelley",
    "Moby Dick by  Herman Melville",
]

records = [
    {"user_id": i, "book_id": str(uuid.uuid4())[:6], "book_name": s}
    for i, s in enumerate(TEST_INPUTS)
]
input_df = pd.DataFrame.from_records(records)


client = OpenAIClient(api_key=os.environ['OPENAI_API_KEY'])

messages = [
    Message(
        role="user",
        content=f"Hello ChatGPT, Give a brief overview of the book Frankenstein by Mary Shelley.",
    )
]

[//]: # (Define a mapping function from row to prompt)
def my_prompt_fn(r: pd.Series) -> ChatRequest:
    message = Message(
        role="user",
        content=f"Hello ChatGPT, Give a brief overview of the book {r.book_name}.",
    )

[//]: # (key Dict is mandatory since results order is NOT guaranteed!)
    key = {"user_id": r.user_id, "book_id": r.book_id}
    return ChatRequest(
        key=key,
        messages=[message],
        system=SystemMessage(content="Assistant is providing book reviews"),
    )

[//]: # (parallel process the DataFrame making up to 4 concurrent requests to OpenAI endpoint)
result_df = client.chat_completions(df=input_df, request_fn=my_prompt_fn,max_connections=4)

[//]: # (result_df columns contains 'openai_reply' and 'api_error' columns.

````

### Default Response Extraction

By default, only the "assistant" message (or messages if n>1) would be returned,
but you can implement a custom ResponseProcessor

```
class ResponseProcessor(Generic[R], Callable[..., R], ABC):
    @abstractmethod
    def __call__(self, json: str, *args: Any, **kwargs: Any) -> R:
        pass
```