Skip to main content

Twikit Grok

Project description

twikit_grok

Extension for using Grok with Twikit.

Installing

pip install twikit_grok

Quick Example

import asyncio
from twikit_grok import Client

USERNAME = 'example_user'
EMAIL = 'email@example.com'
PASSWORD = 'password0000'

client = Client('en-US')

async def main():
    # Login to an account
    if os.path.exists('cookies.json'):
        client.load_cookies('cookies.json')
    else:
        await client.login(
            auth_info_1=USERNAME,
            auth_info_2=EMAIL,
            password=PASSWORD
        )
        client.save_cookies('cookies.json')

    # Create a new conversation
    conversation = await client.create_grok_conversation()
    # Generate a response
    async for chunk in conversation.generate('hello'):
        print(chunk)

    # Generate a response with images
    attachments = [
        await client.upload_grok_attachment('image1.jpg'),
        await client.upload_grok_attachment('image2.jpg')
    ]
    async for chunk in conversation.generate('please describe these images', attachments):
        print(chunk)


    # Continue from an existing conversation
    conversation = await client.get_grok_conversation('123456789')  # Get conversation by ID
    async for chunk in conversation.generate('hello'):
        print(chunk)

asyncio.run(main())

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

twikit_grok-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twikit_grok-0.0.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file twikit_grok-0.0.1.tar.gz.

File metadata

  • Download URL: twikit_grok-0.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for twikit_grok-0.0.1.tar.gz
Algorithm Hash digest
SHA256 717cbdd927cfd20d958107841e5e8ca5c097eb736127bdd86838e9b0f94e34fd
MD5 362a837cfb7f8ec7a18203524ae76e34
BLAKE2b-256 3f3aee76ce7609b39e7dec961edf3240d3e86f995d139c4ad8951786d58ac498

See more details on using hashes here.

File details

Details for the file twikit_grok-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: twikit_grok-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for twikit_grok-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 778f74d60c92ab9f829b819e960bda98a254cb48e7c5d1d29e03633c4a1ae3ad
MD5 de54f572f07603da4e4e43f007fbcc5d
BLAKE2b-256 65ac5f7f757696ce7457dc627a6efde0e15cba5310daf8766e53d022156658ff

See more details on using hashes here.

Supported by

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