#1
by
Chris_oTree
Hi all, I've built an AI model specifically for writing oTree code. (Although general models like ChatGPT are capable of writing code, they tend to do very random things when asked to write oTree code, e.g. confuse oTree with other frameworks and mix in all kinds of irrelevant code that will never work.) You need to use it inside an editor like Cursor, which has a free version: https://www.cursor.com/ You can either ask it to program a full game, e.g. "make me a live auction game", or get help in debugging your existing games. Setup instructions here: https://www.otreehub.com/code_assistant/ Let me know how it goes!
#2
by
Chris_oTree
By the way if you haven't used an AI-enabled code editor like Cursor before, I highly recommend giving it a try.
#3 by PatrickT
Could you possibly post some instructions on how to use the AI with Visual Studio Code?
#4
by
Chris_oTree
it's not possible, Visual Studio Code doesn't support custom AI backends. Only its own copilot.
#5
by
dwoods
Based on some usage, I would recommend setting the default behavior of the AI to always ask before making changes. It can get carried away and incorrectly change hundreds of lines of code, and it can be difficult to keep a track of where these are. In one case, it didn't even tell me it had done it - it made changes in a file I didn't even had open. While you can tell it to never make changes, I found that you have to repeat this statement a few times in quite blunt language for it to add that as a memory. Also, the AI sometimes suggests features that oTree just doesn't have. For example, it suggests you can set 'session_config' and 'session_config_file' in ROOMS in settings.py, and it also suggests rooms can be added manually on the 'oTree Admin Interface' at http://your-domain/admin/ which I'm pretty sure doesn't exist. It also suggested using something called select_related() and also still thinks otree is based on django? These are likely more 'general AI' things than things about this specific AI though. One particularly useful use case I found is having the AI scan all the code and find places that might be causing lag on heroku, and then make suggestions on ways to improve it. I think this is where it would be most useful - making suggestions rather than outright writing the code. However, a lot of caution is still required, as it can suggest things that look correct but don't work in subtle ways (however, this is true of all AI).
#6
by
Chris_oTree
Hi, thank you so much for the feedback! I want to confirm whether you are using oTree's LLM. It should not be hallucinating random features like that. Ask it, "who are you?" It should reply with "I am the oTree code assistant". If it says something generic like "I am a coding assistant" then that's not the oTree model (even if it recognizes that you have an otree project). Check in our cursor settings, i am attaching a screenshot of what it should look like. when I ask it about how to create a session config, it tells me to edit my settings.py. if i follow up with "what about adding a session config manually through the admin interface" it replies: """ You cannot add a new session config (i.e., a new entry in SESSION_CONFIGS) through the oTree admin interface. Session configs are defined in the settings.py file and are loaded when the server starts. The admin interface allows you to: - Create new sessions using the configs already defined in settings.py - Set parameters (like number of participants, room, etc.) for a session at launch - Monitor and manage running sessions But you cannot create or edit the actual session config templates (the dictionaries in SESSION_CONFIGS) from the admin interface. Any changes to session configs must be made by editing settings.py and restarting the server. Summary: You can only add session configs by editing settings.py. The admin interface lets you launch sessions using those configs, but not create new configs. Let me know if you want a step-by-step guide for editing settings.py! """ Although yes I have seen that it can still hallucinate, but I am gonna continue to reduce that.
#7
by
Chris_oTree
I added screenshots and setup instructions here to the oTree Hub page.
#8
by
dwoods
Yes, the issue seems to be it's not using the right model, as it doesn't explicitly say it's the otree assistant. However, I'm pretty sure I followed the instructions correctly the first time, and I've done the same steps twice again, including restarting Cursor in case it needed that to update.
#9
by
Chris_oTree
it's temporarily offline as i'm moving to a new server, hopefully up again within a day or two
#10 by razvanght
Hello, thank you for this. I get the following error when using anything but the Ask feature: "Agent and Edit rely on custom models that cannot be billed to an API key. Please use a Pro or Business subscription and/or disable API keys. Ask should still work."
#11 by JoeyZhu (edited )
Hi Chris, Thanks for providing such a helpful tool. It makes me debug better. However, I encountered the same problem with @razvanght. Whatever I ask, it always shows me this: "Agent and Edit rely on custom models that cannot be billed to an API key. Please use a Pro or Business subscription and/or disable API keys. Ask should still work."
#12
by
Chris_oTree
Thank you both for letting me know about this issue. I didn't know that Agent mode is not available on the free version. That's a pity because Agent mode is much more powerful than Ask mode :( but still Ask mode can be useful if you try that... hm...
#13 by JDetemple
Hi Chris,
Thanks for putting the effort into the oTree AI coding model. I feel that even in ask mode it is quite helpful.
However, I've encountered connection problems to the oTree AI API ("Connection failed"). Is this due to the beta status or some other issue (e.g., do we have to subscribe to the premium version of oTree hub)?
Thanks!
#14
by
Chris_oTree
Hi all, it's been announced that Visual Studio will soon support custom AI models for Copilot. That is good news because it's free and you can use agent mode. It should become available in a few weeks. So I will probably focus on that.
#15 by win_fan
Hello, Chris, I am trying to install oTree plugin into Cursor. But when I search oTree, no result find in Cursor Market Place. In this case, how could I install oTree plugin into Cursor? Thanks!
#16
by
Chris_oTree
can you take a screenshot of when you search for it?
#18
by
Chris_oTree
hmmm i'm not sure... when i search the same place, it finds it...
#19 by ksaral
are the instructions the same for VS Code? I've added the extension, but can't quite figure out how to work it.
#20
by
Chris_oTree
oTree AI code assistant doesn't work in VS Code yet. With the oTree extension, you will get syntax highlighting and checking but no AI stuff yet.
#21
by
Chris_oTree
Microsoft is expected to release their new version of VS Code this month that supports custom AI models. Once that is released, I will try to get the integration working within weeks.
#22 by win_fan
Hello, Chris Since I cannot find oTree plugin in Cursor Market Place. I used pip install to install oTree from cursor terminal. And provided the paid API key. When I ask "Who are you?" It shows, "I'm your AI coding assistant....". Any idea how could I get oTree AI assistant? Thanks
#23 by win_fan
Hello, Chris, Finally, I figured out how to get oTree plugin to show on the Cursor marketplace. I was able to install it successfully. After I configured Cursor to use oTree’s AI model, I enter "Who are you?" in the chat, it still shows "I'm your AI coding assistant....". Any idea how could I get oTree AI assistant? Thanks
#24
by
Chris_oTree
can you show a screenshot of your Cursor models setting? where you set the custom model endpoint URL etc.
#26
by
Chris_oTree
thanks for the screenshot. it looks correctly configured. i just tried it myself and i can confirm something is not working as it should. it works part of the time if i change the model in the chat model picker. anyway I am going to focus on getting AI integration in Visual Studio Code instead. Thanks for your patience.
#27 by win_fan
Thanks for checking. Please let me know if you get the oTree AI Assistant working in Cursor. I primarily use Visual Studio Code. If you release a VS Code version, I'd love to try it. Thanks!
#28 by AnBu0430
Hi Chris, I just wanted to double check - so it seems like the otree assistance is not working with Cursor anymore. Is this correct?
#29
by
Chris_oTree
Yes last time i checked it wasn't working reliably because cursor changed their protocol. I'm still waiting to see if I will be able to add this agent to Visual Studio code.
#30
by
Chris_oTree
However, I still encourage everyone to try the VS Code oTree extension (available through vs code "extensions" tab). It doesn't have AI features but makes otree programming easier.
#31 by Ismael
Hi Chris, thanks for your work. I am sure you already thought about it, couldn't an MCP server solve the compatibility issues between all the AI code software (cursor, vscode, claudecode, codex, etc.) ?
#32 by Ismael
By the way, I think in VScode insiders https://code.visualstudio.com/insiders/ it’s already possible to add custom ai model (by selecting OpenAI Compatible, see the screenshot). I just tried with the personal API key found in otree hub but it didn’t work, but maybe something is still different from Cursor.
#33
by
Chris_oTree
Hi Ismael, thanks for the suggestions. I considered MCP but it only gives limited capabilities... the oTree AI agent has been trained in a more customized way. As for VSCode insiders, yes you are right... although I hope I can get this working in the regular version of VS Code, since it would be a disadvantage to require people to install VS Code Insiders.