Code Monkey home page Code Monkey logo

character-ai-bindings's Introduction

character-ai-bindings

Description

Small API to access character ai chatrooms directly from Python

This API uses selenium to interact with character.ai and provides simple methods to send user text and receive AIs answers!

Requirements

You need to have Chrome or Chromium installed somewhere where the undetected_chromedriver library can easily find it. You also need Poetry to easily download dependencies and build a python wheel that you can install with pip (see next section)

Installation

This project uses poetry to easilly build and package the library.

To build this project into a python wheel you can install you must first have Poetry. Then you must build the project from within the root folder after having cloned the repository.

git clone https://github.com/plouvart/character-ai-bindings
cd character-ai-bindings
poetry build

Once built, the python wheel will be available in the dist/ folder To install it, just do:

pip install dist/character_ai_bindings-0.1.0-py3-none-any.whl

I may host the project on pypi if enough people are interested :)

Usage

Here's a short code snippet demonstrating how to use the API. You need an account at character.ai

from character_ai_bindings.chatroom import ChatRoomServer

server = ChatRoomServer(
	username = "mr_kitty_cat",
	password = "p@ssw0rd",
)

# Instantiate a chatroom with GLaDOS and Steve AIs
# You need to use the url of the chatroom on character.ai website
glados = server.create_chatroom(
	chatroom_name = "GLaDOS",
	url = "https://beta.character.ai/chat?char=uqNQFjKGz4wbqj6A2XoNjrWUq0yQQdKgHkI92aZxsxA",
)
steve = server.create_chatroom(
	chatroom_name = "Steve",
	url = "https://beta.character.ai/chat?char=if4F8RpPbbzyez8M39tO6FCBmadFaDQdhzKRezAYfi0",
)

# Ask them a question
print(
	"Glados response:",
	glados.ask("Wanna do some science stuff together, GLaDOS?"),
)
print(
	"Steve's response:",
	steve.ask("Found any diamonds today, Steve?"),
)

# Delete the chatrooms
glados.delete()
steve.delete()

Next is up to you! You may even have characters speak with each other if you want to :p

Limitations

  • May fail without much debug info
  • Slow. But that's because character.ai may not be easily accessed with a bot

Credits

  • character.ai devs
  • poetry devs
  • selenium devs
  • undetected_chromedriver devs

character-ai-bindings's People

Contributors

plouvart avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.