Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cognite_ai-0.5.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

cognite_ai-0.5.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file cognite_ai-0.5.2.tar.gz.

File metadata

  • Download URL: cognite_ai-0.5.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for cognite_ai-0.5.2.tar.gz
Algorithm Hash digest
SHA256 5658e62c242fd67822be522603493463bafb290dcd1c167cf503ed96fbe82d0d
MD5 aeaf5248f19079390310835b95754bab
BLAKE2b-256 44098f9d5bebdc5edcecaf1edd76dc18852398ffdef9e9a874792259145c2fce

See more details on using hashes here.

File details

Details for the file cognite_ai-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: cognite_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/5.1.1 CPython/3.12.6

File hashes

Hashes for cognite_ai-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 43930d3ef20d9ab08effd85b8ea292203517bf92b6fc27ec23fdbe0dcc0f1921
MD5 755b1c871f4cce0f0c0a241510d24b4d
BLAKE2b-256 67d5eac17ad78975d16d9100c865a45fba027c62ffc6b361955ff3eff92b3b56

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page