Skip to content

clintmckenna/oTree_gpt

Repository files navigation

oTree GPT

This is a simple chat app for oTree that allows participants to chat with a predefined ChatGPT personality using OpenAI's API. Please feel free to leave any feedback or open an issue if you spot a problem. A short blogpost on using this app can be found here!

System Prompt

You can use the system prompt to adjust the tendencies of the personality you want participants to speak to. Here is an example system prompt:

embedded

And what this looks like when chatting:

embedded

The app is set to randomize participants to view one of two personalities. You can adjust these or provide more/less as desired.

API key

To use this, you will need to acquire a key from OpenAI's API. Add this as an environment variable to your local environment. If using on Heroku, you can use this command to add it to your application:


heroku config:add CHATGPT_KEY=sk-.....


OpenAI package requirements

When using locally, you will also need to install openai's Python package. Be sure to add this to your requrements.txt file before using online.


openai==0.27.0


Model Parameters

Currently, I have this set up to use gpt-3.5-turbo. You can adjust this model and the temperature in the _init_.py file:

embedded

Data Output

The text logs are saved in participant fields, but I also made a simple custom export function. This can be accessed in the "data" tab in oTree and will show the chat logs as a long-form csv.

Citation

As part of oTree's installation agreement, be sure to cite their paper:

  • Chen, D.L., Schonger, M., Wickens, C., 2016. oTree - An open-source platform for laboratory, online and field experiments. Journal of Behavioral and Experimental Finance, vol 9: 88-97.

If this app was helpful, you may consider citing this github repository as well.

About

Simple oTree app for interfacing a chat with OpenAI's API for ChatGPT.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published