A set of AI tools for working with Cognite Data Fusion in Python.
Project description
cognite-ai
A set of AI tools for working with CDF in Python.
MemoryVectorStore
Store and query vector embeddings created from CDF. This can enable a bunch of use cases where the number of vectors aren't that big.
Install the package
%pip install cognite-ai
Then you can create vectors from text (both multiple lines or a list of strings) like this
from cognite.ai import MemoryVectorStore
from cognite.client import CogniteClient
client = CogniteClient()
vector_store = MemoryVectorStore(client)
vector_store.store_text("Hi, I am a software engineer working for Cognite.")
vector_store.store_text("The moon is orbiting the earth, which is orbiting the sun.")
vector_store.store_text("Coffee can be a great way to stay awake.")
vector_store.query_text("I am tired, what can I do?")
Smart data frames
Chat with your data using LLMs. Built on top of PandasAI version 2.2.15. If you have loaded data into a Pandas dataframe, you can run
Install the package
%pip install cognite-ai
Chat with your data
from cognite.client import CogniteClient
from cognite.ai import load_pandasai
client = CogniteClient()
SmartDataframe, SmartDatalake, Agent = await load_pandasai()
workorders_df = client.raw.rows.retrieve_dataframe("tutorial_apm", "workorders", limit=-1)
workitems_df = client.raw.rows.retrieve_dataframe("tutorial_apm", "workitems", limit=-1)
workorder2items_df = client.raw.rows.retrieve_dataframe("tutorial_apm", "workorder2items", limit=-1)
workorder2assets_df = client.raw.rows.retrieve_dataframe("tutorial_apm", "workorder2assets", limit=-1)
assets_df = client.raw.rows.retrieve_dataframe("tutorial_apm", "assets", limit=-1)
smart_lake_df = SmartDatalake([workorders_df, workitems_df, assets_df, workorder2items_df, workorder2assets_df], cognite_client=client)
smart_lake_df.chat("Which workorders are the longest, and what work items do they have?")
s_workorders_df = SmartDataframe(workorders_df, cognite_client=client)
s_workorders_df.chat('Which 5 work orders are the longest?')
Configure LLM parameters
params = {
"model": "gpt-35-turbo",
"temperature": 0.5
}
s_workorders_df = SmartDataframe(workorders_df, cognite_client=client, params=params)
Pandas AI agent
We can also
from cognite.client import CogniteClient
from cognite.ai import load_pandasai
client = CogniteClient()
SmartDataframe, SmartDatalake, Agent = await load_pandasai()
# Create example data
sales_by_country_df = pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"revenue": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})
agent = Agent(sales_by_country_df, cognite_client=client)
print(agent.chat("Which are the top 5 countries by sales?"))
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
File details
Details for the file andeplane_ai-0.5.2.tar.gz
.
File metadata
- Download URL: andeplane_ai-0.5.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea2b18950e49c39b0cdb4a18ead64122e608d59ad5ac6dfe69c982b6587bace8 |
|
MD5 | 942a9e9fe3c652a586cbf7cea7b70081 |
|
BLAKE2b-256 | ed61826e55770cc325735473ea760cf938c2976a4b4ce623bcb853de5b97a8f1 |
File details
Details for the file andeplane_ai-0.5.2-py3-none-any.whl
.
File metadata
- Download URL: andeplane_ai-0.5.2-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ab51bedde26197800d264062fed8209ac41ddc106fe10fc10c544b4ea860825 |
|
MD5 | 4562fef7160be7e36d06234ed4c19497 |
|
BLAKE2b-256 | ad577ee891cf57b6baa6ae7b8613e0fda19a9f150b7b46aa2ef7d8c7bfb7d4fa |