### Install Development Dependencies Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Install dependencies required for development, typically listed in requirements.txt. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies with Pip Source: https://github.com/omnifactai/omnifact-cli/blob/master/CLAUDE.md Install the package in editable mode and development dependencies. Ensure you are in a virtual environment. ```bash pip install -e . ``` ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Omnifact CLI Package Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Install the Omnifact CLI package in editable mode. This allows for development and testing. ```bash pip install -e . ``` -------------------------------- ### Configuration Commands Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Commands for setting and getting the API key and Connect URL. These can be persisted in a config file or overridden via environment variables. ```APIDOC ## Configuration Commands ### `config set-api-key` / `config get-api-key` Persists or retrieves the Omnifact API key in `~/.omnifact_cli.ini`. The environment variable `OMNIFACT_API_KEY` takes precedence. ```bash # Store API key permanently omnifact-cli config set-api-key sk-abc123 # Verify stored key omnifact-cli config get-api-key # Output: Current API key: sk-abc123 ``` ### `config set-connect-url` / `config get-connect-url` Overrides the default Omnifact Connect API base URL (`https://connect.omnifact.ai`). The environment variable `OMNIFACT_CONNECT_URL` also overrides the stored value. ```bash # Point to a custom Connect instance omnifact-cli config set-connect-url https://connect.my-company.com # Verify omnifact-cli config get-connect-url # Output: Current Connect URL: https://connect.my-company.com ``` ``` -------------------------------- ### Clone Omnifact CLI Repository Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Clone the Omnifact CLI repository to your local machine. This is the first step for installation. ```bash git clone https://github.com/OmnifactAI/omnifact-cli.git cd omnifact-cli ``` -------------------------------- ### List Supported File Types Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Query the Omnifact API to get a list of all supported MIME types and their corresponding file extensions for document uploads. ```bash omnifact-cli list-supported-types # Output: # Supported file types: # application/pdf: pdf # text/plain: txt, text # application/vnd.openxmlformats-officedocument.wordprocessingml.document: docx # text/markdown: md ``` -------------------------------- ### Start an interactive chat session Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Initiate a persistent multi-turn conversation with an AI endpoint using the `chat -i` command. Conversation history is maintained in memory. Type 'exit' or 'quit' to end. ```bash omnifact-cli chat --endpoint-id endpoint-abc -i # Output: # Interactive chat started. Type 'exit' or 'quit' to end the session. # -------------------------------------------------- # You: What is the Omnifact API? # Assistant: The Omnifact API allows you to manage documents and interact # with AI assistants programmatically... # You: Can you give me a Python example? # Assistant: Sure! Here is how you can list documents using the requests library... # You: exit # Goodbye! ``` -------------------------------- ### Get Document Details Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Retrieve details for a specific document using its ID. ```bash omnifact-cli get-document DOCUMENT_ID ``` -------------------------------- ### Get supported file types using OmnifactAPI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Retrieve a list of file types supported by Omnifact, including their MIME types and associated extensions, using the `get_supported_file_types` method. ```python types = api.get_supported_file_types() for t in types: print(t["mimeType"], t["extensions"]) ``` -------------------------------- ### Chat (Interactive Mode) Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Starts a persistent multi-turn conversation session with an AI endpoint. Conversation history is maintained in memory for the duration of the session, enabling follow-up questions. Type `exit` or `quit` to end the session. ```APIDOC ## chat (interactive mode) ### Description Starts a persistent multi-turn conversation session with an AI endpoint. Conversation history is maintained in memory for the duration of the session, enabling follow-up questions. Type `exit` or `quit` to end the session. ### Usage ```bash omnifact-cli chat --endpoint-id -i ``` ### Example ```bash omnifact-cli chat --endpoint-id endpoint-abc -i # Output: # Interactive chat started. Type 'exit' or 'quit' to end the session. # -------------------------------------------------- # You: What is the Omnifact API? # Assistant: The Omnifact API allows you to manage documents and interact # with AI assistants programmatically... # You: Can you give me a Python example? # Assistant: Sure! Here is how you can list documents using the requests library... # You: exit # Goodbye! ``` ``` -------------------------------- ### Display Help Information Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Display all available commands and their usage information. ```bash omnifact-cli --help ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Create a Python virtual environment and activate it. This isolates project dependencies. ```bash python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate ``` -------------------------------- ### Use Environment Variables for Configuration Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Configure API key and Connect URL using environment variables. Useful for scripts and CI/CD. ```bash OMNIFACT_API_KEY=your_api_key OMNIFACT_CONNECT_URL=https://your-connect-url.com omnifact-cli list-documents --space-id YOUR_SPACE_ID ``` -------------------------------- ### Initialize OmnifactAPI and list documents Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Instantiate the OmnifactAPI class with your API key and base URL. Use the `get_documents` method to retrieve documents from a space, handling pagination with offset and limit. ```python from omnifact_cli.api import OmnifactAPI api = OmnifactAPI(api_key="sk-abc123", base_url="https://connect.omnifact.ai") # List documents (paginated) page = api.get_documents("space-xyz-789", offset=0, limit=100) for doc in page["items"]: print(doc["id"], doc["name"]) ``` -------------------------------- ### List Supported File Types Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md List all file types that the Omnifact CLI supports for upload. ```bash omnifact-cli list-supported-types ``` -------------------------------- ### Upload Document with Options Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Upload a file to a space, with options for a custom display name, JSON metadata, and explicit file encoding. The encoding is sent as a `Content-Transfer-Encoding` header. ```bash # Basic upload omnifact-cli upload-document --space-id space-xyz-789 --file ./report.pdf # Upload with custom name and metadata omnifact-cli upload-document \ --space-id space-xyz-789 \ --file ./report.pdf \ --name "Q4 Financial Report" \ --metadata '{"url": "https://example.com/reports/q4.pdf", "author": "finance-team"}' # Upload a legacy Windows-encoded text file omnifact-cli upload-document \ --space-id space-xyz-789 \ --file ./legacy-export.txt \ --encoding windows-1252 # Output: # Document uploaded successfully. ID: doc-004 ``` -------------------------------- ### Configure Omnifact API Key Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Set your Omnifact API key using the CLI. This is required for authentication. ```bash omnifact-cli config set-api-key YOUR_API_KEY ``` -------------------------------- ### Configure API Key with Omnifact CLI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Store or retrieve your Omnifact API key using the `config set-api-key` and `config get-api-key` commands. The `OMNIFACT_API_KEY` environment variable takes precedence. ```bash omnifact-cli config set-api-key sk-abc123 omnifact-cli config get-api-key # Output: Current API key: sk-abc123 export OMNIFACT_API_KEY=sk-abc123 omnifact-cli list-documents --space-id my-space OMNIFACT_API_KEY=sk-abc123 omnifact-cli list-documents --space-id my-space ``` -------------------------------- ### Configure Omnifact Connect URL Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Optionally, set your Omnifact Connect URL using the CLI. This specifies the API endpoint. ```bash omnifact-cli config set-connect-url YOUR_CONNECT_URL ``` -------------------------------- ### Run Tests Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Execute the project's test suite using pytest. ```bash pytest ``` -------------------------------- ### Upload a Document Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Upload a document to a specified space. Supports custom names and metadata. ```bash omnifact-cli upload-document --space-id YOUR_SPACE_ID --file /path/to/your/document.pdf ``` ```bash omnifact-cli upload-document --space-id YOUR_SPACE_ID --file /path/to/your/document.pdf --name "Document Name" --metadata '{"url": "https://example.com/docs/document.pdf"}' ``` ```bash omnifact-cli upload-document --space-id YOUR_SPACE_ID --file /path/to/your/document.txt --encoding windows-1252 ``` -------------------------------- ### Upload a document from disk using OmnifactAPI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Use the `upload_document` method to upload a file from disk. Specify the space ID, file path, document name, and optional metadata. Encoding is auto-detected by default. ```python result = api.upload_document( space_id="space-xyz-789", file_path="./report.pdf", name="Q4 Report", metadata={"source": "finance"}, encoding=None # auto-detect ) print("Uploaded:", result["id"]) ``` -------------------------------- ### List Documents in a Space Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Retrieve and display all documents within a specified space. The command automatically handles pagination for large numbers of documents. ```bash omnifact-cli list-documents --space-id space-xyz-789 # Output: # ID: doc-001, Name: architecture-overview.pdf # ID: doc-002, Name: api-reference.md # ID: doc-003, Name: release-notes.txt ``` -------------------------------- ### Configure Omnifact Connect URL with CLI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Override the default Omnifact Connect API base URL using `config set-connect-url` and `config get-connect-url`. The `OMNIFACT_CONNECT_URL` environment variable also provides an override. ```bash omnifact-cli config set-connect-url https://connect.my-company.com omnifact-cli config get-connect-url # Output: Current Connect URL: https://connect.my-company.com OMNIFACT_CONNECT_URL=https://staging.omnifact.ai omnifact-cli list-documents --space-id my-space ``` -------------------------------- ### Chat with AI Assistant (Single Question) Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Ask a single question to an AI assistant. Requires the endpoint ID. ```bash omnifact-cli chat --endpoint-id YOUR_ENDPOINT_ID "What is clean code?" ``` -------------------------------- ### Chat with AI Assistant (Interactive Mode) Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Engage in an interactive chat session with an AI assistant. Type 'exit' or 'quit' to end. ```bash omnifact-cli chat --endpoint-id YOUR_ENDPOINT_ID -i ``` -------------------------------- ### Format Code with Black and Isort Source: https://github.com/omnifactai/omnifact-cli/blob/master/CLAUDE.md Format Python code using Black for style and Isort for import sorting. ```bash black omnifact_cli tests ``` ```bash isort omnifact_cli tests ``` -------------------------------- ### List Documents in a Space Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md List all documents within a specified space. Requires the space ID. ```bash omnifact-cli list-documents --space-id YOUR_SPACE_ID ``` -------------------------------- ### Document Management Commands Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Commands for managing documents within Omnifact spaces, including listing, uploading, retrieving, renaming, and deleting. ```APIDOC ## Document Management ### `list-documents` Retrieves all documents in a given space, automatically paginating through results in batches of 100. Prints each document's ID and name to stdout. ```bash omnifact-cli list-documents --space-id space-xyz-789 # Output: # ID: doc-001, Name: architecture-overview.pdf # ID: doc-002, Name: api-reference.md # ID: doc-003, Name: release-notes.txt ``` ### `upload-document` Uploads a file to a space. Supports an optional display name, JSON metadata, and explicit file encoding. Returns the new document's ID on success. ```bash # Basic upload omnifact-cli upload-document --space-id space-xyz-789 --file ./report.pdf # Upload with custom name and metadata omnifact-cli upload-document \ --space-id space-xyz-789 \ --file ./report.pdf \ --name "Q4 Financial Report" \ --metadata '{"url": "https://example.com/reports/q4.pdf", "author": "finance-team"}' # Upload a legacy Windows-encoded text file omnifact-cli upload-document \ --space-id space-xyz-789 \ --file ./legacy-export.txt \ --encoding windows-1252 # Output: # Document uploaded successfully. ID: doc-004 ``` ### `get-document` Fetches and displays the details of a single document by its ID, including processing status and any attached metadata. ```bash omnifact-cli get-document doc-001 # Output: # ID: doc-001 # Name: architecture-overview.pdf # Status: ready # Metadata: { # "url": "https://example.com/docs/architecture.pdf" # } ``` ### `rename-document` Updates the display name of an existing document. Requires the document ID as a positional argument and the new name via `--name`. ```bash omnifact-cli rename-document doc-001 --name "System Architecture v2.pdf" # Output: # Document renamed successfully to: System Architecture v2.pdf ``` ### `delete-document` Permanently removes a single document by ID. No confirmation is requested. ```bash omnifact-cli delete-document doc-003 # Output: # Document doc-003 deleted successfully. ``` ### `list-supported-types` Queries the API for all currently supported MIME types and their corresponding file extensions for document upload. ```bash omnifact-cli list-supported-types # Output: # Supported file types: # application/pdf: pdf # text/plain: txt, text # application/vnd.openxmlformats-officedocument.wordprocessingml.document: docx # text/markdown: md ``` ``` -------------------------------- ### Run Pytest Commands Source: https://github.com/omnifactai/omnifact-cli/blob/master/CLAUDE.md Execute all tests, a single test file, a specific test, or tests with coverage reporting using pytest. ```bash pytest ``` ```bash pytest tests/test_cli.py ``` ```bash pytest tests/test_cli.py::test_list_documents ``` ```bash pytest --cov=omnifact_cli ``` -------------------------------- ### Upload a document from memory using OmnifactAPI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Use `upload_document_from_memory` to upload content directly from memory, such as generated text. Provide file data, file name, content type, and document name. ```python import io content = b"This is an in-memory document." result = api.upload_document_from_memory( space_id="space-xyz-789", file_data=io.BytesIO(content), file_name="generated.txt", content_type="text/plain", name="Generated Doc" ) print("Uploaded from memory:", result["id"]) ``` -------------------------------- ### Send a single message to an AI endpoint Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Use the `chat` command in single-question mode to send a message to an AI endpoint and stream the response. The output is displayed token-by-token as it arrives. ```bash omnifact-cli chat --endpoint-id endpoint-abc "What is clean code?" # Output (streamed): # Clean code is code that is easy to read, understand, and maintain. # It follows consistent conventions, uses meaningful names, and expresses # intent clearly without unnecessary complexity... ``` -------------------------------- ### Chat (Single-Question Mode) Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Sends a single message to an Omnifact AI endpoint and streams the response to stdout using Server-Sent Events. The assistant's reply is printed token-by-token as it arrives. ```APIDOC ## chat (single-question mode) ### Description Sends a single message to an Omnifact AI endpoint and streams the response to stdout using Server-Sent Events. The assistant's reply is printed token-by-token as it arrives. ### Usage ```bash omnifact-cli chat --endpoint-id "" ``` ### Example ```bash omnifact-cli chat --endpoint-id endpoint-abc "What is clean code?" # Output (streamed): # Clean code is code that is easy to read, understand, and maintain. # It follows consistent conventions, uses meaningful names, and expresses # intent clearly without unnecessary complexity... ``` ``` -------------------------------- ### Rename a Document Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Rename an existing document by providing its ID and the new name. ```bash omnifact-cli rename-document DOCUMENT_ID --name "New Document Name.pdf" ``` -------------------------------- ### Perform streaming chat with OmnifactAPI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Initiate a streaming chat with an AI endpoint using `api.chat` with `stream=True`. Iterate over the response lines and decode them to display the streamed output. ```python response = api.chat("endpoint-abc", "Summarize clean code principles", stream=True) for line in response.iter_lines(): if line: print(line.decode("utf-8")) ``` -------------------------------- ### Rename Document Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Update the display name of an existing document. Requires the document ID and the new name specified with the `--name` flag. ```bash omnifact-cli rename-document doc-001 --name "System Architecture v2.pdf" # Output: # Document renamed successfully to: System Architecture v2.pdf ``` -------------------------------- ### Purge All Documents from a Space Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Remove all documents from a specified space. Requires confirmation. ```bash omnifact-cli purge --space-id YOUR_SPACE_ID ``` -------------------------------- ### OmnifactAPI Python Class Source: https://context7.com/omnifactai/omnifact-cli/llms.txt The OmnifactAPI class provides programmatic access to Omnifact functionalities, including document management and AI chat, via a Python library. ```APIDOC ## OmnifactAPI Python Class ### Description The `OmnifactAPI` class in `omnifact_cli/api.py` can also be used directly as a Python library for programmatic integration. It wraps all HTTP communication in a `requests.Session` and supports both streaming and non-streaming chat responses. ### Initialization ```python from omnifact_cli.api import OmnifactAPI api = OmnifactAPI(api_key="", base_url="") ``` ### Document Operations #### List Documents (Paginated) ```python page = api.get_documents("", offset=0, limit=100) for doc in page["items"]: print(doc["id"], doc["name"]) ``` #### Upload Document from Disk ```python result = api.upload_document( space_id="", file_path="./", name="", metadata={"source": ""}, encoding=None # auto-detect ) print("Uploaded:", result["id"]) ``` #### Upload Document from Memory ```python import io content = b"This is an in-memory document." result = api.upload_document_from_memory( space_id="", file_data=io.BytesIO(content), file_name="", content_type="text/plain", name="" ) print("Uploaded from memory:", result["id"]) ``` #### Rename Document ```python updated = api.update_document("", "") print("Renamed to:", updated["name"]) ``` #### Delete Document ```python api.delete_document("") ``` #### Get Supported File Types ```python types = api.get_supported_file_types() for t in types: print(t["mimeType"], t["extensions"]) ``` ### AI Chat Operations #### Streaming Chat ```python response = api.chat("", "Summarize clean code principles", stream=True) for line in response.iter_lines(): if line: print(line.decode("utf-8")) ``` #### Non-Streaming Chat ```python result = api.chat("", "What is Omnifact?", stream=False) print(result) ``` ``` -------------------------------- ### Rename a document using OmnifactAPI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Update a document's name using the `update_document` method, providing the document ID and the new name. ```python updated = api.update_document("doc-001", "New Name.pdf") print("Renamed to:", updated["name"]) ``` -------------------------------- ### Delete a Document Source: https://github.com/omnifactai/omnifact-cli/blob/master/README.md Delete a document from a space using its ID. ```bash omnifact-cli delete-document DOCUMENT_ID ``` -------------------------------- ### Delete a document using OmnifactAPI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Remove a document from a space by its ID using the `delete_document` method. ```python api.delete_document("doc-003") ``` -------------------------------- ### Purge Documents Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Deletes all documents in a specified space after listing them and prompting for confirmation. Handles pagination automatically for large spaces. ```APIDOC ## purge ### Description Deletes all documents in a space after listing them and prompting for confirmation. Pagination is handled automatically, so large spaces are fully cleared regardless of document count. ### Usage ```bash omnifact-cli purge --space-id ``` ### Example ```bash omnifact-cli purge --space-id space-xyz-789 # Output: # The following documents will be deleted: # ID: doc-001, Name: architecture-overview.pdf # ID: doc-002, Name: api-reference.md # Are you sure you want to delete all these documents? [y/N]: y # Deleted document: doc-001 # Deleted document: doc-002 # All documents have been purged from the space. # Cancel the operation omnifact-cli purge --space-id space-xyz-789 # Are you sure you want to delete all these documents? [y/N]: n # Operation cancelled. ``` ``` -------------------------------- ### Perform non-streaming chat with OmnifactAPI Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Send a chat message to an AI endpoint without streaming using `api.chat` with `stream=False`. The complete response is returned as a single result. ```python result = api.chat("endpoint-abc", "What is Omnifact?", stream=False) print(result) ``` -------------------------------- ### Delete Document Source: https://context7.com/omnifactai/omnifact-cli/llms.txt Permanently remove a single document by its ID. This action is irreversible and does not prompt for confirmation. ```bash omnifact-cli delete-document doc-003 # Output: # Document doc-003 deleted successfully. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.