Giter Site home page Giter Site logo

petermartens98 / openai-rick-and-morty-chatbot-jupyter-notebook Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 5 KB

This Python script uses pandas to read a Rick and Morty script CSV. It generates AI responses using OpenAI's Completion API. Morty suggests adventures, cleaning the spaceship, planet choices, music preferences, and bringing Jessica. Rick's witty responses create a humorous and dynamic dialogue.

Jupyter Notebook 100.00%
openai python morty rick

openai-rick-and-morty-chatbot-jupyter-notebook's Introduction

OpenAI-Rick-and-Morty-ChatBot

Python script that demonstrates a conversation between two characters, Rick and Morty, using dialogue from the TV show "Rick and Morty." The script utilizes the pandas library to read a CSV file containing a dataset of Rick and Morty script lines.

First, the necessary imports are made, including importing pandas as pd and setting up the OpenAI API key. Then, the script reads the CSV file using pd.read_csv() and stores it in the variable df. The dataframe is then printed, displaying the contents of the dataset.

Next, a function named "model" is defined, which takes a prompt as input and uses OpenAI's Completion API to generate a response based on the prompt. The function returns the generated response text.

After that, a conversation between Rick and Morty is constructed using a for loop that iterates through the rows of the dataframe. If the name in a row is either "Morty" or "Rick," their corresponding dialogue line is appended to the text variable. The loop breaks after reaching the 100th row.

The prompt for the conversation is set to the constructed text. Then, a while loop begins, prompting the user (representing Morty) to input their dialogue. Morty's input is appended to the prompt, followed by "Rick:" to indicate Rick's turn. The model function is called with the prompt, and the generated response is printed as Rick's dialogue. If the user inputs "bye," the loop terminates, and Rick delivers a closing message.

The conversation provided in the example showcases an exchange between Morty and Rick, where Morty suggests going on an adventure, offers to clean Rick's spaceship, discusses picking a planet, and suggests listening to country music and bringing Jessica along. Rick rejects some of Morty's suggestions, leading to a humorous and dynamic dialogue.

openai-rick-and-morty-chatbot-jupyter-notebook's People

Contributors

petermartens98 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.