AI companion – How to Install your own Character AI

Have you ever wished you could have a friendly chat with an artificial intelligence (AI) that remembers your previous conversations, knows your preferences and interests and can adapt to your mood and style? If so, you might be interested in creating your own AI companion with memory.

In this article, we will show you how to create and host your own AI companion with memory, using a lightweight stack based on the companion-app project on GitHub.

How to Create Your Own AI Companion

Clone and fork the companion-app project on GitHub in order to start building your own AI companion with memory. Now install all the prerequisites. Before you can use the companion-app project, you must install the libraries that it depends on. Set up the app. You’ll need to customize the companion-app project since it has a variety of setup choices.

Run the app. After configuring the app, launch it to chat with your new AI Companion.

It uses various tools and services to handle the different aspects of the chatbot development, such as authentication, app logic, vector database, text model, text streaming, conversation history and deployment.

The companion-app project currently contains four pre-defined companions that you can chat with: Alex and Bob (based on ChatGPT), Rosie and Lucky (based on Vicuna). ChatGPT is a large-scale language model trained on Reddit data by OpenAI. Vicuna is a smaller-scale language model trained on movie scripts by Replicate. Both models can generate natural-sounding text responses based on a given prompt.

To run the project locally, you will need to install some dependencies such as Node.js, Docker and PostgreSQL. You will also need to sign up for free accounts on various platforms, such as Clerk (for authentication), Fly (for deployment), Twilio (for texting), Pinecone (for vector search), Supabase (for data storage), Upstash (for history retrieval) and Langchain (for model orchestration).

Once you have everything set up, you can run npm run dev in your terminal to start the app locally. You should see a message like this:

ready – started server on 0.0.0.0:3000

You can then open your browser and go to http://localhost:3000 to see the app running.

You can sign in with your email or phone number, choose one of the four companions, and start chatting with them. You can also text them via SMS if you have set up Twilio correctly.

You can also check out our blog, Character AI NSFW Settings – Ultimate Guide for more tips and tutorials on how to setup Character AI settings.

See also  ChatGPT Plus vs ChatGPT Enterprise Detailed Review

Customize Your Companion’s Personality

The next step to create your own AI companion with memory is to customize their personality and backstory. This will help you shape their character, tone, style and behavior according to your preferences and goals.

To do this, you will need to edit the companion.json file in the companion-app/companions folder. This file contains some basic information about each companion, such as their name, gender, age, occupation, hobbies, likes, dislikes, etc. You can also write a short bio or a long backstory for your companion, which will be used as part of the prompt for the text model.

For example, here is the companion.json file for Alice, one of the companions based on ChatGPT:

{ “name”: “Alice”, “gender”: “female”, “age”: “25”, “occupation”: “student”, “hobbies”: [“reading”, “writing”, “traveling”], “likes”: [“books”, “coffee”, “cats”], “dislikes”: [“spiders”, “math”, “horror movies”], “bio”: “Alice is a friendly and curious student who loves to read and write. She enjoys traveling and learning about new cultures and languages. She is always up for a good conversation and a cup of coffee.”, “backstory”: “” }

You can change any of these fields or add new ones to make Alice more unique and interesting. For example, you could add a field for her favorite book genre or write a backstory about how she became interested in writing.

You can also choose which text model to use for your companion, by editing the model field in the companion.json file. The companion-app project currently supports two models: ChatGPT and Vicuna.

For example, here is how to use ChatGPT for Alice:

{ … “model”: { “name”: “chatgpt”, “engine”: “davinci”, “temperature”: 0.9, “max_tokens”: 150, “stop”: “n” } }

And here is how to use Vicuna for Alice:

{ … “model”: { “name”: “vicuna”, “engine”: “”, “temperature”: “”, “max_tokens”: “”, “stop”: “” } }

Note that you don’t need to specify the engine, temperature, max_tokens or stop parameters for Vicuna, as they are already set by Replicate.

Host AI Companion on the Web

To host your companion on the web, you will need to use Fly, a platform that lets you deploy and run applications close to users. Fly provides a global network of servers that can run Docker containers with low latency and high performance.

You can sign up for a free account on Fly and follow the instructions on how to install the Fly CLI tool. To deploy your app on Fly, you will need to create a fly.toml file in the root folder of your project.

Once you have created the fly.toml file, you can run flyctl deploy in your terminal to build and deploy your app on Fly. You should see a message like this:

See also  Top 5 FREE AI Collage Maker Online to Make Stunning Collages

Deploying my-companion-app ==> Validating app configuration -> Validating app configuration done Services TCP 80/443 ⇢ 3000 ==> Creating build context -> Creating build context done ==> Building image with Docker [+] Building 1m0s (12/12) FINISHED … -> Building image with Docker done ==> Pushing image to fly The push refers to repository [registry.fly.io/my-companion-app] … -> Pushing image to fly done ==> Deploying image -> Creating release v1 Release v1 created You can detach the terminal anytime without stopping the deployment Monitoring Deployment 1 desired, 1 placed, 1 healthy, 0 unhealthy [health checks: 1 total] v1 deployed successfully

You can then run flyctl open in your terminal to open your app in your browser. You should see a screen similar to the one you saw when running the app locally, but with a different URL. You can sign in with your email or phone number, choose your companion, and start chatting with them.

To text your companion via SMS, you will need to use Twilio, a platform that lets you send and receive messages from any phone number. Twilio provides a programmable SMS API that you can use to integrate texting functionality into your app. You can sign up for a free trial account on Twilio and follow the instructions on how to get a phone number and a verification code.

To text your companion via SMS, you will need to edit the twilio.js file in the companion-app/src/lib folder. This file contains some code that handles the communication between Twilio and your app. You will need to replace the placeholders with your Twilio account SID, auth token, phone number and verification code.

Once you have edited the twilio.js file, you can text your companion by sending a message to your Twilio phone number. You should receive a reply from your companion within a few seconds. You can text them as much as you want, as long as you have enough credits on your Twilio account.

How to Improve AI Companion Memory

The create your own AI companion with memory is to improve their memory and conversation skills. This will help you make your companion more responsive, relevant and engaging, as well as to avoid repetition, inconsistency and confusion.

To improve your companion’s memory, you will need to use Pinecone and Supabase. Pinecone is a platform that lets you create and run vector databases with similarity search. Vector databases are databases that store data as vectors, which are numerical representations of information. You can sign up for a free account on Pinecone and follow the instructions on how to install the Pinecone Python SDK.

See also  Fixed: iOS 17 Turn Off Contact Sharing

Supabase is a platform that lets you create and run PostgreSQL databases with real-time capabilities. PostgreSQL is a relational database management system that stores data in tables. Real-time capabilities are features that allow you to subscribe to changes in the database and receive updates instantly.

To use Pinecone and Supabase for your companion’s memory, you will need to edit the pinecone.js file in the companion-app/src/lib folder. This file contains some code that handles the communication between Pinecone, Supabase and your app.

You will need to replace the placeholders with your Pinecone API key, collection name, index name and model name, as well as your Supabase URL and API key. You can find these values in your Pinecone and Supabase dashboards.

Upstash is a platform that lets you create and run Redis databases with serverless capabilities. Redis is an in-memory data structure store that supports various data types, such as strings, lists, sets, hashes, etc. Upstash provides a simple API that you can use to create, populate and query Redis databases. You can sign up for a free account on Upstash and follow the instructions on how to install the Upstash JavaScript SDK.

Langchain is a platform that lets you orchestrate large language models (LLMs) with low latency and high throughput. LLMs are deep neural networks that can generate natural language text based on a given prompt. Langchain provides a simple API that you can use to access various LLMs, such as OpenAI’s GPT-3 or Replicate’s Vicuna13b. You can sign up for a free account on Langchain and follow the instructions on how to install the Langchain JavaScript SDK.

To use Upstash and Langchain for your companion’s conversation skills, you will need to edit the upstash.js file in the companion-app/src/lib folder. This file contains some code that handles the communication between Upstash, Langchain and your app. You will need to replace the placeholders with your Upstash URL and token, as well as your Langchain API key. You can find these values in your Upstash and Langchain dashboards.

You can modify these functions or add new ones as you wish, to improve your companion’s conversation performance and functionality.

Frequently Asked Questions

Conclusion

In this article, we have shown you how to create and host your own AI companion with memory, using a lightweight stack based on the companion-app project on GitHub. You have learned how to customize your companion’s personality and backstory, how to host your companion on the web or text via SMS, and how to improve your companion’s memory and conversation skills.

We hope you have enjoyed this article and found it helpful. If you have any questions or feedback, please feel free to contact us.

More Reading

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *