Gramex 1.92 adds ChatGPTHandler, OTP custom keys and Excel Hyperlink support.
ChatGPTHandler provides interface to OpenAI’s chat API.
url:
chatgpthandler:
pattern: /$YAMLURL/chat
handler: ChatGPTHandler
kwargs:
key: sz-....
Replace the key
with your OpenAI API key
This opens a WebSocket connection to /chat
. You can read more about how to send messages to it here
OTPs and API keys store a user JSON object. You can pass additional keys to this object using the columns
configuration.
storelocations:
otp:
columns:
role: TEXT
group: TEXT
You can populate these columns using keyword arguments to handler.otp()
and handler.api_key()
. More details here
gramex.cache.open()
now extracts hyperlinks from an Excel column. For example, this Excel file city-sales.xlsx
has a “City” column with hyperlinks.
Country | City | Sales |
---|---|---|
Italy | Rome | 10 |
Norway | Oslo | 20 |
UK | London | 30 |
France | Paris | 40 |
Using gramex.cache.open('city-sales.xlsx', links=True)
will read it as a DataFrame with a new City_links
column with the hyperlinks.
Country | City | Sales | City_link |
---|---|---|---|
Italy | Rome | 10 | https://en.wikipedia.org/wiki/Rome |
Norway | Oslo | 20 | https://en.wikipedia.org/wiki/Oslo |
UK | London | 30 | https://en.wikipedia.org/wiki/London |
France | Paris | 40 | https://en.wikipedia.org/wiki/Paris |
You can specify column names to extract from explicitly as a dictionary. For example:
gramex.cache.open('city-sales.xlsx', links={
'City': 'city_url',
'Country': 'country_url'
})
This extracts the hyperlink from City
into city_url
and Country
into country_url
. Empty hyperlinks are stored as NaN
.
Gramex 1.92 is backward compatible with previous releases unless the release notes say otherwise. We ensure this with automated tests.
Every Gramex release is tested for security vulnerabilities using the following tools.
The Gramex code base has: