Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions agents/tensorlake/tensorlake-agent/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
180 changes: 180 additions & 0 deletions agents/tensorlake/tensorlake-agent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.env.development
.env.production
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc

# Agentuity
.agentuity
.agentuity-crash-*.json
1 change: 1 addition & 0 deletions agents/tensorlake/tensorlake-agent/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
110 changes: 110 additions & 0 deletions agents/tensorlake/tensorlake-agent/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Agentuity Python Agent Development

This guide provides comprehensive instructions for developing AI agents using the Agentuity platform with Python.

## 1. Agent Development Guidelines

- Prefer using the `agentuity agent create` command to create a new Agent
- Prefer importing types from the `agentuity` package
- The file should define an async function named `run`
- All code should follow Python best practices and type hints
- Use the provided logger from the `AgentContext` interface such as `context.logger.info("my message: %s", "hello")`

### Example Agent File

```python
from agentuity import AgentRequest, AgentResponse, AgentContext

async def run(request: AgentRequest, response: AgentResponse, context: AgentContext):
return response.json({"hello": "world"})
```

## 2. Core Interfaces

### Agent Handler

The main handler function for an agent:

```python
async def run(
request: AgentRequest,
response: AgentResponse,
context: AgentContext
) -> Any:
# Agent implementation
pass
```

### AgentRequest

The `AgentRequest` class provides methods for accessing request data:

- `request.trigger`: Gets the trigger type of the request
- `request.metadata`: Gets metadata associated with the request
- `request.get(key, default)`: Gets a value from the metadata
- `request.data.contentType`: Gets the content type of the request payload
- `request.data.json`: Gets the payload as a JSON object
- `request.data.text`: Gets the payload as a string
- `request.data.binary`: Gets the payload as bytes

### AgentResponse

The `AgentResponse` class provides methods for creating responses:

- `response.json(data, metadata)`: Creates a JSON response
- `response.text(data, metadata)`: Creates a text response
- `response.binary(data, content_type, metadata)`: Creates a binary response
- `response.html(data, metadata)`: Creates an HTML response
- `response.empty(metadata)`: Creates an empty response
- `response.handoff(params, args, metadata)`: Redirects to another agent
- Media-specific methods: `pdf()`, `png()`, `jpeg()`, `gif()`, `mp3()`, `mp4()`, etc.

### AgentContext

The `AgentContext` class provides access to various capabilities:

- `context.logger`: Logging functionality
- `context.kv`: Key-Value storage
- `context.vector`: Vector storage
- `context.get_agent(agent_id_or_name)`: Gets a handle to a remote agent
- `context.tracer`: OpenTelemetry tracing
- Environment properties: `sdkVersion`, `devmode`, `orgId`, `projectId`, etc.

## 3. Storage APIs

### Key-Value Storage

Access through `context.kv`:

- `await context.kv.get(name, key)`: Retrieves a value
- `await context.kv.set(name, key, value, params)`: Stores a value with optional params
- `await context.kv.delete(name, key)`: Deletes a value

### Vector Storage

Access through `context.vector`:

- `await context.vector.upsert(name, *documents)`: Inserts or updates vectors
- `await context.vector.search(name, params)`: Searches for vectors
- `await context.vector.delete(name, *ids)`: Deletes vectors

## 4. Logging

Access through `context.logger`:

- `context.logger.debug(message, *args, **kwargs)`: Logs a debug message
- `context.logger.info(message, *args, **kwargs)`: Logs an informational message
- `context.logger.warn(message, *args, **kwargs)`: Logs a warning message
- `context.logger.error(message, *args, **kwargs)`: Logs an error message
- `context.logger.child(**kwargs)`: Creates a child logger with additional context

## 5. Best Practices

- Use type hints for better IDE support
- Import types from `agentuity`
- Use structured error handling with try/except blocks
- Leverage the provided logger for consistent logging
- Use the storage APIs for persisting data
- Consider agent communication for complex workflows

For complete documentation, visit: https://agentuity.dev/SDKs/python/api-reference
Loading