Giter Club home page Giter Club logo

parse_context's Introduction

parse_context

This program uses the OpenAI API, powered by GPT-3, to power the logic of a context-based active-listening voice assistant. The context of this software is:

  • Humans have a conversation, which is recorded and transcribed in real time.
  • (THIS PROGRAM) The conversation is sent to the OpenAI API along with a few-shot list of examples. The API returns a detected context, suggestions for what outputs would be useful to the humans, and a list of data sources for achieving those outputs.
  • The voice assistant presents the data to the user to augment the conversation.

Requirements

  • Python 3
  • OpenAI Python Client
  • OpenAI API key

Installation

API Key Setup

First, set up your API key:

export OPENAI_API_KEY='sk-<your key here>'

To make it persistent,

echo "export OPENAI_API_KEY='sk-<your key here>'" >> ~/.bashrc && source ~/.bashrc

Python and Packages Setup

Install Python. Install Pip for Python3. Then run:

pip3 install -r ./requirements.txt

To update the requirements file after changing, you can use:

pip3 freeze > ./requirements.txt

Or

pip3 freeze | grep openai > ./requirements.txt

Usage

Non-interactive mode (default)

To use non-interactive mode, make sure the INTERACTIVE flag at the top of parse_context.py is set to False.

Then, run the program while passing your conversation to standard input (STDIN). For example, if the above conversation were placed in a file located at ./conversations/tech_stack.txt, we could run:

cat ./conversations/tech_stack.txt | python3 parse_context.py

The result will be printed to STDOUT (default is the terminal window).

Interactive Mode

To use interactive mode, make sure the INTERACTIVE flag at the top of parse_context.py is set to True.

Then, run python3 parse_context.py. You can enter the conversation on the command line in the following format, using /end to stop.

A: Hey, what tech stack do you think we should use for the new app?
B: What app?
A: The dating app we are developing. It needs to be cross-platform mobile.
B: Oh, okay. Um... I don't really know any good frameworks
/end

And the result will be printed to STDOUT.

Examples of AI Output

For each example, the format is:

input
AI output

Talking about an actor

A: I watched Terminator last night.
B: Oh, cool! I love that movie, it's a classic.
A: Arnold Schwarzenegger was so good.
B: Yeah, I agree.
Context: A group of people are talking about a film
Useful Output: Information about Arnold Schwarzenegger filmography
Relevant Data Sources: Query Google Search for "Arnold Schwarzenegger filmography"

Going to Dinner

A: Hey Mike, let's get dinner tonight.
B: Okay, sure! What restaurants do you know in the area?
Context: Two friends are trying to decide what to eat for dinner
Useful Output: List of restaurants nearby, restaurant reviews, restaurant menus
Relevant Data Sources: Query Foursquare API for restaurants, query Yelp API for reviews, query OpenTable API for restaurant menus

Developing an App

A: Hey, what tech stack do you think we should use for the new app?
B: What app?
A: The dating app we are developing. It needs to be cross-platform mobile.
B: Oh, okay. Um... I don't really know any good frameworks
Context: Two people are discussing the development of a new cross-platform mobile application
Useful Output: List of popular frameworks
Relevant Data Sources: Query Stack Overflow website for most popular frameworks.

Cooking a Meal

A: Hey, what do you think we should cook for dinner tonight?
B: Dunno. Let's check the fridge.
A: Okay. Looks like we've got chicken, beef, lettuce, rice, mustard, mayo, taco shells, and corn.
B: How about tacos?
Context: Two people are talking about dinner
Useful Output: Ingredients, recipe, estimated cooking time
Relevant Data Sources: Query Google Search for "recipes with chicken, beef, lettuce, rice, mustard, mayo, taco shells, and corn", query Google Maps API for local grocery stores

License

This is released under the MIT License.

Legal

Please refer to the OpenAI website for information regarding the legal and copyright status of content produced by GPT-3. By using this software, you agree that as the repository author, Radu Vasilescu, I am not responsible for any content produced by this software, including completions and model output. All content/media produced with this software must be attributed to the person or company who produced the output-- not me, and not OpenAI. I hereby release the content of this document as well as the examples included herein to the public domain.

parse_context's People

Contributors

vasilescur 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

Watchers

 avatar  avatar  avatar

parse_context's Issues

Incorrect / incomplete output in README.md

The 3rd example in Developing an App does not have a correct / desired output.

Developing an App

A: Hey, what tech stack do you think we should use for the new app?
B: What app?
A: The dating app we are developing. It needs to be cross-platform mobile.
B: Oh, okay. Um... I don't really know any good frameworks
A: Hey, what tech stack do you think we should use for the new app?
B: What app?
A: The dating app we are developing. It needs to be cross-platform mobile.
B: Oh, okay. Um... I don't really know any good frameworks

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.