semvec/pypi-packages huggingface dataset:
langprompt 0.1.1
Add your description here
Requires Python: >=3.10

# LangPrompt

LangPrompt is a Python library for creating chat prompts with template support.

> Some code come from <https://github.com/cfahlgren1/observers>，<https://github.com/Mirascope/mirascope>

## Installation

```bash
pip install langprompt
```

## Usage

```python
from pydantic import BaseModel
from langprompt import TextOutputParser, Prompt
from langprompt.llms.openai import OpenAI
from langprompt.cache import SQLiteCache
from langprompt.store import DuckDBStore


class Input(BaseModel):
    text: str
    language: str = "Chinese"

prompt = Prompt[Input]("""


You are a professional translator. Please accurately translate the text while maintaining its original meaning and style.





Translate the following text into {{language}}: {{text}}


""")

if __name__ == "__main__":

    parser = TextOutputParser()
    provider = OpenAI(model="gpt-4o-mini", cache=SQLiteCache(), store=DuckDBStore(), query_per_second=0.2)
    inputs = [
        Input(text="Hello, how are you?", language="Chinese"),
        Input(text="Hello, how are you?", language="English"),
        Input(text="Hello, how are you?", language="Chinese"),
    ]

    messages = [prompt.parse(input) for input in inputs]
    responses = provider.batch(messages, batch_size=2, enable_retry=True)

    # 处理结果
    for i, response in enumerate(responses):
        print(f"\n--- Result {i+1} ---")
        print(f"Original: {inputs[i].text}")
        result = parser.parse(response)
        print(f"Translated: {result}")
```

执行结果：

```txt
--- Result 1 ---
Original: Hello, how are you?
Translated: 你好，你好吗？
Cache Key: None

--- Result 2 ---
Original: Hello, how are you?
Translated: Hello, how are you?
Cache Key: None

--- Result 3 ---
Original: Hello, how are you?
Translated: 你好，你好吗？
Cache Key: 5693a0a16dff61866ca18feef969719cc78979a5f44cd412fef1add7bdcaaa42
```

## Todo

1. OpenAI Tools 完全支持
2. OpenAI JSON Mode 支持
3. support data viewer
4. add to langeval/ragas/distilabel
distilabel support qianfan、llm cache
caesar-cipher-tool-pye-edition 3.1
A simple terminal program use to encipher/decipher text to/from Caesar Cipher.

# Caesar Cipher Tool<sup><sup>TM</sup></sup> - Python Edition
A simple program use to Encipher/Decipher text to/from Caesar Cipher.
And yes, there are more versions of this program from other programming languages.

## How this thing works
1. It slices the alphabet from the index of shift then add the sliced part to the start of the alphabet.
2. Find the index of every character in user input in the alphabet and append the character with the same index into the output. Add the character into the output if it doesn't exist in the alphabet.

## Functionalities
Encipher/Decipher text to/from Caesar Cipher. This have 2 modes:
1. Input from keyboard: Good for inputting short texts and quickly Encipher/Decipher them.
2. Input from file: Good for processing a large amount of text, result will be put into another file. You can input the file name you desire, or leave blank to use the default name (output.txt). You have to specify the directory for the output file in case you select this mode.

## Installation
<ol type="1">
  <li>
    Install Python 3.x from <a href="https://www.python.org/downloads/" target="_blank">here</a>. (Ignore if you already have Python 3.x installed)
  </li>
  <li>
    Open terminal, run:
    
```
pip install caesar_cipher_tool_pye_edition
```
  </li>
</ol>

## Usage
<ol type="1">
  <li>
    Open terminal, run:

```
cct
```
  </li>
  <li>
    Alternatively, in a Python file (*.py), you can do:
    
```
from caesar_cipher_tool_pye_edition import main
main()
```
To use the program.
  </li>
  <li>
    Similarly, you can do:
    
```
from caesar_cipher_tool_pye_edition.main import Caesar
```
To use the ciphering function.
(Syntax: Caesar({user_input}, {shift}) with user_input = user input, shift = shift, enter minus shift in order to decipher texts to use the ciphering function.)
  </li>
</ol>

## Requirement(s)
1.  Python 3.x

## Note(s)
1. While the input from file mode support pretty much any file type, anything other than plain text files (*.txt,...) could cause the program to freeze up (e.g *.exe,...) so avoid inputting those.

## License
This project is licensed under the GNU General Public License 3.0, check [LICENSE](LICENSE) for more details.