Metadata-Version: 2.1
Name: cycls
Version: 0.0.2.13
Summary: Cycls SDK
Author: Mohammed Jamal
Author-email: mj@cycls.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: asyncssh (>=2.14.2,<3.0.0)
Requires-Dist: fastapi (>=0.111.0,<0.112.0)
Requires-Dist: httpx (>=0.27.0,<0.28.0)
Description-Content-Type: text/markdown

</br></br><p align="center"><img src="https://cycls.com/static/assets/favicon.svg" alt="Cycls"></p></br>

<div align="center">
    <a href="https://pypi.org/project/cycls/" target="_blank" rel="noopener noreferrer">
        <img loading="lazy" src="https://img.shields.io/pypi/v/cycls.svg" alt="PyPI" class="img_ev3q" style="display: inline;">
    </a>
    <a href="https://discord.gg/BMnaMatDC7" target="_blank" rel="noopener noreferrer">
        <img loading="lazy" src="https://img.shields.io/discord/1175782747164389466" alt="Discord" class="img_ev3q" style="display: inline;">
    </a>
</div>

# cycls.py

```sh
pip install cycls
```

## sync app
```py
from cycls import Cycls, Message, Text

push = Cycls()

@push("cake")
def app(m: Message):
    return Text(m.content)
```
`https://cycls.com/@cake`

## async app
```py
from cycls import Cycls, Message, Text

push = Cycls()

@push("her")
async def app(m: Message):
    return Text(m.content)
```
`https://cycls.com/@her`

## debug
```py
push = Cycls(debug=True)
```

## groq app
```py
from cycls import Cycls, Message, Text
from groq import AsyncGroq

push = Cycls()

groq = AsyncGroq(api_key="YOUR_KEY")

async def llm(content):
    stream = await groq.chat.completions.create(
        messages=[
            {"role": "system", "content": "you are a helpful assistant."},
            {"role": "user", "content": content}
        ],
        model="llama3-70b-8192",
        temperature=0.5, max_tokens=1024, top_p=1, stop=None, 
        stream=True,
    )

    async def event_stream():
        async for chunk in stream:
            yield f"{chunk.choices[0].delta.content}"

    return event_stream()

@push("groq-app")
async def app(x:Message):
    stream = await llm(x.content)
    return Text(stream)
```
`https://cycls.com/@groq-app`

## history
```py
@push("cake")
def app(m:Message):
   print(m.history)
   return Text(m.content)
```
`https://cycls.com/@cake`

## groq app with history
```py
from cycls import Cycls, Message, Text
from groq import AsyncGroq

push = Cycls()

groq = AsyncGroq(api_key="YOUR_KEY")

async def llm(messages):
    stream = await groq.chat.completions.create(
        messages=messages,
        model="llama3-70b-8192",
        temperature=0.5, max_tokens=1024, top_p=1, stop=None, 
        stream=True,
    )

    async def event_stream():
        async for chunk in stream:
            yield f"{chunk.choices[0].delta.content}"

    return event_stream()

@push("groq-app")
async def app(m:Message):
    x  = [{"role": "system", "content": "you are a helpful assistant."}]
    x +=  m.history
    x += [{"role": "user", "content": m.content}]
    stream = await llm(x)
    return Text(stream)
```
`https://cycls.com/@groq-app`

# Known issues
- Dev mode doesn't work on Windows machines

