Name | codemie-sdk-python JSON |
Version |
0.1.132
JSON |
| download |
home_page | None |
Summary | CodeMie SDK for Python |
upload_time | 2025-08-29 14:47:08 |
maintainer | None |
docs_url | None |
author | Vadym Vlasenko |
requires_python | <4.0,>=3.12 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# CodeMie Python SDK
Python SDK for CodeMie services. This SDK provides a comprehensive interface to interact with CodeMie services, including LLM (Large Language Models), assistants, workflows, and tools.
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Basic Usage](#basic-usage)
- [Service Details](#service-details)
- [LLM Service](#llm-service)
- [Assistant Service](#assistant-service)
- [Core Methods](#core-methods)
- [Advanced Features](#advanced-features)
- [Datasource Service](#datasource-service)
- [Supported Datasource Types](#supported-datasource-types)
- [Core Methods](#core-methods-1)
- [Datasource Status](#datasource-status)
- [Best Practices for Datasources](#best-practices-for-datasources)
- [Integration Service](#integration-service)
- [Integration Types](#integration-types)
- [Core Methods](#core-methods-2)
- [Best Practices for Integrations](#best-practices-for-integrations)
- [Workflow Service](#workflow-service)
- [Core Methods](#core-methods-3)
- [Workflow Execution](#workflow-execution)
- [Workflow Configuration](#workflow-configuration)
- [Best Practices](#best-practices)
- [Error Handling](#error-handling)
- [Workflow Status Monitoring](#workflow-status-monitoring)
- [Development](#development)
- [Setup](#setup)
- [Running Tests](#running-tests)
- [Building Package](#building-package)
- [Error Handling](#error-handling-1)
- [Authentication](#authentication)
- [Required Parameters](#required-parameters)
- [Usage Examples](#usage-examples)
- [Best Practices](#best-practices-1)
- [Support](#support)
## Installation
```sh
pip install codemie-sdk
```
OR
```sh
poetry install
```
### If you want to run only tests, go to ## Running tests section
## Usage
### Basic usage
```python
from codemie_sdk import CodeMieClient
# Initialize client with authentication parameters
client = CodeMieClient(
auth_server_url="https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth",
auth_client_id="your-client-id",
auth_client_secret="your-client-secret",
auth_realm_name="your-realm",
codemie_api_domain="https://codemie.lab.epam.com/code-assistant-api"
)
```
## Service Details
### LLM Service
The LLM service provides access to language models and embedding models:
- **list()**: Retrieves a list of available LLM models
```python
llm_models = client.llm.list(token=client.token)
```
- **list_embeddings()**: Retrieves a list of available embedding models
```python
embedding_models = client.llm.list_embeddings(token=client.token)
```
Each LLM model contains the following information:
- Model identifier
- Model capabilities
- Configuration parameters
Example usage:
```python
# List available LLM models
llm_models = client.llm.list(token=client.token)
# List available embedding models
embedding_models = client.llm.list_embeddings(token=client.token)
```
### Assistant Service
The Assistant service allows you to manage and interact with CodeMie assistants:
#### Core Methods
1. **List Assistants**
```python
assistants = client.assistant.list(
minimal_response=True, # Return minimal assistant info
scope="visible_to_user", # or "created_by_user"
page=0,
per_page=12,
filters={"key": "value"} # Optional filters
)
```
2. **Get Assistant Details**
```python
# By ID
assistant = client.assistant.get("assistant-id")
# By Slug
assistant = client.assistant.get_by_slug("assistant-slug")
```
3. **Create Assistant**
```python
from codemie_sdk.models.assistant import AssistantCreateRequest
request = AssistantCreateRequest(
name="My Assistant",
description="Assistant description",
instructions="Assistant instructions",
tools=["tool1", "tool2"],
# Additional parameters as needed
)
new_assistant = client.assistant.create(request)
```
4. **Update Assistant**
```python
from codemie_sdk.models.assistant import AssistantUpdateRequest
request = AssistantUpdateRequest(
name="Updated Name",
description="Updated description",
# Other fields to update
)
updated_assistant = client.assistant.update("assistant-id", request)
```
5. **Delete Assistant**
```python
result = client.assistant.delete("assistant-id")
```
#### Advanced Features
6. **Chat with Assistant**
```python
from codemie_sdk.models.assistant import AssistantChatRequest
chat_request = AssistantChatRequest(
text="Your message here",
stream=False, # Set to True for streaming response
# Additional parameters
)
response = client.assistant.chat("assistant-id", chat_request)
```
7. **Utilize structured outputs with Assistant**
```python
from pydantic import BaseModel
class OutputSchema(BaseModel):
requirements: list[str]
chat_request = AssistantChatRequest(
text="Your message here",
stream=False,
output_schema=OutputSchema
# Additional parameters
)
response = client.assistants.chat("id", chat_request)
# response.generated is a Pydantic object
```
Or using JSON schema in dict format
```python
output_schema = {
"properties": {
"requirements": {
"items": {"type": "string"},
"title": "Requirements",
"type": "array",
}
},
"required": ["requirements"],
"title": "OutputSchema",
"type": "object",
}
chat_request = AssistantChatRequest(
text="Your message here",
stream=False,
output_schema=output_schema
# Additional parameters
)
response = client.assistants.chat("id", chat_request)
# response.generated is a dict corresponded with JSON schema
```
8. **Work with Prebuilt Assistants**
```python
# List prebuilt assistants
prebuilt = client.assistant.get_prebuilt()
# Get specific prebuilt assistant
prebuilt_assistant = client.assistant.get_prebuilt_by_slug("assistant-slug")
```
9. **Get Available Tools**
```python
tools = client.assistant.get_tools()
```
### Datasource Service
The Datasource service enables managing various types of data sources in CodeMie, including code repositories, Confluence spaces, Jira projects, files, and Google documents.
#### Supported Datasource Types
- `CODE`: Code repository datasources
- `CONFLUENCE`: Confluence knowledge base
- `JIRA`: Jira knowledge base
- `FILE`: File-based knowledge base
- `GOOGLE`: Google documents
#### Core Methods
1. **Create Datasource**
```python
from codemie_sdk.models.datasource import (
CodeDataSourceRequest,
ConfluenceDataSourceRequest,
JiraDataSourceRequest,
GoogleDataSourceRequest
)
# Create Code Datasource
code_request = CodeDataSourceRequest(
name="my_repo", # lowercase letters and underscores only
project_name="my_project",
description="My code repository",
link="https://github.com/user/repo",
branch="main",
index_type="code", # or "summary" or "chunk-summary"
files_filter="*.py", # optional
embeddings_model="model_name",
summarization_model="gpt-4", # optional
docs_generation=False # optional
)
result = client.datasource.create(code_request)
# Create Confluence Datasource
confluence_request = ConfluenceDataSourceRequest(
name="confluence_kb",
project_name="my_project",
description="Confluence space",
cql="space = 'MYSPACE'",
include_restricted_content=False,
include_archived_content=False,
include_attachments=True,
include_comments=True
)
result = client.datasource.create(confluence_request)
# Create Jira Datasource
jira_request = JiraDataSourceRequest(
name="jira_kb",
project_name="my_project",
description="Jira project",
jql="project = 'MYPROJECT'"
)
result = client.datasource.create(jira_request)
# Create Google Doc Datasource
google_request = GoogleDataSourceRequest(
name="google_doc",
project_name="my_project",
description="Google document",
google_doc="document_url"
)
result = client.datasource.create(google_request)
```
2. **Update Datasource**
```python
from codemie_sdk.models.datasource import UpdateCodeDataSourceRequest
# Update Code Datasource
update_request = UpdateCodeDataSourceRequest(
name="my_repo",
project_name="my_project",
description="Updated description",
branch="develop",
full_reindex=True, # optional reindex parameters
skip_reindex=False,
resume_indexing=False
)
result = client.datasource.update("datasource_id", update_request)
```
3. **List Datasources**
```python
# List all datasources with filtering and pagination
datasources = client.datasource.list(
page=0,
per_page=10,
sort_key="update_date", # or "date"
sort_order="desc", # or "asc"
datasource_types=["CODE", "CONFLUENCE"], # optional filter by type
projects=["project1", "project2"], # optional filter by projects
owner="John Doe", # optional filter by owner
status="COMPLETED" # optional filter by status
)
```
4. **Get Datasource Details**
```python
# Get single datasource by ID
datasource = client.datasource.get("datasource_id")
```
5. **Delete Datasource**
```python
# Delete datasource by ID
result = client.datasource.delete("datasource_id")
```
#### Datasource Status
Datasources can have the following statuses:
- `COMPLETED`: Indexing completed successfully
- `FAILED`: Indexing failed
- `FETCHING`: Fetching data from source
- `IN_PROGRESS`: Processing/indexing in progress
#### Best Practices for Datasources
1. **Naming Convention**:
- Use lowercase letters and underscores for datasource names
- Keep names descriptive but concise
2. **Performance Optimization**:
- Use appropriate filters when listing datasources
- Consider pagination for large result sets
- Choose appropriate reindex options based on your needs
3. **Error Handling**:
- Always check datasource status after creation/update
- Handle potential failures gracefully
- Monitor processing information for issues
4. **Security**:
- Be careful with sensitive data in filters and queries
- Use proper access controls when sharing datasources
- Regularly review and clean up unused datasources
### Integration Service
The Integration service manages both user and project-level integrations in CodeMie, allowing you to configure and manage various integration settings.
#### Integration Types
- `USER`: User-level integrations
- `PROJECT`: Project-level integrations
#### Core Methods
1. **List Integrations**
```python
from codemie_sdk.models.integration import IntegrationType
# List user integrations with pagination
user_integrations = client.integration.list(
setting_type=IntegrationType.USER,
page=0,
per_page=10,
filters={"some_filter": "value"} # optional
)
# List project integrations
project_integrations = client.integration.list(
setting_type=IntegrationType.PROJECT,
per_page=100
)
```
2. **Get Integration**
```python
# Get integration by ID
integration = client.integration.get(
integration_id="integration_id",
setting_type=IntegrationType.USER
)
# Get integration by alias
integration = client.integration.get_by_alias(
alias="integration_alias",
setting_type=IntegrationType.PROJECT
)
```
3. **Create Integration**
```python
from codemie_sdk.models.integration import Integration
# Create new integration
new_integration = Integration(
setting_type=IntegrationType.USER,
alias="my_integration",
# Add other required fields based on integration type
)
result = client.integration.create(new_integration)
```
4. **Update Integration**
```python
# Update existing integration
updated_integration = Integration(
setting_type=IntegrationType.USER,
alias="updated_alias",
# Add other fields to update
)
result = client.integration.update("integration_id", updated_integration)
```
5. **Delete Integration**
```python
# Delete integration
result = client.integration.delete(
setting_id="integration_id",
setting_type=IntegrationType.USER
)
```
#### Best Practices for Integrations
1. **Error Handling**:
- Handle `NotFoundError` when getting integrations by ID or alias
- Validate integration settings before creation/update
- Use appropriate setting type (USER/PROJECT) based on context
2. **Performance**:
- Use pagination for listing integrations
- Cache frequently accessed integrations when appropriate
- Use filters to reduce result set size
3. **Security**:
- Keep integration credentials secure
- Regularly review and update integration settings
- Use project-level integrations for team-wide settings
- Use user-level integrations for personal settings
### Workflow Service
The Workflow service enables you to create, manage, and execute workflows in CodeMie. Workflows allow you to automate complex processes and integrate various CodeMie services.
#### Core Methods
1. **Create Workflow**
```python
from codemie_sdk.models.workflow import WorkflowCreateRequest
# Create new workflow
workflow_request = WorkflowCreateRequest(
name="My Workflow",
description="Workflow description",
project="project-id",
yaml_config="your-yaml-configuration",
mode="SEQUENTIAL", # Optional, defaults to SEQUENTIAL
shared=False, # Optional, defaults to False
icon_url="https://example.com/icon.png" # Optional
)
result = client.workflow.create_workflow(workflow_request)
```
2. **Update Workflow**
```python
from codemie_sdk.models.workflow import WorkflowUpdateRequest
# Update existing workflow
update_request = WorkflowUpdateRequest(
name="Updated Workflow",
description="Updated description",
yaml_config="updated-yaml-config",
mode="PARALLEL",
shared=True
)
result = client.workflow.update("workflow-id", update_request)
```
3. **List Workflows**
```python
# List workflows with pagination and filtering
workflows = client.workflow.list(
page=0,
per_page=10,
projects=["project1", "project2"] # Optional project filter
)
```
4. **Get Workflow Details**
```python
# Get workflow by ID
workflow = client.workflow.get("workflow-id")
# Get prebuilt workflows
prebuilt_workflows = client.workflow.get_prebuilt()
```
5. **Delete Workflow**
```python
result = client.workflow.delete("workflow-id")
```
#### Workflow Execution
The SDK provides comprehensive workflow execution management through the WorkflowExecutionService:
1. **Run Workflow**
```python
# Simple workflow execution
execution = client.workflow.run("workflow-id", user_input="optional input")
# Get execution service for advanced operations
execution_service = client.workflow.executions("workflow-id")
```
2. **Manage Executions**
```python
# List workflow executions
executions = execution_service.list(
page=0,
per_page=10
)
# Get execution details
execution = execution_service.get("execution-id")
# Abort running execution
result = execution_service.abort("execution-id")
# Resume interrupted execution
result = execution_service.resume("execution-id")
# Delete all executions
result = execution_service.delete_all()
```
3. **Work with Execution States**
```python
# Get execution states
states = execution_service.states(execution_id).list()
# Get state output
state_output = execution_service.states(execution_id).get_output(state_id)
# Example of monitoring workflow with state verification
def verify_workflow_execution(execution_service, execution_id):
execution = execution_service.get(execution_id)
if execution.status == ExecutionStatus.SUCCEEDED:
# Get and verify states
states = execution_service.states(execution_id).list()
# States are ordered by completion date
if len(states) >= 2:
first_state = states[0]
second_state = states[1]
assert first_state.completed_at < second_state.completed_at
# Get state outputs
for state in states:
output = execution_service.states(execution_id).get_output(state.id)
print(f"State {state.id} output: {output.output}")
elif execution.status == ExecutionStatus.FAILED:
print(f"Workflow failed: {execution.error_message}")
```
#### Workflow Configuration
Workflows support various configuration options:
1. **Modes**:
- `SEQUENTIAL`: Tasks execute in sequence
- `PARALLEL`: Tasks can execute simultaneously
2. **YAML Configuration**:
```yaml
name: Example Workflow
description: Workflow description
tasks:
- name: task1
type: llm
config:
prompt: "Your prompt here"
model: "gpt-4"
- name: task2
type: tool
config:
tool_name: "your-tool"
parameters:
param1: "value1"
```
#### Best Practices
1. **Workflow Design**:
- Keep workflows modular and focused
- Use clear, descriptive names for workflows and tasks
- Document workflow purpose and requirements
- Test workflows thoroughly before deployment
2. **Execution Management**:
- Monitor long-running workflows
- Implement proper error handling
- Use pagination for listing executions
- Clean up completed executions regularly
3. **Performance Optimization**:
- Choose appropriate workflow mode (SEQUENTIAL/PARALLEL)
- Manage resource usage in parallel workflows
- Consider task dependencies and ordering
- Use efficient task configurations
4. **Security**:
- Control workflow sharing carefully
- Validate user inputs
- Manage sensitive data appropriately
- Regular audit of workflow access
5. **Maintenance**:
- Regular review of workflow configurations
- Update workflows when dependencies change
- Monitor workflow performance
- Archive or remove unused workflows
#### Error Handling
Implement proper error handling for workflow operations:
```python
try:
workflow = client.workflow.get("workflow-id")
except ApiError as e:
if e.status_code == 404:
print("Workflow not found")
else:
print(f"API error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
```
#### Workflow Status Monitoring
Monitor workflow execution status:
```python
def monitor_execution(execution_service, execution_id):
while True:
execution = execution_service.get(execution_id)
status = execution.status
if status == "COMPLETED":
print("Workflow completed successfully")
break
elif status == "FAILED":
print(f"Workflow failed: {execution.error}")
break
elif status == "ABORTED":
print("Workflow was aborted")
break
time.sleep(5) # Poll every 5 seconds
```
## Error Handling
The SDK implements comprehensive error handling. All API calls may raise exceptions for:
- Authentication failures
- Network errors
- Invalid parameters
- Server-side errors
It's recommended to implement try-catch blocks around SDK operations to handle potential exceptions gracefully.
## Authentication
The SDK supports two authentication methods through Keycloak:
1. Username/Password Authentication
2. Client Credentials Authentication
### Required Parameters
You must provide either:
- Username/Password credentials:
```python
{
"username": "your-username",
"password": "your-password",
"auth_client_id": "client-id", # Optional, defaults to "codemie-sdk"
"auth_realm_name": "realm-name",
"auth_server_url": "keycloak-url",
"verify_ssl": True # Optional, defaults to True
}
```
OR
- Client Credentials:
```python
{
"auth_client_id": "your-client-id",
"auth_client_secret": "your-client-secret",
"auth_realm_name": "realm-name",
"auth_server_url": "keycloak-url",
"verify_ssl": True # Optional, defaults to True
}
```
### Usage Examples
1. Username/Password Authentication:
```python
from codemie_sdk import CodeMieClient
client = CodeMieClient(
codemie_api_domain="https://api.domain.com",
username="your-username",
password="your-password",
auth_client_id="your-client-id", # Optional
auth_realm_name="your-realm",
auth_server_url="https://keycloak.domain.com/auth",
verify_ssl=True # Optional
)
```
2. Client Credentials Authentication:
```python
from codemie_sdk.auth import KeycloakCredentials
credentials = KeycloakCredentials(
server_url="https://keycloak.domain.com/auth",
realm_name="your-realm",
client_id="your-client-id",
client_secret="your-client-secret",
verify_ssl=True # Optional
)
client = CodeMieClient(
codemie_api_domain="https://api.domain.com",
credentials=credentials
)
```
## Support
For providing credentials please contact AI/Run CodeMie Team: Vadym_Vlasenko@epam.com or Nikita_Levyankov@epam.com
## Running tests
For running tests on custom environment you should create .env file in the ./tests directory,
ask QA team: anton_yeromin@epam.com to provide all needed testing credentials. Under this directory there are stubs
for .env files for running tests on local and preview environments.
Configuration example:
``` properties
AUTH_SERVER_URL=https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth
AUTH_CLIENT_ID=codemie-preview
AUTH_CLIENT_SECRET=<auth_clienbt_secret>
AUTH_REALM_NAME=codemie-prod
CODEMIE_API_DOMAIN=http://localhost:8080
VERIFY_SSL=False
NATS_URL=nats://localhost:4222
ENV=local
CLEANUP_DATA=True
AUTH_USERNAME=<username>
AUTH_PASSWORD=<password>
TEST_USER_FULL_NAME=<user_full_name>
PROJECT_NAME=codemie
GIT_ENV=gitlab
DEFAULT_TIMEOUT=60
GITLAB_URL=https://gitbud.epam.com
GITLAB_TOKEN=<gitlab_token>
GITLAB_PROJECT=https://gitbud.epam.com/epm-cdme/autotests/codemie-test-project
GITLAB_PROJECT_ID=17889
GITHUB_URL=https://github.com
GITHUB_TOKEN=<github_token>
GITHUB_PROJECT=https://github.com/wild47/final_task
JIRA_URL=https://jiraeu.epam.com
JIRA_TOKEN=<jira_token>
JQL="project = 'EPMCDME' and issuetype = 'Epic' and status = 'Closed'"
CONFLUENCE_URL=https://kb.epam.com
CONFLUENCE_TOKEN=<confluence_token>
CQL="space = EPMCDME and type = page and title = 'AQA Backlog Estimation'"
AWS_ACCESS_KEY=<aws_access_token>
AWS_SECRET_KEY=<aws_secret_key>
RP_API_KEY=<report_portal_key_optional>
```
Run all tests (-n - number of parallel workers. Fill free to change it to find the best that suits your environment)
```shell
pytest -n 10 --reruns 2
```
Run e2e/regression tests
```shell
pytest -n 10 -m "e2e or regression" --reruns 2
```
Run UI tests
First you have to install playwright browsers:
```shell
playwright install
```
and then
```shell
pytest -n 4 -m ui --reruns 2
```
All Playwright documentation can be found by the following link: https://playwright.dev/python/docs/intro
Run tests for e2e tests for specific integration/tool.
Available marks:
- jira_kb
- confluence_kb
- code_kb
- gitlab
- github
- git
```shell
pytest -n 10 -m "jira_kb or github" --reruns 2
```
In case you want to send test results in **ReportPortal** you should specify RP_API_KEY in .env and run tests like this:
```shell
pytest -n 10 -m "e2e or regression" --reruns 2 --reportportal
```
ReportPortal link is available by the following URL: https://report-portal.core.kuberocketci.io/ui/#epm-cdme/launches/all
If you do not have access to the project ask Anton Yeromin (anton_yeromin@epam.com) to add you.
Raw data
{
"_id": null,
"home_page": null,
"name": "codemie-sdk-python",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.12",
"maintainer_email": null,
"keywords": null,
"author": "Vadym Vlasenko",
"author_email": "vadym_vlasenko@epam.com",
"download_url": "https://files.pythonhosted.org/packages/8b/2a/c3c6aba7cd5d1552f912e57f257180314493e034c01f77cb7cfb63438a0d/codemie_sdk_python-0.1.132.tar.gz",
"platform": null,
"description": "# CodeMie Python SDK\n\nPython SDK for CodeMie services. This SDK provides a comprehensive interface to interact with CodeMie services, including LLM (Large Language Models), assistants, workflows, and tools.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n - [Basic Usage](#basic-usage)\n- [Service Details](#service-details)\n - [LLM Service](#llm-service)\n - [Assistant Service](#assistant-service)\n - [Core Methods](#core-methods)\n - [Advanced Features](#advanced-features)\n - [Datasource Service](#datasource-service)\n - [Supported Datasource Types](#supported-datasource-types)\n - [Core Methods](#core-methods-1)\n - [Datasource Status](#datasource-status)\n - [Best Practices for Datasources](#best-practices-for-datasources)\n - [Integration Service](#integration-service)\n - [Integration Types](#integration-types)\n - [Core Methods](#core-methods-2)\n - [Best Practices for Integrations](#best-practices-for-integrations)\n - [Workflow Service](#workflow-service)\n - [Core Methods](#core-methods-3)\n - [Workflow Execution](#workflow-execution)\n - [Workflow Configuration](#workflow-configuration)\n - [Best Practices](#best-practices)\n - [Error Handling](#error-handling)\n - [Workflow Status Monitoring](#workflow-status-monitoring)\n- [Development](#development)\n - [Setup](#setup)\n - [Running Tests](#running-tests)\n - [Building Package](#building-package)\n- [Error Handling](#error-handling-1)\n- [Authentication](#authentication)\n - [Required Parameters](#required-parameters)\n - [Usage Examples](#usage-examples)\n- [Best Practices](#best-practices-1)\n- [Support](#support)\n\n## Installation\n\n```sh\npip install codemie-sdk\n```\nOR\n```sh\npoetry install\n```\n\n### If you want to run only tests, go to ## Running tests section\n\n## Usage\n\n### Basic usage\n\n```python\nfrom codemie_sdk import CodeMieClient\n\n# Initialize client with authentication parameters\nclient = CodeMieClient(\n auth_server_url=\"https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth\",\n auth_client_id=\"your-client-id\",\n auth_client_secret=\"your-client-secret\",\n auth_realm_name=\"your-realm\",\n codemie_api_domain=\"https://codemie.lab.epam.com/code-assistant-api\"\n)\n```\n\n## Service Details\n\n### LLM Service\n\nThe LLM service provides access to language models and embedding models:\n\n- **list()**: Retrieves a list of available LLM models\n ```python\n llm_models = client.llm.list(token=client.token)\n ```\n\n- **list_embeddings()**: Retrieves a list of available embedding models\n ```python\n embedding_models = client.llm.list_embeddings(token=client.token)\n ```\n\nEach LLM model contains the following information:\n- Model identifier\n- Model capabilities\n- Configuration parameters\n\nExample usage:\n```python\n# List available LLM models\nllm_models = client.llm.list(token=client.token)\n\n# List available embedding models\nembedding_models = client.llm.list_embeddings(token=client.token)\n```\n\n### Assistant Service\n\nThe Assistant service allows you to manage and interact with CodeMie assistants:\n\n#### Core Methods\n\n1. **List Assistants**\n```python\nassistants = client.assistant.list(\n minimal_response=True, # Return minimal assistant info\n scope=\"visible_to_user\", # or \"created_by_user\"\n page=0,\n per_page=12,\n filters={\"key\": \"value\"} # Optional filters\n)\n```\n\n2. **Get Assistant Details**\n```python\n# By ID\nassistant = client.assistant.get(\"assistant-id\")\n\n# By Slug\nassistant = client.assistant.get_by_slug(\"assistant-slug\")\n```\n\n3. **Create Assistant**\n```python\nfrom codemie_sdk.models.assistant import AssistantCreateRequest\n\nrequest = AssistantCreateRequest(\n name=\"My Assistant\",\n description=\"Assistant description\",\n instructions=\"Assistant instructions\",\n tools=[\"tool1\", \"tool2\"],\n # Additional parameters as needed\n)\nnew_assistant = client.assistant.create(request)\n```\n\n4. **Update Assistant**\n```python\nfrom codemie_sdk.models.assistant import AssistantUpdateRequest\n\nrequest = AssistantUpdateRequest(\n name=\"Updated Name\",\n description=\"Updated description\",\n # Other fields to update\n)\nupdated_assistant = client.assistant.update(\"assistant-id\", request)\n```\n\n5. **Delete Assistant**\n```python\nresult = client.assistant.delete(\"assistant-id\")\n```\n\n#### Advanced Features\n\n6. **Chat with Assistant**\n```python\nfrom codemie_sdk.models.assistant import AssistantChatRequest\n\nchat_request = AssistantChatRequest(\n text=\"Your message here\",\n stream=False, # Set to True for streaming response\n # Additional parameters\n)\nresponse = client.assistant.chat(\"assistant-id\", chat_request)\n```\n\n7. **Utilize structured outputs with Assistant**\n```python\nfrom pydantic import BaseModel\n\nclass OutputSchema(BaseModel):\n requirements: list[str]\n\nchat_request = AssistantChatRequest(\n text=\"Your message here\",\n stream=False, \n output_schema=OutputSchema\n # Additional parameters\n)\n\nresponse = client.assistants.chat(\"id\", chat_request)\n# response.generated is a Pydantic object\n```\nOr using JSON schema in dict format\n```python\noutput_schema = {\n \"properties\": {\n \"requirements\": {\n \"items\": {\"type\": \"string\"},\n \"title\": \"Requirements\",\n \"type\": \"array\",\n }\n },\n \"required\": [\"requirements\"],\n \"title\": \"OutputSchema\",\n \"type\": \"object\",\n}\n\nchat_request = AssistantChatRequest(\n text=\"Your message here\",\n stream=False, \n output_schema=output_schema \n # Additional parameters\n)\n\nresponse = client.assistants.chat(\"id\", chat_request)\n# response.generated is a dict corresponded with JSON schema\n```\n\n8. **Work with Prebuilt Assistants**\n```python\n# List prebuilt assistants\nprebuilt = client.assistant.get_prebuilt()\n\n# Get specific prebuilt assistant\nprebuilt_assistant = client.assistant.get_prebuilt_by_slug(\"assistant-slug\")\n```\n\n9. **Get Available Tools**\n```python\ntools = client.assistant.get_tools()\n```\n\n### Datasource Service\n\nThe Datasource service enables managing various types of data sources in CodeMie, including code repositories, Confluence spaces, Jira projects, files, and Google documents.\n\n#### Supported Datasource Types\n\n- `CODE`: Code repository datasources\n- `CONFLUENCE`: Confluence knowledge base\n- `JIRA`: Jira knowledge base\n- `FILE`: File-based knowledge base\n- `GOOGLE`: Google documents\n\n#### Core Methods\n\n1. **Create Datasource**\n```python\nfrom codemie_sdk.models.datasource import (\n CodeDataSourceRequest,\n ConfluenceDataSourceRequest,\n JiraDataSourceRequest,\n GoogleDataSourceRequest\n)\n\n# Create Code Datasource\ncode_request = CodeDataSourceRequest(\n name=\"my_repo\", # lowercase letters and underscores only\n project_name=\"my_project\",\n description=\"My code repository\",\n link=\"https://github.com/user/repo\",\n branch=\"main\",\n index_type=\"code\", # or \"summary\" or \"chunk-summary\"\n files_filter=\"*.py\", # optional\n embeddings_model=\"model_name\",\n summarization_model=\"gpt-4\", # optional\n docs_generation=False # optional\n)\nresult = client.datasource.create(code_request)\n\n# Create Confluence Datasource\nconfluence_request = ConfluenceDataSourceRequest(\n name=\"confluence_kb\",\n project_name=\"my_project\",\n description=\"Confluence space\",\n cql=\"space = 'MYSPACE'\",\n include_restricted_content=False,\n include_archived_content=False,\n include_attachments=True,\n include_comments=True\n)\nresult = client.datasource.create(confluence_request)\n\n# Create Jira Datasource\njira_request = JiraDataSourceRequest(\n name=\"jira_kb\",\n project_name=\"my_project\",\n description=\"Jira project\",\n jql=\"project = 'MYPROJECT'\"\n)\nresult = client.datasource.create(jira_request)\n\n# Create Google Doc Datasource\ngoogle_request = GoogleDataSourceRequest(\n name=\"google_doc\",\n project_name=\"my_project\",\n description=\"Google document\",\n google_doc=\"document_url\"\n)\nresult = client.datasource.create(google_request)\n```\n\n2. **Update Datasource**\n```python\nfrom codemie_sdk.models.datasource import UpdateCodeDataSourceRequest\n\n# Update Code Datasource\nupdate_request = UpdateCodeDataSourceRequest(\n name=\"my_repo\",\n project_name=\"my_project\",\n description=\"Updated description\",\n branch=\"develop\",\n full_reindex=True, # optional reindex parameters\n skip_reindex=False,\n resume_indexing=False\n)\nresult = client.datasource.update(\"datasource_id\", update_request)\n```\n\n3. **List Datasources**\n```python\n# List all datasources with filtering and pagination\ndatasources = client.datasource.list(\n page=0,\n per_page=10,\n sort_key=\"update_date\", # or \"date\"\n sort_order=\"desc\", # or \"asc\"\n datasource_types=[\"CODE\", \"CONFLUENCE\"], # optional filter by type\n projects=[\"project1\", \"project2\"], # optional filter by projects\n owner=\"John Doe\", # optional filter by owner\n status=\"COMPLETED\" # optional filter by status\n)\n```\n\n4. **Get Datasource Details**\n```python\n# Get single datasource by ID\ndatasource = client.datasource.get(\"datasource_id\")\n```\n\n5. **Delete Datasource**\n```python\n# Delete datasource by ID\nresult = client.datasource.delete(\"datasource_id\")\n```\n\n#### Datasource Status\n\nDatasources can have the following statuses:\n- `COMPLETED`: Indexing completed successfully\n- `FAILED`: Indexing failed\n- `FETCHING`: Fetching data from source\n- `IN_PROGRESS`: Processing/indexing in progress\n\n#### Best Practices for Datasources\n\n1. **Naming Convention**:\n - Use lowercase letters and underscores for datasource names\n - Keep names descriptive but concise\n\n2. **Performance Optimization**:\n - Use appropriate filters when listing datasources\n - Consider pagination for large result sets\n - Choose appropriate reindex options based on your needs\n\n3. **Error Handling**:\n - Always check datasource status after creation/update\n - Handle potential failures gracefully\n - Monitor processing information for issues\n\n4. **Security**:\n - Be careful with sensitive data in filters and queries\n - Use proper access controls when sharing datasources\n - Regularly review and clean up unused datasources\n\n### Integration Service\n\nThe Integration service manages both user and project-level integrations in CodeMie, allowing you to configure and manage various integration settings.\n\n#### Integration Types\n\n- `USER`: User-level integrations\n- `PROJECT`: Project-level integrations\n\n#### Core Methods\n\n1. **List Integrations**\n```python\nfrom codemie_sdk.models.integration import IntegrationType\n\n# List user integrations with pagination\nuser_integrations = client.integration.list(\n setting_type=IntegrationType.USER,\n page=0,\n per_page=10,\n filters={\"some_filter\": \"value\"} # optional\n)\n\n# List project integrations\nproject_integrations = client.integration.list(\n setting_type=IntegrationType.PROJECT,\n per_page=100\n)\n```\n\n2. **Get Integration**\n```python\n# Get integration by ID\nintegration = client.integration.get(\n integration_id=\"integration_id\",\n setting_type=IntegrationType.USER\n)\n\n# Get integration by alias\nintegration = client.integration.get_by_alias(\n alias=\"integration_alias\",\n setting_type=IntegrationType.PROJECT\n)\n```\n\n3. **Create Integration**\n```python\nfrom codemie_sdk.models.integration import Integration\n\n# Create new integration\nnew_integration = Integration(\n setting_type=IntegrationType.USER,\n alias=\"my_integration\",\n # Add other required fields based on integration type\n)\nresult = client.integration.create(new_integration)\n```\n\n4. **Update Integration**\n```python\n# Update existing integration\nupdated_integration = Integration(\n setting_type=IntegrationType.USER,\n alias=\"updated_alias\",\n # Add other fields to update\n)\nresult = client.integration.update(\"integration_id\", updated_integration)\n```\n\n5. **Delete Integration**\n```python\n# Delete integration\nresult = client.integration.delete(\n setting_id=\"integration_id\",\n setting_type=IntegrationType.USER\n)\n```\n\n#### Best Practices for Integrations\n\n1. **Error Handling**:\n - Handle `NotFoundError` when getting integrations by ID or alias\n - Validate integration settings before creation/update\n - Use appropriate setting type (USER/PROJECT) based on context\n\n2. **Performance**:\n - Use pagination for listing integrations\n - Cache frequently accessed integrations when appropriate\n - Use filters to reduce result set size\n\n3. **Security**:\n - Keep integration credentials secure\n - Regularly review and update integration settings\n - Use project-level integrations for team-wide settings\n - Use user-level integrations for personal settings\n\n### Workflow Service\n\nThe Workflow service enables you to create, manage, and execute workflows in CodeMie. Workflows allow you to automate complex processes and integrate various CodeMie services.\n\n#### Core Methods\n\n1. **Create Workflow**\n```python\nfrom codemie_sdk.models.workflow import WorkflowCreateRequest\n\n# Create new workflow\nworkflow_request = WorkflowCreateRequest(\n name=\"My Workflow\",\n description=\"Workflow description\",\n project=\"project-id\",\n yaml_config=\"your-yaml-configuration\",\n mode=\"SEQUENTIAL\", # Optional, defaults to SEQUENTIAL\n shared=False, # Optional, defaults to False\n icon_url=\"https://example.com/icon.png\" # Optional\n)\nresult = client.workflow.create_workflow(workflow_request)\n```\n\n2. **Update Workflow**\n```python\nfrom codemie_sdk.models.workflow import WorkflowUpdateRequest\n\n# Update existing workflow\nupdate_request = WorkflowUpdateRequest(\n name=\"Updated Workflow\",\n description=\"Updated description\",\n yaml_config=\"updated-yaml-config\",\n mode=\"PARALLEL\",\n shared=True\n)\nresult = client.workflow.update(\"workflow-id\", update_request)\n```\n\n3. **List Workflows**\n```python\n# List workflows with pagination and filtering\nworkflows = client.workflow.list(\n page=0,\n per_page=10,\n projects=[\"project1\", \"project2\"] # Optional project filter\n)\n```\n\n4. **Get Workflow Details**\n```python\n# Get workflow by ID\nworkflow = client.workflow.get(\"workflow-id\")\n\n# Get prebuilt workflows\nprebuilt_workflows = client.workflow.get_prebuilt()\n```\n\n5. **Delete Workflow**\n```python\nresult = client.workflow.delete(\"workflow-id\")\n```\n\n#### Workflow Execution\n\nThe SDK provides comprehensive workflow execution management through the WorkflowExecutionService:\n\n1. **Run Workflow**\n```python\n# Simple workflow execution\nexecution = client.workflow.run(\"workflow-id\", user_input=\"optional input\")\n\n# Get execution service for advanced operations\nexecution_service = client.workflow.executions(\"workflow-id\")\n```\n\n2. **Manage Executions**\n```python\n# List workflow executions\nexecutions = execution_service.list(\n page=0,\n per_page=10\n)\n\n# Get execution details\nexecution = execution_service.get(\"execution-id\")\n\n# Abort running execution\nresult = execution_service.abort(\"execution-id\")\n\n# Resume interrupted execution\nresult = execution_service.resume(\"execution-id\")\n\n# Delete all executions\nresult = execution_service.delete_all()\n```\n\n3. **Work with Execution States**\n```python\n# Get execution states\nstates = execution_service.states(execution_id).list()\n\n# Get state output\nstate_output = execution_service.states(execution_id).get_output(state_id)\n\n# Example of monitoring workflow with state verification\ndef verify_workflow_execution(execution_service, execution_id):\n execution = execution_service.get(execution_id)\n \n if execution.status == ExecutionStatus.SUCCEEDED:\n # Get and verify states\n states = execution_service.states(execution_id).list()\n \n # States are ordered by completion date\n if len(states) >= 2:\n first_state = states[0]\n second_state = states[1]\n assert first_state.completed_at < second_state.completed_at\n \n # Get state outputs\n for state in states:\n output = execution_service.states(execution_id).get_output(state.id)\n print(f\"State {state.id} output: {output.output}\")\n \n elif execution.status == ExecutionStatus.FAILED:\n print(f\"Workflow failed: {execution.error_message}\")\n```\n\n#### Workflow Configuration\n\nWorkflows support various configuration options:\n\n1. **Modes**:\n- `SEQUENTIAL`: Tasks execute in sequence\n- `PARALLEL`: Tasks can execute simultaneously\n\n2. **YAML Configuration**:\n```yaml\nname: Example Workflow\ndescription: Workflow description\ntasks:\n - name: task1\n type: llm\n config:\n prompt: \"Your prompt here\"\n model: \"gpt-4\"\n \n - name: task2\n type: tool\n config:\n tool_name: \"your-tool\"\n parameters:\n param1: \"value1\"\n```\n\n#### Best Practices\n\n1. **Workflow Design**:\n- Keep workflows modular and focused\n- Use clear, descriptive names for workflows and tasks\n- Document workflow purpose and requirements\n- Test workflows thoroughly before deployment\n\n2. **Execution Management**:\n- Monitor long-running workflows\n- Implement proper error handling\n- Use pagination for listing executions\n- Clean up completed executions regularly\n\n3. **Performance Optimization**:\n- Choose appropriate workflow mode (SEQUENTIAL/PARALLEL)\n- Manage resource usage in parallel workflows\n- Consider task dependencies and ordering\n- Use efficient task configurations\n\n4. **Security**:\n- Control workflow sharing carefully\n- Validate user inputs\n- Manage sensitive data appropriately\n- Regular audit of workflow access\n\n5. **Maintenance**:\n- Regular review of workflow configurations\n- Update workflows when dependencies change\n- Monitor workflow performance\n- Archive or remove unused workflows\n\n#### Error Handling\n\nImplement proper error handling for workflow operations:\n\n```python\ntry:\n workflow = client.workflow.get(\"workflow-id\")\nexcept ApiError as e:\n if e.status_code == 404:\n print(\"Workflow not found\")\n else:\n print(f\"API error: {e}\")\nexcept Exception as e:\n print(f\"Unexpected error: {e}\")\n```\n\n#### Workflow Status Monitoring\n\nMonitor workflow execution status:\n\n```python\ndef monitor_execution(execution_service, execution_id):\n while True:\n execution = execution_service.get(execution_id)\n status = execution.status\n \n if status == \"COMPLETED\":\n print(\"Workflow completed successfully\")\n break\n elif status == \"FAILED\":\n print(f\"Workflow failed: {execution.error}\")\n break\n elif status == \"ABORTED\":\n print(\"Workflow was aborted\")\n break\n \n time.sleep(5) # Poll every 5 seconds\n```\n\n## Error Handling\n\nThe SDK implements comprehensive error handling. All API calls may raise exceptions for:\n- Authentication failures\n- Network errors\n- Invalid parameters\n- Server-side errors\n\nIt's recommended to implement try-catch blocks around SDK operations to handle potential exceptions gracefully.\n\n## Authentication\n\nThe SDK supports two authentication methods through Keycloak:\n\n1. Username/Password Authentication\n2. Client Credentials Authentication\n\n### Required Parameters\n\nYou must provide either:\n\n- Username/Password credentials:\n ```python\n {\n \"username\": \"your-username\", \n \"password\": \"your-password\",\n \"auth_client_id\": \"client-id\", # Optional, defaults to \"codemie-sdk\"\n \"auth_realm_name\": \"realm-name\",\n \"auth_server_url\": \"keycloak-url\",\n \"verify_ssl\": True # Optional, defaults to True\n }\n ```\n\nOR\n\n- Client Credentials:\n ```python\n {\n \"auth_client_id\": \"your-client-id\",\n \"auth_client_secret\": \"your-client-secret\",\n \"auth_realm_name\": \"realm-name\", \n \"auth_server_url\": \"keycloak-url\",\n \"verify_ssl\": True # Optional, defaults to True\n }\n ```\n\n### Usage Examples\n\n1. Username/Password Authentication:\n```python\nfrom codemie_sdk import CodeMieClient\n\nclient = CodeMieClient(\n codemie_api_domain=\"https://api.domain.com\",\n username=\"your-username\",\n password=\"your-password\",\n auth_client_id=\"your-client-id\", # Optional\n auth_realm_name=\"your-realm\",\n auth_server_url=\"https://keycloak.domain.com/auth\",\n verify_ssl=True # Optional\n)\n```\n\n2. Client Credentials Authentication:\n```python\nfrom codemie_sdk.auth import KeycloakCredentials\n\ncredentials = KeycloakCredentials(\n server_url=\"https://keycloak.domain.com/auth\",\n realm_name=\"your-realm\",\n client_id=\"your-client-id\",\n client_secret=\"your-client-secret\",\n verify_ssl=True # Optional\n)\n\nclient = CodeMieClient(\n codemie_api_domain=\"https://api.domain.com\",\n credentials=credentials\n)\n```\n\n## Support\nFor providing credentials please contact AI/Run CodeMie Team: Vadym_Vlasenko@epam.com or Nikita_Levyankov@epam.com\n\n## Running tests\n\nFor running tests on custom environment you should create .env file in the ./tests directory,\nask QA team: anton_yeromin@epam.com to provide all needed testing credentials. Under this directory there are stubs\nfor .env files for running tests on local and preview environments.\n\nConfiguration example:\n\n``` properties\n\nAUTH_SERVER_URL=https://keycloak.eks-core.aws.main.edp.projects.epam.com/auth\nAUTH_CLIENT_ID=codemie-preview\nAUTH_CLIENT_SECRET=<auth_clienbt_secret>\nAUTH_REALM_NAME=codemie-prod\nCODEMIE_API_DOMAIN=http://localhost:8080\nVERIFY_SSL=False\n\nNATS_URL=nats://localhost:4222\n\nENV=local\nCLEANUP_DATA=True\n\nAUTH_USERNAME=<username>\nAUTH_PASSWORD=<password>\nTEST_USER_FULL_NAME=<user_full_name>\n\nPROJECT_NAME=codemie\nGIT_ENV=gitlab\n\nDEFAULT_TIMEOUT=60\n\nGITLAB_URL=https://gitbud.epam.com\nGITLAB_TOKEN=<gitlab_token>\nGITLAB_PROJECT=https://gitbud.epam.com/epm-cdme/autotests/codemie-test-project\nGITLAB_PROJECT_ID=17889\n\nGITHUB_URL=https://github.com\nGITHUB_TOKEN=<github_token>\nGITHUB_PROJECT=https://github.com/wild47/final_task\n\nJIRA_URL=https://jiraeu.epam.com\nJIRA_TOKEN=<jira_token>\nJQL=\"project = 'EPMCDME' and issuetype = 'Epic' and status = 'Closed'\"\n\nCONFLUENCE_URL=https://kb.epam.com\nCONFLUENCE_TOKEN=<confluence_token>\nCQL=\"space = EPMCDME and type = page and title = 'AQA Backlog Estimation'\"\n\nAWS_ACCESS_KEY=<aws_access_token>\nAWS_SECRET_KEY=<aws_secret_key>\n\nRP_API_KEY=<report_portal_key_optional>\n```\n\nRun all tests (-n - number of parallel workers. Fill free to change it to find the best that suits your environment)\n\n```shell\npytest -n 10 --reruns 2\n```\n\nRun e2e/regression tests\n\n```shell\npytest -n 10 -m \"e2e or regression\" --reruns 2\n```\n\nRun UI tests\n\nFirst you have to install playwright browsers:\n\n```shell\nplaywright install\n```\nand then\n\n```shell\npytest -n 4 -m ui --reruns 2\n```\n\nAll Playwright documentation can be found by the following link: https://playwright.dev/python/docs/intro\n\nRun tests for e2e tests for specific integration/tool.\nAvailable marks:\n - jira_kb\n - confluence_kb\n - code_kb\n - gitlab\n - github\n - git\n\n```shell\npytest -n 10 -m \"jira_kb or github\" --reruns 2\n```\n\nIn case you want to send test results in **ReportPortal** you should specify RP_API_KEY in .env and run tests like this:\n\n```shell\npytest -n 10 -m \"e2e or regression\" --reruns 2 --reportportal\n```\n\nReportPortal link is available by the following URL: https://report-portal.core.kuberocketci.io/ui/#epm-cdme/launches/all\n\nIf you do not have access to the project ask Anton Yeromin (anton_yeromin@epam.com) to add you.\n",
"bugtrack_url": null,
"license": null,
"summary": "CodeMie SDK for Python",
"version": "0.1.132",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e6721113f7b537df65d89f07d1c6614cb550e9eea2f449d36b23145d1f7435f6",
"md5": "4f3273fd2d8514a57ee9d5be8ef29b14",
"sha256": "a9e804fb6e3d852e4d00209f39b1585e77c177619170c4389004dcca661ba037"
},
"downloads": -1,
"filename": "codemie_sdk_python-0.1.132-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4f3273fd2d8514a57ee9d5be8ef29b14",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 36814,
"upload_time": "2025-08-29T14:47:07",
"upload_time_iso_8601": "2025-08-29T14:47:07.093128Z",
"url": "https://files.pythonhosted.org/packages/e6/72/1113f7b537df65d89f07d1c6614cb550e9eea2f449d36b23145d1f7435f6/codemie_sdk_python-0.1.132-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8b2ac3c6aba7cd5d1552f912e57f257180314493e034c01f77cb7cfb63438a0d",
"md5": "103afe6c9320e4d008ec39a980ac544e",
"sha256": "08b3b17e7e8d2f5027f35821b76d6b67fb2be631d416cbac0083eb5458950084"
},
"downloads": -1,
"filename": "codemie_sdk_python-0.1.132.tar.gz",
"has_sig": false,
"md5_digest": "103afe6c9320e4d008ec39a980ac544e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 31558,
"upload_time": "2025-08-29T14:47:08",
"upload_time_iso_8601": "2025-08-29T14:47:08.373625Z",
"url": "https://files.pythonhosted.org/packages/8b/2a/c3c6aba7cd5d1552f912e57f257180314493e034c01f77cb7cfb63438a0d/codemie_sdk_python-0.1.132.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-29 14:47:08",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "codemie-sdk-python"
}