Skip to main content

Cycls SDK

Project description



Cycls


cycls.py

pip install cycls

sync app

from cycls import Cycls, Message, Text

push = Cycls()

@push("cake")
def app(m: Message):
    return Text(m.content)

https://cycls.com/@cake

async app

from cycls import Cycls, Message, Text

push = Cycls()

@push("her")
async def app(m: Message):
    return Text(m.content)

https://cycls.com/@her

debug

push = Cycls(debug=True)

groq app

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

@push("cake")
def app(m:Message):
   print(m.history)
   return Text(m.content)

https://cycls.com/@cake

groq app with history

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cycls-0.0.2.13.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

cycls-0.0.2.13-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file cycls-0.0.2.13.tar.gz.

File metadata

  • Download URL: cycls-0.0.2.13.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.13 Linux/6.5.0-1021-azure

File hashes

Hashes for cycls-0.0.2.13.tar.gz
Algorithm Hash digest
SHA256 05d2615ad3ab40589554032e1fc0a8ed2957bae0a95b35d831d3da2f09533ba7
MD5 2e03aa6aa459d15256bce0e5fb3ed158
BLAKE2b-256 fe9b90e469cebeb3290a68bb3db9cf4149199d1573e813cc909eaea84dc8aa10

See more details on using hashes here.

File details

Details for the file cycls-0.0.2.13-py3-none-any.whl.

File metadata

  • Download URL: cycls-0.0.2.13-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.13 Linux/6.5.0-1021-azure

File hashes

Hashes for cycls-0.0.2.13-py3-none-any.whl
Algorithm Hash digest
SHA256 8f791d3718d05a4fb5507836f7f7fa22f9d8c5f37186446224b85f8609274880
MD5 83a7de4610247cb01227565f64bb573b
BLAKE2b-256 25f213e0ebc7bc3cc034c2b1a6e982a08c6538ee91a0d565a849f2201b15788e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page