Skip to content

AnswerDotAI/solveit_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solveit_client

A Python client for programmatically interacting with SolveIt dialogs.

Installation

Authentication

Set your SOLVEIT_TOKEN environment variable before using the client. To find your token:

  1. Open Chrome DevTools (F12 or Cmd+Option+I)
  2. Go to the Application tab
  3. In the sidebar, expand Cookies and select your SolveIt domain
  4. Find the cookie named _solveit
  5. Copy its value—that’s your token
export SOLVEIT_TOKEN='your-token-here'
!pip install solveit_client

Quick Start

from solveit_client.core import *

# Initialize client (uses SOLVEIT_TOKEN env var by default)
sic = SolveItClient('https://your-instance.solve.it.com/'); sic
SolveItClient(self.url='https://your-instance.solve.it.com/')

Use the /test_route to confirm your client has connect:

sic('/test_route')
'here'

If you get an error saying No access. Please login and then retry., double check your SOLVEIT_TOKEN is correct and exported.

# Create a dialog
dlg = sic.create_dialog('my-project/experiment'); dlg

Dialog: my-project/experiment | Mode: learning

# Add and execute code
msg = dlg.add_msg('1 + 1'); msg

Message: _59a51ada | Type: code | 1 + 1 | Output:

msg.exec(); msg

Message: _59a51ada | Type: code | 1 + 1 | Output: 2

# Add a prompt for AI assistance
ai_msg = dlg.add_msg('Tell me about otters 🤓', msg_type='prompt')
ai_msg.exec(); ai_msg

Message: _e8ede692 | Type: prompt | Tell me about otters 🤓 | Output: Otters are fascinating semi-aquatic mammals! They'...

# View all messages
dlg.messages
ID Type Content Output
<a
href="https://lucid-magic-forges-szzy66.solve.it.com/dialog_?name=my-project/experiment#_1512badb"
target="_blank">_1512badb code 1 + 1 2
<a
href="https://lucid-magic-forges-szzy66.solve.it.com/dialog_?name=my-project/experiment#_4129a41c"
target="_blank">_4129a41c prompt Explain this code This code adds two numbers together: `1
<a
href="https://lucid-magic-forges-szzy66.solve.it.com/dialog_?name=my-project/experiment#_74e465c1"
target="_blank">_74e465c1 code 1 + 1 2
<a
href="https://lucid-magic-forges-szzy66.solve.it.com/dialog_?name=my-project/experiment#_4bd1fbe2"
target="_blank">_4bd1fbe2 prompt Explain this code This code performs addition: `1 + 1` res
<a
href="https://lucid-magic-forges-szzy66.solve.it.com/dialog_?name=my-project/experiment#_59a51ada"
target="_blank">_59a51ada code 1 + 1 2
<a
href="https://lucid-magic-forges-szzy66.solve.it.com/dialog_?name=my-project/experiment#_e8ede692"
target="_blank">_e8ede692 prompt Tell me about otters 🤓 Otters are fascinating semi-aquatic mamm
dlg.delete()
{'success': 'deleted "/app/data/my-project/experiment"'}