44[ ![ Python versions] ( https://img.shields.io/pypi/pyversions/textql.svg )] ( https://pypi.org/project/textql/ )
55[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( LICENSE )
66
7- Official Python SDK for the [ TextQL Platform API] ( https://docs.textql.com ) .
8-
9- > ** Status:** v0.1.0 is a scaffolding release. Resource clients (` chat ` , ` playbooks ` , ` sandbox ` , ` connectors ` ) are stubs and not yet functional.
7+ Official Python SDK for the [ TextQL Platform API] ( https://docs.textql.com/api-reference/v2/introduction ) .
108
119## Installation
1210
@@ -22,45 +20,79 @@ Requires Python 3.9+.
2220from textql import TextQL
2321
2422client = TextQL(api_key = " tql_..." ) # or set TEXTQL_API_KEY in the environment
23+
24+ # Ask a question
25+ response = client.chat.create(" What was total revenue last quarter?" , connector_ids = [1 ])
26+ print (response[" response" ])
27+
28+ # Stream a response
29+ for event in client.chat.stream(" Summarize sales by region" ):
30+ if event[" type" ] == " text" :
31+ print (event[" text" ], end = " " , flush = True )
32+
33+ # Upload files with a question
34+ response = client.chat.create(
35+ " Analyze this data" ,
36+ files = [" ./sales.csv" ],
37+ )
2538```
2639
27- Once resource clients land, the surface will look like:
40+ ## Resources
41+
42+ ### Chat
2843
2944``` python
30- # Simple chat
31- response = client.chat.create(question = " What was total revenue last quarter?" )
45+ client.chat.list(limit = 10 )
46+ client.chat.create(" What connectors are available?" )
47+ client.chat.get(" chat-uuid" )
48+ client.chat.stream(" Summarize revenue" )
49+ client.chat.cancel(" chat-uuid" )
50+ ```
3251
33- # Streaming
34- for event in client.chat.stream(question = " ..." ):
35- print (event.text, end = " " , flush = True )
52+ ### Connectors
3653
37- # File upload
38- response = client.chat.create(
39- question = " Analyze this" ,
40- files = [{" path" : " ./sales.csv" }],
41- )
54+ ``` python
55+ client.connectors.list()
56+ ```
57+
58+ ### Playbooks
59+
60+ ``` python
61+ client.playbooks.list(limit = 10 )
62+ pb = client.playbooks.create()
63+ client.playbooks.update(pb[" id" ], name = " Weekly Revenue" , prompt = " Summarize revenue by region" )
64+ client.playbooks.deploy(pb[" id" ])
65+ client.playbooks.run(pb[" id" ])
66+ client.playbooks.get(pb[" id" ])
67+ client.playbooks.delete(pb[" id" ])
68+ ```
69+
70+ ### Sandbox
71+
72+ ``` python
73+ sb = client.sandbox.start()
74+ sid = sb[" sandbox_id" ]
75+
76+ client.sandbox.execute(sid, code = " import pandas as pd; print(pd.__version__)" )
77+ client.sandbox.query(sid, connector_id = 1 , query = " SELECT * FROM sales LIMIT 10" , dataframe_name = " sales" )
78+ client.sandbox.upload_file(sid, " ./data.csv" )
79+ client.sandbox.status(sid)
80+ client.sandbox.stop(sid)
4281```
4382
4483## Configuration
4584
4685| Option | Env var | Default |
4786| ---| ---| ---|
4887| ` api_key ` | ` TEXTQL_API_KEY ` | — (required) |
49- | ` base_url ` | ` TEXTQL_BASE_URL ` | ` https://api .textql.com ` |
88+ | ` base_url ` | ` TEXTQL_BASE_URL ` | ` https://app .textql.com ` |
5089| ` timeout ` | — | ` 60.0 ` seconds |
5190
52- ## Development
53-
54- ``` bash
55- pip install -e " .[dev]"
56- ruff check . && ruff format --check .
57- pyright
58- pytest
59- ```
91+ The ` base_url ` accepts a bare hostname (e.g. ` app.textql.com ` ) or a full URL.
6092
6193## Links
6294
63- - [ API documentation] ( https://docs.textql.com )
95+ - [ API documentation] ( https://docs.textql.com/api-reference/v2/introduction )
6496- [ Changelog] ( CHANGELOG.md )
6597- [ Issues] ( https://github.com/TextQLLabs/textql-python/issues )
6698
0 commit comments