Skip to main content

Interact with AI without API key

Project description

tgpt2

Python Test License PyPi Black Passing coverage Progress Downloads Latest release release date wakatime

AI for all

from tgpt2 import TGPT
bot = TGPT()
resp = bot.chat('<Your prompt>')
print(resp)
# Output : How may I help you.

This project allows you to interact with AI (LLaMA) without API Key.

The name tgpt2 is inherited from it's parent project tgpt which runs on golang.

Prerequisite

Installation and usage

Installation

Pick either of the following ways to get started.

  1. From pypi:
pip install tgpt2
  1. Direct from source
pip install git+https://github.com/Simatwa/tgpt2.git
  1. Clone and Install
git clone https://github.com/Simatwa/tgpt2.git
cd tgp2
pip install .

Usage

This package features a ready to use commandline interface.

  • Quick response python -m tgpt2 generate "<Your prompt>"

  • Interactive mode python -m tgpt2 interactive

Instead of python -m tgpt2, ypu can as well use just tgpt2

Developer Docs

  1. Generate a quick response
from tgpt2 import TGPT
bot = TGPT()
resp = bot.chat('<Your prompt>')
print(resp)
# Output : How may I help you.
  1. Get back whole response
from tgpt2 import TGPT
bot = TGPT()
resp = bot.ask('<Your Prompt')
print(resp)
# Output
"""
{'completion': "I'm so excited to share with you the incredible experiences...", 'stop_reason': None, 'truncated': False, 'stop': None, 'model': 'llama-2-13b-chat', 'log_id': 'cmpl-3NmRt5A5Djqo2jXtXLBwJ2', 'exception': None}
"""

Stream Response

Just add parameter stream with value true.

  1. Text Generated only
from tgpt2 import TGPT
bot = TGPT()
resp = bot.chat('<Your prompt>', stream=True)
for value in resp:
    print(value)
# output
"""
How may
How may I help 
How may I help you
How may I help you today?
"""
  1. Whole Response
from tgpt2 import TGPT
bot = TGPT()
resp = bot.ask('<Your Prompt>', stream=True)
for value in resp:
    print(value)
# Output
"""
{'completion': "I'm so", 'stop_reason': None, 'truncated': False, 'stop': None, 'model': 'llama-2-13b-chat', 'log_id': 'cmpl-3NmRt5A5Djqo2jXtXLBwJ2', 'exception': None}

{'completion': "I'm so excited to share with.", 'stop_reason': None, 'truncated': False, 'stop': None, 'model': 'llama-2-13b-chat', 'log_id': 'cmpl-3NmRt5A5Djqo2jXtXLBwJ2', 'exception': None}

{'completion': "I'm so excited to share with you the incredible ", 'stop_reason': None, 'truncated': False, 'stop': None, 'model': 'llama-2-13b-chat', 'log_id': 'cmpl-3NmRt5A5Djqo2jXtXLBwJ2', 'exception': None}

{'completion': "I'm so excited to share with you the incredible experiences...", 'stop_reason': None, 'truncated': False, 'stop': None, 'model': 'llama-2-13b-chat', 'log_id': 'cmpl-3NmRt5A5Djqo2jXtXLBwJ2', 'exception': None}
"""

Note : At the time of wriiting this, Chatting conversational is not supported

Acknowledgements

  1. tgpt
  2. You

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

tgpt2-0.0.5.tar.gz (13.4 kB view hashes)

Uploaded Source

Built Distribution

tgpt2-0.0.5-py3-none-any.whl (13.0 kB view hashes)

Uploaded Python 3

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