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
load_dotenv()
driver = StructuredDataDriver(os.environ['INMYDATA_TENANT'])
# -- 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
)
df = driver.get_data_simple(
"Inmystore Sales", # Name of the subject we want to extract data from
["Financial Year","Sales Value"], # List of fields we want to extract
filter, # Filters to apply
False) # Whether filters are case sensitive
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 sensitiv
)
)
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 sensitiv
)
)
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
print(df)
Example of retrieving conversational data
import os
from dotenv import load_dotenv
from inmydata.ConversationalData import ConversationalDataDriver
import asyncio
load_dotenv()
driver = ConversationalDataDriver(os.environ['INMYDATA_TENANT'])
# Register a callback to handle AI question updates
def on_ai_question_update(caller, message):
print(message)
# Callback handler for AI question updates
driver.on("ai_question_update", on_ai_question_update)
# Ask the question
# Note: This is an asynchronous operation, so we need to run it in an event loop
async def ask_question(question):
response = await driver.get_answer(question)
return response
# Example question
Answer = asyncio.run(ask_question("Give me the top 10 stores this year"))
print("=================================================================")
print(Answer.answer)
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))
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.8.tar.gz.
File metadata
- Download URL: inmydata-0.0.8.tar.gz
- Upload date:
- Size: 167.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a588b2c9740888db7c9ede822764195d2ce53e88cd9bdab1249c30f091c1393
|
|
| MD5 |
570a9f5a880ce1af8285252d59ef2f93
|
|
| BLAKE2b-256 |
4c8efdaef7e0cf3dec58636874b96a8501b90539f678d4d6e82cc9c87ee3ac30
|
File details
Details for the file inmydata-0.0.8-py3-none-any.whl.
File metadata
- Download URL: inmydata-0.0.8-py3-none-any.whl
- Upload date:
- Size: 11.6 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 |
ace4850fcd35944dd09346090551e74e745a62efaf9886a981a41dd1bd465f31
|
|
| MD5 |
dbd2ee5e56e93c1947aedfb50f50ed8f
|
|
| BLAKE2b-256 |
8da88d74287eca5d34d78ee6517720d1fdf27cd64fd190dddfd28b566be97d79
|