semvec/pypi-packages huggingface dataset:
choc-expr 1.3.5
A Python templating library
Requires Python: >=3.12.2

[![PyPI version](https://badge.fury.io/py/choc-expr.svg)](https://badge.fury.io/py/choc-expr) ![Licence badge](https://img.shields.io/pypi/l/choc-expr) ![Python](https://img.shields.io/badge/python-3.12.2-blue.svg)
[![Actions Status](https://github.com/pe-brian/choc-expr/workflows/tests/badge.svg)](https://github.com/pe-brian/choc-expr/actions)
![Dependencies](https://img.shields.io/badge/dependencies-typeguard-cyan)
![Downloads per month](https://img.shields.io/pypi/dm/choc-expr)
![Last commit](https://img.shields.io/github/last-commit/pe-brian/choc-expr)

# choc-expr

A Python templating library

# Why ChocExpr ?

ChocExpr is used by Chocolatine to help to generate SQL queries, but you are free to use it for your own projects.

# Installation

```pip install choc-expr```

# Functionnalities

- If-Then-Else statements
- Line break
- Compact/Extended mode
- Attributes evaluation :
    - Loop : unpack iterable and join it by a character separator
    - Attribute chain : follow the chain and return the nested value

# TODO

- Nested Conditions
- Methods (upper, lower, title, etc...)
- Optional parenthesis in loop statement

# Examples

```python
from choc_expr import Expr as ChocExpr

age = 24  # or 15
print(ChocExpr("Kevin is @{age}>=18:an adult:a child; of {age} years old", vars()))
```

**output :**

```
>> Kevin is an adult of 24 years old
```

*or*

```
>> Kevin is a child of 15 years old
```

*depending if condition is True or False*.
kwnn 1.0.6
kwniu.com ai sdk
Requires Python: >=3.7.1

## 会问牛牛 Python3 SDK

> api key 请联系商务开通。

### 1、安装sdk

```
pip install kwnn
```


### 2、发起一个请求
```python
import os
from kwnn import KwnnAI

client = KwnnAI(
    base_url="可选代理url",
    api_key=os.environ.get("KWNN_API_KEY"),
    timeout=120, # default
)
```

#### 请求参数

|参数|类型|是否必填|说明|
|----|----|-------|---|
|cid|uuid|否|会话id，带上第一次响应的cid可支持上下文|
|content|str|是|问题内容|
|stream|bool|否|流式输出|

#### 响应参数
|参数|类型|说明|
|----|----|---|
|cid|uuid|会话id，用于上下文|
|mid|uuid|消息id|
|message|array|响应的内容|
|content|str|AI生成的内容|

```json
{
    "cid": "1639a26f-fbcb-499f-823e-826fb3e448e1",
    "mid": "b15aef9e-5512-4d5f-8b22-04a3c57fcacf",
    "message": [
        {
            "content": "我是会问牛牛，专注于回答关于财务内容的问题。"
        }
    ]
}
```

### 3、调用对话API
#### 流式输出
```python
import os
from kwnn import KwnnAI

client = KwnnAI(
    api_key=os.environ.get("KWNN_API_KEY")
)

stream = client.chat.completions.create(
    content="你好！",
    stream=True,
)

for chunk in stream:
    if chunk.message[0].content is not None:
        print(chunk.message[0].content)
```
#### 非流式输出
```python
import os
from kwnn import KwnnAI

client = KwnnAI(
    api_key=os.environ.get("KWNN_API_KEY")
)

completion = client.chat.completions.create(
    content="你好！",
)

print(completion.message[0].content)
```