This package provides simple API access to the inmydata platform
Project description
Agent SDK
The inmydata agent SDK enables you to build AI agents that can rapidly access data from the inmydata platform.
Features
- Conversational data interface - retrieve data with natural language queries
- Structured data interface - rapidly build data interfaces for you AI agents
- Calendar assistant - empower your AI agent with detailed knowledge of your financial calendars
Installation
Install the inmydata agent SDK with pip
pip install inmydata
Documentation
See https://developer.inmydata.com for quickstarts, documentation, and examples.
Usage/Examples
For these examples you will need to set the following environment variables:
- INMYDATA_API_KEY
- INMYDATA_TENANT
- INMYDATA_CALENDAR
Example of retrieving structured data
import os
from dotenv import load_dotenv
from inmydata.StructuredData import (
StructuredDataDriver,
AIDataSimpleFilter,
AIDataFilter,
LogicalOperator,
ConditionOperator,
TopNOption,
ChartType
)
load_dotenv()
driver = StructuredDataDriver(os.environ['INMYDATA_TENANT'])
driver.user = "demo" # Events to display charts will be available to the user specified here
driver.session_id = "test-session" # Session ID passed in the event to display charts. Can optionally be used to only show charts for the current session
# -- Get a json document that details the available schema
print(driver.get_schema("Readme Documentation"))
# -- Use get_data_simple when your filter is simple (only equality filters, no bracketing, no ORs, etc.)
# Build our simple filter
filter = []
filter.append(
AIDataSimpleFilter(
"Store", # Field to filter on
"Edinburgh") # Value to filter by
)
# Build a TopN filter to only show the Top 10 Sales People based on Sales Value
TopN = TopNOption("Sales Value", 10) # Field to order by and number of records to return (Positive for TopN, negative for BottomN)
TopNOptions = {}
TopNOptions["Sales Person"] = TopN # Apply the Top N option to the Sales Person field
df = driver.get_data_simple(
"Inmystore Sales", # Name of the subject we want to extract data from
["Sales Person","Sales Value"], # List of fields we want to extract
filter, # Filters to apply
False, # Whether filters are case sensitive
TopNOptions) # Apply the Top 10 Sales People based on Sales Value filter
print(df)
# -- Use get_data when your filter more complex (non-equality matches, bracketing, ORs, etc.) --
# Build our filter
filter = []
filter.append(
AIDataFilter(
"Store",
ConditionOperator.Equals, # Condition to use in the filter
LogicalOperator.And, # Logical operator to use in the filter
"Edinburgh", # Value to filter by
0, # Number of brackets before this condition
0, # Number of brackets after this condition
False # Whether the filter is case sensitive
)
)
filter.append(
AIDataFilter(
"Store",
ConditionOperator.Equals, # Condition to use in the filter
LogicalOperator.Or, # Logical operator to use in the filter
"London", # Value to filter by
0, # Number of brackets before this condition
0, # Number of brackets after this condition
False # Whether the filter is case sensitive
)
)
df = driver.get_data(
"Inmystore Sales", # Name of the subject we want to extract data from
["Financial Year","Store","Sales Value"], # List of fields we want to extract
filter, # Filters to apply
{}) # Apply no TopN options
print(df)
# -- Use get_chart to generate a chart based on the data -- see https://developer.inmydata.com/support/solutions/articles/36000577995-displaying-charts-generated-by-agentic-ai-workflows
# Build our filter
filter = []
filter.append(
AIDataFilter(
"Store",
ConditionOperator.Equals, # Condition to use in the filter
LogicalOperator.And, # Logical operator to use in the filter
"Edinburgh", # Value to filter by
0, # Number of brackets before this condition
0, # Number of brackets after this condition
False # Whether the filter is case sensitive
)
)
filter.append(
AIDataFilter(
"Financial Year",
ConditionOperator.Equals, # Condition to use in the filter
LogicalOperator.And, # Logical operator to use in the filter
"2025", # Value to filter by
0, # Number of brackets before this condition
0, # Number of brackets after this condition
False # Whether the filter is case sensitive
)
)
# Build a TopN filter to only show the Top 10 Sales People based on Sales Value
TopN = TopNOption("Sales Value", 10) # Field to order by and number of records to return (Positive for TopN, negative for BottomN)
TopNOptions = {}
TopNOptions["Sales Person"] = TopN # Apply the Top N option to the Sales Person field
chartId = driver.get_chart(
"Inmystore Sales", # Name of the subject we want to extract data from
["Sales Person"], # Chart row fields
[], # Chart Column Fields
["Sales Value"], # Chart value fields
filter, # Filters to apply
ChartType.Bar, # Type of chart to generate
"Top 10 Sales People in Edinburgh for 2025", # Title of the chart
TopNOptions, # Apply the Top 10 Sales People based on Sales Value filter
)
Example of retrieving conversational data
import os
from dotenv import load_dotenv
from inmydata.ConversationalData import ConversationalDataDriver
import asyncio
load_dotenv()
# get_answer is an async function, so we need to run it in an event loop
async def main():
driver = ConversationalDataDriver(os.environ['INMYDATA_TENANT'])
# Register a callback to handle AI question updates
def on_ai_question_update(caller, message):
print(message)
# Register the callback handler for AI question updates
driver.on("ai_question_update", on_ai_question_update)
question = "Give me the top 10 stores this year"
answer = await driver.get_answer(question)
print("=================================================================")
print(f"The answer was: {answer.answer}")
print(f"The subject used to generate the answer was: {answer.subject}")
asyncio.run(main())
Example of retrieving calendar periods
import os
from datetime import date
from dotenv import load_dotenv
from inmydata.CalendarAssistant import CalendarAssistant
load_dotenv()
# Get today's date
today = date.today()
# Initialize the Calendar Assistant with tenant and calendar name
assistant = CalendarAssistant(os.environ['INMYDATA_TENANT'], os.environ['INMYDATA_CALENDAR'])
# Get the current financial year
print("The current financial year is: " + str(assistant.get_financial_year(today)))
# Get the current financial quarter
print("The current financial quarter is: " + str(assistant.get_quarter(today)))
# Get the current financial month
print("The current financial month is: " + str(assistant.get_month(today)))
# Get the current financial week
print("The current financial week is: " + str(assistant.get_week_number(today)))
# Get the current financial periods
print("The current periods are:")
print(assistant.get_financial_periods(today))
# Get the date range for the current financial month
response = assistant.get_calendar_period_date_range(assistant.get_financial_year(today), assistant.get_month(today), CalendarPeriodType.month)
if response is not None:
print("The current financial month date range is: " + response.StartDate.strftime("%A, %B %d, %Y") + " to " + response.EndDate.strftime("%A, %B %d, %Y"))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inmydata-0.0.17.tar.gz.
File metadata
- Download URL: inmydata-0.0.17.tar.gz
- Upload date:
- Size: 208.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfec4b26088b790b4a5e9ea91f22f0f85c96759a5aeea448d6b0f2fd26566e8c
|
|
| MD5 |
9c5a8c88003afd9eb23aa7dd1407e470
|
|
| BLAKE2b-256 |
4e9ac80f077aced2e068be7a7aefbd03a3de97ffe5414db199b4948669251406
|
File details
Details for the file inmydata-0.0.17-py3-none-any.whl.
File metadata
- Download URL: inmydata-0.0.17-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14e5407f2a4811640dfed8f3eb20afd68463404f990ccf6ca0914128b4f6199d
|
|
| MD5 |
443aea75eb62647860cf5a800a9cb656
|
|
| BLAKE2b-256 |
5a52e14737f7cfbc4aed2c4fc1af732dce8b2ba23911d2f39b3758d5a5031986
|