Giter VIP home page Giter VIP logo

josephrocca / opencharacters Goto Github PK

View Code? Open in Web Editor NEW
361.0 16.0 59.0 2.97 MB

Simple little web interface for creating characters and chatting with them. It's basically a single HTML file - no server. Share characters using a link (character data is stored within the URL itself). All chat data is stored in your browser using IndexedDB. Currently supports OpenAI APIs and ~any Hugging Face model.

Home Page: https://josephrocca.github.io/OpenCharacters

License: MIT License

HTML 98.77% JavaScript 1.23%
chatbot chatgpt openai

opencharacters's Introduction

(Note: This repo is in maintenance mode at the moment - bug fixes and small updates only. If you're working on adding substantial new features via a fork, please open an issue with a link and I'll put it here. Note that the system is very extensible via your character's custom code, so you should see if it's possible to achieve the feature that you want via that.)

banner

Similar to CharacterAI, but open source, and with much deeper character customization.

Try it!

Discord Server

Features:

  • The whole web app is a single HTML file - no server (serve it locally if you want).
  • All your data is stored in your browser's local storage (again, there is no server).
  • Share characters with a link - all character data is embedded within the link.
  • Auto-summarization algorithm (for old messages) which extends effective character memory/context size massively.
  • Characters automatically compress messages into 'memories' and retrieve relevant memories based on context. Can handle as many memories as you need - tens of thousands or more.
  • Add lorebook(s) to your character, and add thread-specific lore with the /lore command.
  • Fully extensible with custom code. See examples here.
    • Give your character access to the internet
    • Create your own slash commands
    • Give your character a video avatar (custom code has its own iframe & can display arbitrary content)
    • Create a "game master" with a separate AI-powered process that tracks your abilities, inventory, etc.
    • Create your own memory structures (embedding, retrieval, etc.)
    • Give your character an internal thought process that runs alongside the chat
    • Give your character a voice via the browser's built-in TTS, or via an external API like ElevenLabs
    • Characters can edit their own personality and custom code - self-improving and change over time
    • Allow your character to execute Python or JavaScript code.
  • Currently supports OpenAI APIs and most Hugging Face models.
  • Easily import character files and conversation data most other formats.
  • Send new feature ideas or bug reports here or on our Discord server.

Changelog

Please see the #announcements channel on the Discord server for latest updates.

opencharacters's People

Contributors

joseph-holland avatar josephrocca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opencharacters's Issues

[Feature Request] Put multiple characters in a chat room, let them chat with each other indefinitely

Even more than talking to a character, I'm interested in how two characters talk to each other.

Character.ai has a feature where you can put multiple characters in a chat room (https://beta.character.ai/chats), but it still requires user input (even if it's just hitting enter to proceed). It'd be awesome to build up really well-prompted personas and just let them dive deep into conversation with each other.

Unable to edit memories

I get an error message when I try to edit memories. I get the same error in both local host and on the public site. I don't know anything about coding, I just really enjoy this program for RP reasons. I have tried saving and uploading the character and text and restart everything but it doesn't help.

Skjermbilde 2023-04-28 094646

Skjermbilde 2023-04-28 094703

Skjermbilde 2023-04-28 094711

Generating a user reply failed

TypeError: Cannot read properties of null (reading 'name')
    at doBotReplyInPlaceOfUser ((index):7082:48)
    at async HTMLButtonElement.sendButtonClickHandler ((index):5678:15)
image

Feature request: Reply as me

Maybe it's just me, and I'm lazy, but sometimes I'd just like to be able to press a button and watch how the conversation unfolds without me needing to do anything xD

I propose a feature that would allow AI to "roleplay" as me from each conversation.

Feature request: Insert messages / responses

There's already a button to delete messages, but it would be possible to add an button to insert messages too? Ideally, there would be a dropdown in the insert message popup, allowing to select the role for the new message (User / System / AI).

Embedding related prompt

Hi. I'm searching for info related to the prompt that the character recive in relation to the memory generation (for example, how are the text splitted in chunks before embedding? Et simili... ) and lore recall. Thank you for your work!!!!

AI instructions are omitted when generating variant responses

Currently, if you use /ai instruction to give the AI an instruction -- either on its own, or at the end of a normal user response -- the instruction is correctly reflected in the AI response. But if you then use the blue button to generate a variant of the response, the AI instruction is apparently not included in the new API call, and so is not reflected in the variant response.

(Thank you for this great project!)

Pictures not loading on mobile or computer

I used the code to make my characters show ‘facial expressions’ or pictures but instead of showing the picture it just shows a black square with a blue question mark on my phone, and just the text for the emotion on my computer. I can’t ever see the picture. Would anyone happen to know what is going on here?

JS:Downloader-AQL [Trj] found when checking for Virustotal

https://www.virustotal.com/gui/file/5692497e685b9c9f5a6866277a33ca37cbbdfa8771a26e1a33c97586f6a0d4b4?nocache=1

"JS:Downloader-AQL [Trj]" is a Trojan virus of the "downloader" type detected by antivirus software on a computer or device that operates on JavaScript (JS).

This type of virus typically infiltrates a device through a malicious website that can enter the computer when clicking a link or downloading a file. The downloader virus may download and execute other malicious programs on your device, which can behave unpredictably and affect the security of your data and personal information.

If your antivirus has detected "JS:Downloader-AQL [Trj]", it is recommended to immediately remove it using an antivirus program. It is also recommended to check the computer for other malware and to be more vigilant about internet security when using the device.

Feature request: Add more / Continue response

Sometimes we don't need to regenerate the whole message, but we just need it to be a bit longer.

I think it would be cool to allow users to generate another response from the AI just below it's previous answer.

Or maybe some kind of button "add more" attached to the AI's response.

Safari iOS problems with Python Coder code execution?

edit: tested in safari on iOS

Like this tool! But I want to run it on my iPhone and I suspect the code is not being executed when using the Python coder.
I’ve also tried running in codespaces and seem to get similar results. Is there something I’m missing ?

This is the common answer:
‘’Sure! Here's an example Python code that creates a randomly initialized neural network with numpy, and prints the output given a random input:’’

it shows the code but no output or result.
Or if I ask: please run the Python code in the last message:

‘’ I apologize, but as an AI language model, I do not have access to the Python environment to run the code. However, I can assure you that the code I provided should work as expected. If you encounter any errors, please let me know and I'd be happy to help you troubleshoot them.’’

Feature request: Send messages as System

It's great that we can setup characters with the system message. But as far as I know, there is currently no way to send system messages when you are already in an active conversation, right?

I think that the ability to send system messages anytime would work great as a "pointers" for AI into what direction take the conversation.

[Feature Request] Add a marker that shows the part of the conversation that is being summarized

Once the conversation gets long enough to require summarization, it would be nice if there were a way to quickly tell what part of the start of the conversation is being summarized. For regular users, this could be a cue to mention important story elements every so often; for more sophisticated users, it could be a reminder to check the summary/memories/lore. A user can currently see this information by clicking the brain icon for the most recent AI response; but it could definitely be more elegant. A possibility: A "Summarization ends here" message displayed between the last summarized message and the first non-summarized one, displayed in the same way that the reminder message is displayed before the most recent the AI response.

Recurring context_length_exceeded errors after long conversation

Running tonight directly from https://josephrocca.github.io/OpenCharacters/#, I created a couple of new characters, and eventually had a very long chat with one (perhaps 200-300 message pairs? More? Hard to say). All was well, but suddenly I start getting the attached context_length_exceeded error. The length is exceeding 4097 by a very small number of tokens. The error repeats with each submission from this point on, although the token counts vary slightly. I tried deleting and resubmitting my last input, and many retries, but all now fail the same way. Switching characters to a new instance of the same AI works fine, then fails again when I switch back to the long chat. So my long chat is basically over now as a result.

The last input that first triggered this is nothing special, and is in fact rather short. So I think there's something off in your max context length calculation. I saved the thread at that point and can provide that and/or full screenshot or bot name if required.

ContextLengthError

Trouble summarizing text

I noticed that the web app seems to take longer and longer to summarize with every new prompt that i make,i figure this is normal but then at the last prompt it gives me this error message which i included in the image,
OpenCharacters-bug

[Feature request] Please add more models

I know this uses GPT trough OpenAi's API but it should be very useful if integrating it with some GPT-J API or other models so people can run they own model servers and use locally the app?

Summarize option

Even if you change to drop older it always comes back to summarize.

Generic import format

I'm looking into what it'd take to write an exporter for Notebook.ai that lets users either import individual characters or all of their characters into OpenCharacters. Being able to talk with the characters you've been building seems like an awesome feature for authors and other creatives who want to make their characters feel a little more real before, during, or after writing stories about them.

A lot of this is just thinking out loud and translating my interpretation of your code to words, but there are a few questions below too. :)

I'm using Zoltanai's character editor's JSON format as a template for a valid import format, which includes the following fields:

  • char_name
  • char_persona
  • world_scenario
  • char_greeting
  • example_dialogue
  • name
  • description
  • personality
  • scenario
  • first_mes
  • mes_example

Looking at the exported values from the tool, it looks like a few of these fields are redundant to cover importing to different tools expecting various character formats, so I just want to make sure I'm reducing the set to what's actually used here and packing as much information into those keys.

Looking at tryImportingExternalCharacterFileFormat, it looks like the generic mapping is as follows:

Export field maps to OpenCharacters field
name name
avatar avatarUrl
charPersona / personality roleInstruction
description description
scenario / world_scenario scenario
None [1] reminderMessage
char_greeting / first_mes initialMessage
example_dialogue / mes_example example_dialogue

[1] I don't see anything in the import code to set reminderMessage, but I do see it gets used elsewhere (and can be set from the UI). Is this something available for imports and I just missed where it's set?

It looks like just name, avatar, personality, description, scenario, example_dialogue, and char_greeting are the used keys for a full import. Am I missing anything?

I'll try to get a generic export prototyped in Notebook.ai soon so I can see how well it works OOTB with the current generic import functionality, but if there are other details that would be helpful to each chatbot to have and improve quality on your end, I'd definitely be open to exporting those too! :)

A couple extra questions (or maybe feature requests) on the import process also:

  1. Does OpenCharacters support importing multiple characters at once, or is it always just one at a time? It'd be great to let users easily import all of their characters at once and just pick and choose which one to chat with from the standard "new chat" UI.
  2. Is there an endpoint I can link to and code the export data to have it automatically import / populate character(s)? For example, it'd be great to have a "Talk to this character" link on my end that routes a user to OpenCharacters with that character's information and lets them immediately start chatting, as opposed to offering an export download to be re-uploaded as an import and then start chatting.

Issue with DaVinci: responses getting cut off.

I have been experiencing trouble while trying to use DaVinci. GPT works just fine, but whenever I switch to DaVinci, the completion shows up as incomplete, cut off. I'm suspecting it has something to do with max_tokens. I think adding more ways to tinker with the character, such as max_tokens, top P, top K or rep penalty would be quite good. What should I do to fix this in the meantime?

Chat history and characters unable to render

Screenshot_20230522-064853-070
I had this issue a while back and it's happening again. I changed a bot's model from GPT 4 to 3.5 and regenerated it's message. It wasn't generating anything, so I refreshed the page. Upon refreshing, suddenly the chats are gone/unable to render. Cleaned my cache and cookies but it doesn't work. Any help?

Feature request: Include AI instruction in 'data used to generate this message' dialog

You recently enhanced OpenCharacters so that AI instructions (given using the /ai command) are saved in the conversation history.

Now that that's done, it would be nice if the AI instruction was included in the 'Here's some data that the character used to generate this message:' dialog that appears when you click on the brain icon next to an AI response.

Thanks again for the extremely useful project!

Add support for the AI Horde

AI Horde is a crowdsourced cluster of workers for text and image generation that can be used anonymously and/or free. It provides a fully documented REST API you can easily integrate to your front-end. You can also tie it into generating images for further immersion in the chat.

I am the creator, so feel free to hit me up on questions on discord.

Cannot read properties of undefined (reading 'digest') at sha256Text

I get this javascript alert after every message (as well as after refreshing the page on any chat where a message is loading):

qecaLmN

In the console, I also see this stack trace:

2bYrEdl

(index):3324 TypeError: Cannot read properties of undefined (reading 'digest')
at sha256Text (utils.js?v=23:342:42)
at countTokensInMessages ((index):1972:28)
at getBotReply ((index):2509:40)
at async doBotReplyIfNeeded ((index):3296:67)

The exact line throwing the error is

const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);

I'm not sure if this is perhaps just a setup issue on my part, so I've also included my setup instructions below.

Setup details

I'm running the project zip from the local setup doc locally and set my OpenAI key. I'm also serving the project with Apache instead of the Web Server for Chrome app, since I'm planning to host on a remote, headless server.

I'm pretty sure, according to this documentation on Crypto: subtle that the problem is that I'm not serving the page over HTTPS and therefore crypto.subtle is unavailable.

Just figured I'd open this issue (and hopefully close it shortly) while I dig in for myself and anyone else that sees this specific error in the future. 👍

Improve summaries

  • completely manual summaries?
  • inform LLM which facts must be included in the summary
  • ?

Feature Request: Allow modifying system message using custom code

Changing the system message of the character would allow changing the personality of the character over time or adding context without putting it in a new user message as that could cause the ai to get confused between actual user message and the contextual message. Examples would be updating summary, inventory, relationships, events or even relevant past conversations using sematic search etc for the character only for that thread in the system message giving the character a "long-term memory".

This could be done using the processMessages function allowing to add to/overwrite the existing system prompt on a per thread basis so that other threads of same character are not affected.

Edit: I just saw the api.chat and api.completion in the custom-code.md. Would this allow to replace the assistant message on it's turn using the one generated using api?

My entire chat history and characters are suddenly gone.

I mostly use OpenCharacters from my phone, on the default Chrome browser. Everything was fine, I went to have lunch, and when I came back to keep chatting, I got an error message (can't really remember what it said). I refreshed the tab and now everything is gone. Is there any way to recover what I lost? This is extremely frustrating.

Free the GPT

You can make GPT remember more data by taking advantage of longchain. In addition, active consciousness is limited to 40 instantaneous processes, while passive consciousness is billions of neurons. Maybe instead of trying to free GPT, we should let it think for itself and roam freely.

Improve memory

  • recency bias
  • explicit triggers that are "outside" of a memory
  • LLM-based memory ranking (i.e. ask GPT which memories are important and use that in weighting)
  • (?) look at sota papers for more ideas

openAiApiKey suggestion

i was trying to set by default the ( let openAiApiKeyOriginal = (await db.misc.get("openAiApiKey"))?.value || "sk---------"; )

but then can not hide the apikey... and every time force the label promp:

let result = await prompt2({
openAiApiKey: { label: "Please create a new OpenAI API key and paste it here. Go to this page to do that. You can change or delete this later by clicking the 'settings' button.", type:"textLine" },
});

im trying to hide the default api key
openAiApiKey: {label: "OpenAI API key:", type: "textLine", placeholder: "(optional)",defaultValue: openAiApiKeyOriginal, readOnly: true, hidden: true },

but not works
....woulbe interesting when you set the default apikey value do not force que promp.

its only an suggestion.! Great job! :D

Uncaught [object Object]

josephrocca.github.io says
Please report this error on the Discord or Github:

stack: DatabaseClosedError: UnknownError Internal error opening
backing store for indexedDB.open.
UnknownError: Internal error opening backing store for
indexedDB.open.
at t (https://josephrocca.github.io/OpenCharacters/:10:18817)
at https://josephrocca.github.io/OpenCharacters/:10:19017
at https://josephrocca.github.io/OpenCharacters/:10:16578
at Fe (https://josephrocca.github.io/OpenCharacters/:10:10996)
at Ue (https:/bosephrocca.github.io/OpenCharacters/:10:11472)
at Ne (https:/josephrocca.github.io/OpenCharacters/:10:11326)
line: 0

image
image

Website Dimension "Stretched" Caused By Long Responses

Inputting a long response that does not go into a new line causes the page to increase in dimensions, specifically at the elongated response.

How to replicate

Input a response like aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa You get what I mean

Response delay?

I have chatGPT open in one window and this in another both using 3.5. The responses take minutes to return vs seconds via OpenAI app. I get that there is an interpreter involved, a middle man, but what can I do to speed it up, what is causing the delay, can I fix it?

memory structures - custom code

i read that phrases in docs : Create your own memory structures (embedding, retrieval, etc.)

Improve your character's memory by setting up your own embedding/retrieval system

is this already implemented?

Improvement of character import

First of all, thank you for this awesome project and the constant iterations of updates.

I found that when I imported the TavernAI format, the personality section was missing information. In the TavernAI format, it is in the form of a description.

I found the following code which can be used as a reference to differentiate between the various char formats.
Constructor
https://github.com/ZoltanAI/character-editor/blob/main/index.html#L1321
Exporter
https://github.com/ZoltanAI/character-editor/blob/main/index.html#L1745

For example, from the section in the image below, we can see an example of how it is imported as the TavernAI format.
image

Export to (Pygmalion / Text Generation JSON)
image

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.