Skip to main content

ChatBot API wrapper for https://public-api.travitia.xyz/talk

Project description

Travitia Talk

Async ChatBot API wrapper for https://public-api.travitia.xyz/talk

Installation

Travitia Talk is available on PyPi

pip install travitia_talk

Getting API key

Usage

Interactive session

python -m travitia_talk

Basic usage

import travitia_talk as tt

API_KEY = "SECRET_KEY"

chatbot = tt.ChatBot(API_KEY)
response = await chatbot.ask("How are you?")
print(response)
# I'm doing okay, you?

await chatbot.close()

Emotions

Travitia Talk supports multiple emotions

import random

emotion = random.choice(list(tt.Emotion))
response = await chatbot.ask("How are you?", emotion=emotion)

Contexts

It is possible to add context to query for more accurate answers (up to 2 answers currently). By default library uses in-memory context, but it is possible to define your own by using travitia_talk.Context.

Context looks up previous queries using an identifier. In case of discord bot this could be user id. Example:

@bot.command
async def cb(self, ctx, *, text: str):
    response = await ctx.bot.chatbot.ask(text, id=ctx.author.id)

    await ctx.send(response.text)

Custom session

It is possible to use custom aiohttp session with configured timeouts and other settings.

from aiohttp import ClientSession, ClientTimeout
import travitia_talk as tt

API_KEY = "SECRET_KEY"

chatbot = tt.ChatBot(API_KEY, session=ClientSession(timeout=ClientTimeout))

Custom API URL

In case URL gets changed for some reason or library adds support for other backends it is possible to overwrite API URL:

import travitia_talk as tt

API_KEY = "SECRET_KEY"

chatbot = tt.ChatBot(API_KEY, api_url="https://paid-api.travitia.xyz/talk")

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

travitia_talk-0.0.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

travitia_talk-0.0.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: travitia_talk-0.0.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for travitia_talk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 23295d42f9512ca14968201097be1e297c49da94023294db7b61e45745acb59e
MD5 58d7c91ff7005eaf63130b2a7aa2f6af
BLAKE2b-256 ced528c9737b7d71b117bb2a21c6214e30bae1b4bdb10c78495aa2d10fb38460

See more details on using hashes here.

File details

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

File metadata

  • Download URL: travitia_talk-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for travitia_talk-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 378a1b6f93013b98c9b85050af588008d8e41532f507e5b57ea21bdc2008831b
MD5 40d30de59a019fb257bedd179e8e8de8
BLAKE2b-256 9dd70f2b2483c1d17b7f257592870568e72ec4b3735271ec48edcd108f3630a4

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