Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ai-openchat

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai-openchat

Python module for asynchronous interaction with OpenAI

  • 1.1.8
  • PyPI
  • Socket score

Maintainers
1

Typing SVG


Download: https://pypi.org/project/ai-openchat/

Chat

  1. Example #1 Chat:
import asyncio

from ai_openchat import Model, AsyncOpenAI


async def chat():
    openai_client = AsyncOpenAI(token='API-KEY')
    resp = await openai_client.generate_message('Your request?', Model().chat())
    print(resp)


if __name__ == '__main__':
    asyncio.run(chat())
  1. Example #2 Movie to Emoji:
import asyncio

from ai_openchat import Model, AsyncOpenAI


async def movie_to_emoji():
    openai_client = AsyncOpenAI(token='API-KEY')
    resp = await openai_client.generate_message('Convert movie titles into emoji.\n\n'
                                            'Back to the Future: 👨👴🚗🕒 \n'
                                            'Batman: 🤵🦇 \n'
                                            'Transformers: 🚗🤖 \n'
                                            'Star Wars:', Model().movie_to_emoji())
    print(resp)
    # ⭐️⚔️


if __name__ == '__main__':
    asyncio.run(movie_to_emoji())


  1. Example #3 Custom chat
import asyncio

from ai_openchat import Model, AsyncOpenAI


async def image_generator():
    
    custom_model = Model(
        model="code-davinci-002",
        temperature=0,
        max_tokens=100,
        top_p=1.0,
        frequency_penalty=0.5,
        presence_penalty=0.0,
        stop=["You:"]
    )

    openai_client = AsyncOpenAI(token='API-KEY')
    resp = await openai_client.generate_message('Hello!', custom_model)
    print(resp)


if __name__ == '__main__':
    asyncio.run(image_generator())

Image

  1. Generate Image
import asyncio

from ai_openchat import ImageModel, AsyncOpenAI


async def image_generator():
    openai_client = AsyncOpenAI(token='API-KEY')
    resp = await openai_client.generate_image('Captain America', ImageModel().image())
    print(resp)


if __name__ == '__main__':
    asyncio.run(image_generator())
  1. Generate custom Image
import asyncio

from ai_openchat import ImageModel, AsyncOpenAI


async def image_generator():

    custom_model = ImageModel(n=1, size="1024x1024")

    openai_client = AsyncOpenAI(token='API-KEY')
    resp = await openai_client.generate_image('Captain America', custom_model)
    print(resp)


if __name__ == '__main__':
    asyncio.run(image_generator())

This project is an attempt to make an asynchronous library for convenient OpenAI management. You can check out the rest of the models here: https://beta.openai.com/examples.

Technologies

  • Python >= 3.8;
  • aiohttp >= 3.8

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc