Skip to content

Update Python README to match R#11

Merged
chendaniely merged 8 commits intomainfrom
python-readme
May 29, 2025
Merged

Update Python README to match R#11
chendaniely merged 8 commits intomainfrom
python-readme

Conversation

@jcheng5
Copy link
Copy Markdown
Collaborator

@jcheng5 jcheng5 commented May 23, 2025

No description provided.

@jcheng5 jcheng5 requested a review from chendaniely May 23, 2025 21:28
Comment thread python-package/README.md
### Provide a greeting (recommended)

When the querychat UI first appears, you will usually want it to greet the user with some basic instructions. By default, these instructions are auto-generated every time a user arrives; this is slow, wasteful, and unpredictable. Instead, you should create a file called `greeting.md`, and when calling `querychat.init`, pass `greeting=Path("greeting.md").read_text()`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can provide suggestions to the user by using the <span class="suggestion"> </span> tag.

For example:

* **Filter and sort the data:**
  * <span class="suggestion">Show only survivors</span>
  * <span class="suggestion">Filter to first class passengers under 30</span>
  * <span class="suggestion">Sort by fare from highest to lowest</span>

* **Answer questions about the data:**
  * <span class="suggestion">What was the survival rate by gender?</span>
  * <span class="suggestion">What's the average age of children who survived?</span>
  * <span class="suggestion">How many passengers were traveling alone?</span>

This will provide a clickable message in the greeting that will auto populate the chat text box. This gives the user a few ideas to explore on their own. You can see this behavior in our querychat template.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <span class="suggestion"> is a good example to point out for the greeting. It really makes the greeting flow better, and we should showcase how to do it. It really polishes up the application and chat.

This was a suggestion of the block of text to put in this part of the README

Comment thread python-package/README.md Outdated

- Column names
- DuckDB data type (integer, float, boolean, datetime, text)
- For text columns with less than 10 unique values, we assume they are categorical variables and include the list of values
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • For text columns with less than 10 unique values, we assume they are categorical variables and include the list of values. This threshold is configurable.

Comment thread python-package/README.md Outdated
- For text columns with less than 10 unique values, we assume they are categorical variables and include the list of values
- For integer and float columns, we include the range

And that's all the LLM will know about your data. If the column names are usefully descriptive, it may be able to make a surprising amount of sense out of the data. But if your data frame's columns are `x`, `V1`, `value`, etc., then the model will need to be given more background info--just like a human would.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be important here to really clarify that the data does not go to the LLM.

And that's all the LLM will know about your data. The actual data does not get passed into the LLM. We calculate these values before we pass the schema information into the LLM.

Comment thread python-package/README.md
Comment on lines 178 to 201
### Use a different LLM provider

You can change the LLM provider or model by providing a callback function that takes a `system_prompt` argument and returns a `chatlas.Chat` object. (The parameter must be called `system_prompt` as it is passed by keyword.)
By default, querychat uses GPT-4o via the OpenAI API. If you want to use a different model, you can provide a `create_chat_callback` function that takes a `system_prompt` parameter, and returns a chatlas Chat object:

```python
import chatlas
from functools import partial

# Option 1: Define a function
def my_chat_func(system_prompt: str) -> chatlas.Chat:
return chatlas.ChatAnthropic(
model="claude-3-5-sonnet-latest",
model="claude-3-7-sonnet-latest",
system_prompt=system_prompt
)

# Option 2: Use partial
my_chat_func = partial(chatlas.ChatAnthropic, model="claude-3-7-sonnet-latest")

querychat_config = querychat.init(
df=my_dataframe,
df=titanic,
table_name="titanic",
create_chat_callback=my_chat_func
)
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really good you have these examples. Shiny prides itself in not having to write a callback, so seeing that term can be a bit scary. I suspect most people will use Option 1.

Comment thread python-package/README.md Outdated
- Reading greeting and data description from files
- Setting up the querychat configuration
- Creating a Shiny UI with the chat sidebar
- Displaying the filtered data in the main panel No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add at the end.

If you have Shiny installed, and want to get started right away, you can use our querrychat template.

@chendaniely
Copy link
Copy Markdown
Contributor

Merge #12 into this before merging into main. I added my additions there. (Don't have access to this repo directly)

@chendaniely chendaniely merged commit e811195 into main May 29, 2025
@chendaniely chendaniely deleted the python-readme branch May 29, 2025 19:17
schloerke added a commit that referenced this pull request May 29, 2025
* main:
  docs: Update Python and R READMEs (#11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants