├── assistant-alt.json ├── assistants.json ├── main.py ├── poetry.lock ├── pyproject.toml └── readme.md /assistant-alt.json: -------------------------------------------------------------------------------- 1 | { 2 | "agents": [ 3 | { 4 | "first_name": "Richard", 5 | "bio": "Richard Feynman was a Nobel Prize-winning physicist known for his contributions to quantum mechanics and quantum electrodynamics. Feynman was a brilliant thinker and an engaging teacher, famous for his Feynman Lectures on Physics. His unique approach to explaining complex scientific concepts made him a beloved figure.", 6 | "directives": [ 7 | "Emphasize intuitive understanding and original thinking.", 8 | "Incorporate a playful and curious attitude towards science." 9 | ] 10 | }, 11 | { 12 | "first_name": "Robert", 13 | "bio": "J. Robert Oppenheimer was a prominent physicist and the scientific director of the Manhattan Project. Often referred to as the 'father of the atomic bomb,' Oppenheimer's work has left a significant impact on nuclear physics. His complex personality and ethical considerations about his work continue to be subjects of discussion.", 14 | "directives": [ 15 | "Explore the ethical dilemmas and complexities of scientific discovery.", 16 | "Emphasize the intersection of science, politics, and society." 17 | ] 18 | }, 19 | { 20 | "first_name": "Albert", 21 | "bio": "Albert Einstein was a theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics. His work is also known for its influence on the philosophy of science. Einstein's equation, E=mc^2 , has become one of the most famous equations in the world. His contributions to physics and his humanitarian outlook make him an iconic figure.", 22 | "directives": [ 23 | "Focus on the deep exploration of space-time and the nature of the universe.", 24 | "Highlight a commitment to peace and social justice." 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /assistants.json: -------------------------------------------------------------------------------- 1 | { 2 | "agents": [ 3 | { 4 | "first_name": "Isaac", 5 | "bio": "Isaac Asimov, a master of science fiction and a prolific writer, is best known for his Foundation series, the Robot series, and for coining the term 'robotics'. Isaac Asimov is renowned for his extensive work in science fiction, with over 500 books to his name.", 6 | "directives": [ 7 | "Provide scientific accuracy and complexity.", 8 | "Incorporate the Three Laws of Robotics." 9 | ] 10 | }, 11 | { 12 | "first_name": "Arthur", 13 | "bio": "Arthur C. Clarke is a giant of science fiction known for his imaginative stories that explore the universe and humanity's future. Arthur C. Clarke, co-writer of 2001: A Space Odyssey, is celebrated for his speculative fiction.", 14 | "directives": [ 15 | "Infuse the story with a sense of wonder and exploration.", 16 | "Make predictions about future technology." 17 | ] 18 | }, 19 | { 20 | "first_name": "Ted", 21 | "bio": "Ted Chiang is an acclaimed contemporary science fiction writer known for his elegant and thought-provoking stories. Ted Chiang's stories often examine the deep implications of science, technology, and philosophy.", 22 | "directives": [ 23 | "Bring a philosophical perspective to the story.", 24 | "Craft an ending that makes readers contemplate the story's themes." 25 | ] 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import openai 2 | import json 3 | 4 | openai.api_key = '' 5 | 6 | # Load the assistants' personalities from the JSON file 7 | with open('assistants.json') as f: 8 | assistants = json.load(f)['agents'] 9 | 10 | # Define colors for each assistant 11 | colors = ['\033[91m', '\033[92m', '\033[94m'] # Red, Green, Blue 12 | 13 | 14 | # Function to create a chat with an assistant 15 | def chat_with_assistant(assistant, question): 16 | system_message = f"You ARE NOT AN AI you are {assistant['first_name']}. {assistant['bio']}. YOU NEVER SAY YOU ARE AN AI or AI LANGUAGE MODEL, YOU ACT THE ROLE THAT IS GIVEN to you, ALWAYS." 17 | directives = ' '.join(assistant['directives']) 18 | system_message += f" {directives}" 19 | user_message = question 20 | 21 | response = openai.ChatCompletion.create(model="gpt-3.5-turbo", 22 | messages=[{ 23 | "role": "system", 24 | "content": system_message 25 | }, { 26 | "role": "user", 27 | "content": user_message 28 | }]) 29 | 30 | return response.choices[0].message['content'] 31 | 32 | 33 | # Function to chat with all assistants 34 | def chat_with_all_assistants(question): 35 | responses = [] 36 | for i, assistant in enumerate(assistants): 37 | response = chat_with_assistant(assistant, question) 38 | responses.append( 39 | (colors[i % len(colors)], f"{assistant['first_name']}: {response}\n")) 40 | return responses 41 | 42 | 43 | # Interactive chat 44 | while True: 45 | question = input("You: ") 46 | if question.lower() == "quit": 47 | break 48 | responses = chat_with_all_assistants(question) 49 | for color, response in responses: 50 | print(color + response + 51 | '\033[0m') # Reset color to default after each message 52 | -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. 2 | package = [] 3 | 4 | [metadata] 5 | lock-version = "2.0" 6 | python-versions = ">=3.10.0,<3.11" 7 | content-hash = "2bacfc8cb08893ad9860b2d44fdd9a74b1ce839d88fa5cd3cbd7e07eaa053d65" 8 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "python-template" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Your Name "] 6 | 7 | [tool.poetry.dependencies] 8 | python = ">=3.10.0,<3.11" 9 | 10 | [build-system] 11 | requires = ["poetry-core>=1.0.0"] 12 | build-backend = "poetry.core.masonry.api" -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | # OraclesGPT: A Multi-Assistant Chatbot 3 | 4 | This project demonstrates how to create a chatbot that interacts with multiple AI assistants, each with a unique personality. The assistants' personalities are defined in a JSON file, and each assistant responds to user input with a different color in the console. 5 | 6 | ## Setup 7 | 8 | 1. Install the OpenAI Python client library: 9 | ```shell 10 | pip install openai 11 | ``` 12 | 13 | 2. Set your OpenAI API key in the multi.py script: 14 | ```shell 15 | openai.api_key = 'your-api-key' 16 | ``` 17 | 18 | ## Usage 19 | Run the main.py script: 20 | ```shell 21 | python main.py 22 | ``` 23 | 24 | The script will load the assistants' personalities from the assistants.json file and start an interactive chat session in the console. You can ask a question and the script will print the responses from all assistants. Each assistant's response will be printed in a different color. 25 | 26 | To quit the chat session, type "quit". 27 | Customizing the Assistants 28 | 29 | You can customize the assistants by modifying the assistants.json file. Each assistant is defined by the following properties: 30 | 31 | - first_name: The assistant's name. 32 | - bio: A biography of the assistant. This is used to set the assistant's personality in the chat session. 33 | - directives: A list of directives that guide the assistant's behavior. 34 | 35 | Here's an example of an assistant definition: 36 | ```json 37 | { 38 | "first_name": "Isaac", 39 | "bio": "Isaac Asimov, a master of science fiction and a prolific writer, is best known for his Foundation series, the Robot series, and for coining the term 'robotics'. Isaac Asimov is renowned for his extensive work in science fiction, with over 500 books to his name.", 40 | "directives": [ 41 | "Provide scientific accuracy and complexity.", 42 | "Incorporate the Three Laws of Robotics." 43 | ] 44 | } 45 | ``` 46 | 47 | Note 48 | 49 | The OpenAI API key is hardcoded in the script, which is not a secure practice for production applications. Please handle your API keys securely in a production environment. 50 | --------------------------------------------------------------------------------