Skip to main content

Twikit Grok

Project description

twikit_grok

Extension for using Grok with Twikit.

Installing

pip install twikit_grok

Quick Example

Streaming

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.stream('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.stream('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.stream('hello'):
        print(chunk)

asyncio.run(main())

Non Streaming

conversation = await client.create_grok_conversation()
content = await conversation.generate('generate images of cats.')
await content.attachments[0].download('image.jpg')

content2 = await conversation.generate('hello')
print(content2.message)

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.2.tar.gz (6.8 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.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: twikit_grok-0.0.2.tar.gz
  • Upload date:
  • Size: 6.8 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.2.tar.gz
Algorithm Hash digest
SHA256 9ab4dd416fdd52d7f71b68ec405e2a064e337fd4959d9fb3de876a5fa83d997b
MD5 3d192c9e7ca78b27c295ad15c5cad82a
BLAKE2b-256 042d32a9a7446b9c554c52aa31b79dcca7ed7974a14af65ce7b8b14064f32fe7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: twikit_grok-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2f6e899ff3beea585893d1c0ec79a8fefe6f90a0e8053db32dbfc73973f5c969
MD5 fb7b2567c26604d6cd4d1b258bd5f401
BLAKE2b-256 2f1d87d2bda6fefd77311943c9370f398b131a974e337e329528b31fd668db96

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