From 189589b0092877a1a4bb3e55f6caa7d615c66df7 Mon Sep 17 00:00:00 2001 From: choir27 Date: Thu, 15 Aug 2024 19:30:29 -0400 Subject: [PATCH 01/19] docs: add Pieces Python SDK to sidebar nav. Add installation section. Add features section. Add introduction. Add Usage section. Add community section. --- docs/build/copilot/python/index.mdx | 55 +++++++++++++++++++++++++++++ sidebars.ts | 14 ++++---- 2 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 docs/build/copilot/python/index.mdx diff --git a/docs/build/copilot/python/index.mdx b/docs/build/copilot/python/index.mdx new file mode 100644 index 000000000..d8d0e5c96 --- /dev/null +++ b/docs/build/copilot/python/index.mdx @@ -0,0 +1,55 @@ +--- +title: Pieces OS Python SDK +description: Learn how to set up and use the Pieces OS Python SDK. +--- + +# Pieces OS Python SDK + +The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server to enable features such as copilot chats, asset saving, and more. + +Follow these steps to use the Pieces Python SDK. + +## Download Pieces OS + +Download the appropriate version for your operating system: + +- [**macOS**](/installation-getting-started/macos) +- [**Windows**](/installation-getting-started/windows) +- [**Linux**](/installation-getting-started/linux) + +[**Pieces OS**](/installation-getting-started/pieces-os) is the primary backend service, providing essential SDK functionality. + +## Install Python SDK + +Use pip to install the Pieces Python SDK using the following command: + +```sh +pip install pieces_os_client +``` + +## Usage + +After installing the SDK, you can import the library into your project and start utilizing its features: + +```sh +import pieces_os_client as pos_client +``` + +## Features + +1. Copilot Chats + - Communicate seamlessly with the functionalities of the copilot chats. + +2. Asset Management + - Save and manage assets and formats them efficiently. + +3. Local Server Interaction + - Interact with a locally hosted server for various functionalities. + +4. Multi LLMs support + - Use any Pieces supported LLMs to power apps. + +## Community +If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). + +If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). diff --git a/sidebars.ts b/sidebars.ts index 42679951f..c83d3a246 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -561,12 +561,14 @@ const sidebars: SidebarsConfig = { // }, { type: 'category', - label: 'πŸ” API Reference', - items: allSDKs.map(sdk => ({ - type: 'doc' as const, - id: `build/reference/${sdk.toLowerCase()}/index`, - label: `${sdk} SDK` - })) + label: 'πŸ“š Copilot', + items:[ + { + type: 'doc', + id: 'build/copilot/python/index', + label: 'Python', + }, + ] }, // { // type: 'doc', From 1c27281bb759e1e7eb5727279d9daf76a2e953df Mon Sep 17 00:00:00 2001 From: choir27 Date: Sat, 17 Aug 2024 12:14:29 -0400 Subject: [PATCH 02/19] add note info to include Pieces OS for SDk. Update location to href redirec to Pieces OS docs. Change Usage to Initialize SDK. Update instructions to initialize Pieces OS. Update Features to table and content. Add parameters, return type, and example sections for the following: ask_question(), create_conversation(), prompt_conversation(), get_conversation(), update_conversation_name(), get_conversations(), get_user_profile_picture(), and Full Example using all Python SDK methods --- docs/build/copilot/python/index.mdx | 310 ++++++++++++++++++++++++++-- 1 file changed, 295 insertions(+), 15 deletions(-) diff --git a/docs/build/copilot/python/index.mdx b/docs/build/copilot/python/index.mdx index d8d0e5c96..69e447573 100644 --- a/docs/build/copilot/python/index.mdx +++ b/docs/build/copilot/python/index.mdx @@ -11,14 +11,18 @@ Follow these steps to use the Pieces Python SDK. ## Download Pieces OS -Download the appropriate version for your operating system: +:::info + +You must either have Pieces OS installed on your local machine or have access to a remote instance of Pieces OS to use this SDK. + +::: + +Download [**Pieces OS**](/installation-getting-started/pieces-os) for your operating system: - [**macOS**](/installation-getting-started/macos) - [**Windows**](/installation-getting-started/windows) - [**Linux**](/installation-getting-started/linux) -[**Pieces OS**](/installation-getting-started/pieces-os) is the primary backend service, providing essential SDK functionality. - ## Install Python SDK Use pip to install the Pieces Python SDK using the following command: @@ -27,27 +31,303 @@ Use pip to install the Pieces Python SDK using the following command: pip install pieces_os_client ``` -## Usage +## Initialize SDK -After installing the SDK, you can import the library into your project and start utilizing its features: +After installing the SDK, you must initialize the SDK with your base URL. The base URL will depend on your setup. -```sh -import pieces_os_client as pos_client +If you are using a local instance of Pieces OS: +- On macOS/Windows, use http://localhost:1000 +- On Linux, use http://localhost:5323 + +If you are using a remote instance of Pieces OS, use the URL you have set up for that. + +```python +from pieces_copilot_sdk import PiecesClient + +# Replace 'your_base_url' with your actual base URL +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) ``` ## Features -1. Copilot Chats - - Communicate seamlessly with the functionalities of the copilot chats. +Feature | Description +------------- | ------------- +Simplified Interaction | The Pieces Copilot SDK simplifies the interaction with the Pieces OS Client SDK by providing easy-to-use methods for various operations. +Manage Conversations | The SDK provides various methods to manage conversations such as fetching a specific conversation, updating conversation name, and more. +Get User Profile Picture | Retrieve the user's profile picture using the `get_user_profile_picture()` method. + +## ask_question() + +```python +ask_question() +``` + +Allows users to ask a question and receive a response. + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **question** | **string**| This is the question representing the query that will be used to generate the answer outputted by the Pieces OS Copilot. | [required] + +### Return type + +string (response body) + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +response = pieces_client.ask_question('What is Pieces for Developers?') + +print(response) +``` + +## create_conversation() + +```python +create_conversation(name=None, first_message=None) +``` + +Creates a new conversation. + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**name** | **string** | This is the name of the new conversation | [optional] +**first message** | **string** | This is the first message that will be used to generate an answer to the message |[optional] + +### Return type + +A dictionary containing many key-value pairs, including the conversation name and the answer to the first message if either are provided. + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +new_conversation = pieces_client.create_conversation( + props={ + 'name': 'Test Conversation', + 'firstMessage': 'Hello, how can I use the API?' + } +) + +print(new_conversation) +``` + +## prompt_conversation() + +This method prompts a conversation with a message. + +```python +prompt_conversation(question, conversation_id, regenerate_conversation_name=False) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**question** | **string** | This is the question that will be used to generate an answer in the message | [required] +**conversation_id** | **string** | ID of a conversation that was created | [required] +**regenerate_conversation_name** | **boolean** | Regenerate the conversation name of the provided conversation id. Default is set to `False`. | [required] + +### Return type + +A dictionary containing the text of the answer, the ID of the user query message, and the ID of the bot response message. + +If there are previous messages in the conversation, they will be used as context for the new message. If there is an error, it will return a dictionary containing only the text of the error message + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +answer = pieces_client.prompt_conversation( + message='Hello, world!', + conversation_id='conversationId', + regenerate_conversation_name=False, +) + +print(answer) +``` + +## get_conversation() + +This method retrieves a conversation by its ID. + +```python +get_conversation(conversation_id, include_raw_messages=False) +``` + +### Parameters + -2. Asset Management - - Save and manage assets and formats them efficiently. +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**conversation_id** | **string** | ID of a conversation that was created | [required] +**include_raw_messages** | **boolean** | Includes the raw messages | [optional] -3. Local Server Interaction - - Interact with a locally hosted server for various functionalities. +### Return type -4. Multi LLMs support - - Use any Pieces supported LLMs to power apps. +A dictionary representing the `Conversation` object or `None`. + +### Example + +```pieces +from pieces_copilot_sdk import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +conversation = pieces_client.get_conversation( + conversation_id='conversationId', + include_raw_messages=False +) + +print(conversation) +``` + +## update_conversation_name() + +This method generates a new name for a specific conversation based on the messages that have been sent. + +```python +update_conversation_name(conversation_id) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**conversation_id** | **string** | ID of a conversation that was created | [required] + +### Return type + +It returns a string representing the updated conversation name or `None`. + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +updated_name = pieces_client.update_conversation_name( + conversation_id='conversationId') + +print(updated_name) +``` + +## get_conversations() + +```python +get_conversations() +``` + +This method retrieves all conversations. + +### Return type + +It returns a list of `Conversation` objects or `None`. + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +conversations = pieces_client.get_conversations() + +print(conversations) +``` + +## get_user_profile_picture() + +```python +get_user_profile_picture() +``` + +### Return type + +It returns a string representing the URL of the profile picture or `None`. + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +profile_picture_url = pieces_client.get_user_profile_picture() + +print(profile_picture_url) +``` + +## Full Example + +```python +from pieces_copilot_sdk import PiecesClient + +# Create an instance of PiecesClient +pieces_client = PiecesClient( + config={ + 'baseUrl': 'your_base_url' + } +) + +# 1. Create a new conversation +conversation_response = pieces_client.create_conversation( + props={ + "name": "Test Conversation", + "firstMessage": "Hello, how can I use the API?" + } +) + +# Check if the conversation was created successfully +if conversation_response: + print("Conversation Created:", conversation_response['conversation'].id) + print("First Message Response:", conversation_response['answer']['text']) + + # 2. Get the created conversation details + conversation_id = conversation_response['conversation'].id + conversation_details = pieces_client.get_conversation( + conversation_id=conversation_id, + include_raw_messages=True + ) + + # Access the conversation name using the key + print("Conversation Name:", conversation_details.get('name')) + + # 3. Ask a question within the created conversation + question_response = pieces_client.prompt_conversation( + message="Can you give me an example code snippet?", + conversation_id=conversation_id + ) + print("Question Response:", question_response['text']) + +# 4. Retrieve all conversations and print their names +all_conversations = pieces_client.get_conversations() +for conversation in all_conversations: + print("Conversation Name:", conversation.name) + +# 5. Get user profile picture +profile_picture = pieces_client.get_user_profile_picture() +print("User Profile Picture URL:", profile_picture) + +# 6. Ask a question +question = "What is Pieces for Developer?" +response = pieces_client.ask_question(question) +print("Question Response:", response) +``` ## Community If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). From 12ce3f219cb9eb3120affcb91c1faec2e0ccbe25 Mon Sep 17 00:00:00 2001 From: choir27 Date: Thu, 22 Aug 2024 18:20:23 -0400 Subject: [PATCH 03/19] add sdk sidebar wrapper navigation --- docs/build/copilot/python/index.mdx | 335 -------------------- docs/build/sdks/python/assets/index.mdx | 6 + docs/build/sdks/python/copilot/index.mdx | 10 + docs/build/sdks/python/index.mdx | 33 ++ docs/build/sdks/python/quickstart/index.mdx | 91 ++++++ sidebars.ts | 51 ++- src/lib/activeSDK.ts | 8 +- 7 files changed, 182 insertions(+), 352 deletions(-) delete mode 100644 docs/build/copilot/python/index.mdx create mode 100644 docs/build/sdks/python/assets/index.mdx create mode 100644 docs/build/sdks/python/copilot/index.mdx create mode 100644 docs/build/sdks/python/index.mdx create mode 100644 docs/build/sdks/python/quickstart/index.mdx diff --git a/docs/build/copilot/python/index.mdx b/docs/build/copilot/python/index.mdx deleted file mode 100644 index 69e447573..000000000 --- a/docs/build/copilot/python/index.mdx +++ /dev/null @@ -1,335 +0,0 @@ ---- -title: Pieces OS Python SDK -description: Learn how to set up and use the Pieces OS Python SDK. ---- - -# Pieces OS Python SDK - -The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server to enable features such as copilot chats, asset saving, and more. - -Follow these steps to use the Pieces Python SDK. - -## Download Pieces OS - -:::info - -You must either have Pieces OS installed on your local machine or have access to a remote instance of Pieces OS to use this SDK. - -::: - -Download [**Pieces OS**](/installation-getting-started/pieces-os) for your operating system: - -- [**macOS**](/installation-getting-started/macos) -- [**Windows**](/installation-getting-started/windows) -- [**Linux**](/installation-getting-started/linux) - -## Install Python SDK - -Use pip to install the Pieces Python SDK using the following command: - -```sh -pip install pieces_os_client -``` - -## Initialize SDK - -After installing the SDK, you must initialize the SDK with your base URL. The base URL will depend on your setup. - -If you are using a local instance of Pieces OS: -- On macOS/Windows, use http://localhost:1000 -- On Linux, use http://localhost:5323 - -If you are using a remote instance of Pieces OS, use the URL you have set up for that. - -```python -from pieces_copilot_sdk import PiecesClient - -# Replace 'your_base_url' with your actual base URL -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) -``` - -## Features - -Feature | Description -------------- | ------------- -Simplified Interaction | The Pieces Copilot SDK simplifies the interaction with the Pieces OS Client SDK by providing easy-to-use methods for various operations. -Manage Conversations | The SDK provides various methods to manage conversations such as fetching a specific conversation, updating conversation name, and more. -Get User Profile Picture | Retrieve the user's profile picture using the `get_user_profile_picture()` method. - -## ask_question() - -```python -ask_question() -``` - -Allows users to ask a question and receive a response. - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **question** | **string**| This is the question representing the query that will be used to generate the answer outputted by the Pieces OS Copilot. | [required] - -### Return type - -string (response body) - -### Example - -```python -from pieces_copilot_sdk import PiecesClient - -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) - -response = pieces_client.ask_question('What is Pieces for Developers?') - -print(response) -``` - -## create_conversation() - -```python -create_conversation(name=None, first_message=None) -``` - -Creates a new conversation. - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- -**name** | **string** | This is the name of the new conversation | [optional] -**first message** | **string** | This is the first message that will be used to generate an answer to the message |[optional] - -### Return type - -A dictionary containing many key-value pairs, including the conversation name and the answer to the first message if either are provided. - -### Example - -```python -from pieces_copilot_sdk import PiecesClient - -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) - -new_conversation = pieces_client.create_conversation( - props={ - 'name': 'Test Conversation', - 'firstMessage': 'Hello, how can I use the API?' - } -) - -print(new_conversation) -``` - -## prompt_conversation() - -This method prompts a conversation with a message. - -```python -prompt_conversation(question, conversation_id, regenerate_conversation_name=False) -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- -**question** | **string** | This is the question that will be used to generate an answer in the message | [required] -**conversation_id** | **string** | ID of a conversation that was created | [required] -**regenerate_conversation_name** | **boolean** | Regenerate the conversation name of the provided conversation id. Default is set to `False`. | [required] - -### Return type - -A dictionary containing the text of the answer, the ID of the user query message, and the ID of the bot response message. - -If there are previous messages in the conversation, they will be used as context for the new message. If there is an error, it will return a dictionary containing only the text of the error message - -### Example - -```python -from pieces_copilot_sdk import PiecesClient - -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) - -answer = pieces_client.prompt_conversation( - message='Hello, world!', - conversation_id='conversationId', - regenerate_conversation_name=False, -) - -print(answer) -``` - -## get_conversation() - -This method retrieves a conversation by its ID. - -```python -get_conversation(conversation_id, include_raw_messages=False) -``` - -### Parameters - - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- -**conversation_id** | **string** | ID of a conversation that was created | [required] -**include_raw_messages** | **boolean** | Includes the raw messages | [optional] - -### Return type - -A dictionary representing the `Conversation` object or `None`. - -### Example - -```pieces -from pieces_copilot_sdk import PiecesClient - -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) - -conversation = pieces_client.get_conversation( - conversation_id='conversationId', - include_raw_messages=False -) - -print(conversation) -``` - -## update_conversation_name() - -This method generates a new name for a specific conversation based on the messages that have been sent. - -```python -update_conversation_name(conversation_id) -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- -**conversation_id** | **string** | ID of a conversation that was created | [required] - -### Return type - -It returns a string representing the updated conversation name or `None`. - -### Example - -```python -from pieces_copilot_sdk import PiecesClient - -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) - -updated_name = pieces_client.update_conversation_name( - conversation_id='conversationId') - -print(updated_name) -``` - -## get_conversations() - -```python -get_conversations() -``` - -This method retrieves all conversations. - -### Return type - -It returns a list of `Conversation` objects or `None`. - -### Example - -```python -from pieces_copilot_sdk import PiecesClient - -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) - -conversations = pieces_client.get_conversations() - -print(conversations) -``` - -## get_user_profile_picture() - -```python -get_user_profile_picture() -``` - -### Return type - -It returns a string representing the URL of the profile picture or `None`. - -### Example - -```python -from pieces_copilot_sdk import PiecesClient - -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) - -profile_picture_url = pieces_client.get_user_profile_picture() - -print(profile_picture_url) -``` - -## Full Example - -```python -from pieces_copilot_sdk import PiecesClient - -# Create an instance of PiecesClient -pieces_client = PiecesClient( - config={ - 'baseUrl': 'your_base_url' - } -) - -# 1. Create a new conversation -conversation_response = pieces_client.create_conversation( - props={ - "name": "Test Conversation", - "firstMessage": "Hello, how can I use the API?" - } -) - -# Check if the conversation was created successfully -if conversation_response: - print("Conversation Created:", conversation_response['conversation'].id) - print("First Message Response:", conversation_response['answer']['text']) - - # 2. Get the created conversation details - conversation_id = conversation_response['conversation'].id - conversation_details = pieces_client.get_conversation( - conversation_id=conversation_id, - include_raw_messages=True - ) - - # Access the conversation name using the key - print("Conversation Name:", conversation_details.get('name')) - - # 3. Ask a question within the created conversation - question_response = pieces_client.prompt_conversation( - message="Can you give me an example code snippet?", - conversation_id=conversation_id - ) - print("Question Response:", question_response['text']) - -# 4. Retrieve all conversations and print their names -all_conversations = pieces_client.get_conversations() -for conversation in all_conversations: - print("Conversation Name:", conversation.name) - -# 5. Get user profile picture -profile_picture = pieces_client.get_user_profile_picture() -print("User Profile Picture URL:", profile_picture) - -# 6. Ask a question -question = "What is Pieces for Developer?" -response = pieces_client.ask_question(question) -print("Question Response:", response) -``` - -## Community -If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). - -If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). diff --git a/docs/build/sdks/python/assets/index.mdx b/docs/build/sdks/python/assets/index.mdx new file mode 100644 index 000000000..b65aa9970 --- /dev/null +++ b/docs/build/sdks/python/assets/index.mdx @@ -0,0 +1,6 @@ +--- +title: Pieces OS Python SDK +description: Learn how to set up and use the Pieces OS Python SDK. +--- + + diff --git a/docs/build/sdks/python/copilot/index.mdx b/docs/build/sdks/python/copilot/index.mdx new file mode 100644 index 000000000..604098e6b --- /dev/null +++ b/docs/build/sdks/python/copilot/index.mdx @@ -0,0 +1,10 @@ +--- +title: Pieces OS Python SDK +description: Learn how to set up and use the Pieces OS Python SDK. +--- + + + +# Pieces OS Python SDK + +The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server to enable features such as copilot chats, asset saving, and more. diff --git a/docs/build/sdks/python/index.mdx b/docs/build/sdks/python/index.mdx new file mode 100644 index 000000000..1ab7e751a --- /dev/null +++ b/docs/build/sdks/python/index.mdx @@ -0,0 +1,33 @@ +--- +title: Pieces OS Python SDK +description: Learn how to set up and use the Pieces OS Python SDK. +--- + +# Pieces OS Python SDK + +The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server to enable features such as copilot chats, asset saving, and more. + +## Requirements + +The Pieces SDK has the following system requirements: + +- Pieces OS running as a backend service. +- Python environment with `pip` for installing the SDK package. + +## Features + +Feature | Description +------------- | ------------- +Simplified Interaction | The Pieces Copilot SDK simplifies the interaction with the Pieces OS Client SDK by providing easy-to-use methods for various operations. +Manage Conversations | The SDK provides various methods to manage conversations such as fetching a specific conversation, updating conversation name, and more. +Get User Profile Picture | Retrieve the user's profile picture using the `get_user_profile_picture()` method. +Copilot Chats | Communicate seamlessly with copilot chats functionality. +Asset Management | Save and manage assets and formats efficiently. +Local Server Interaction | Interact with a locally hosted server for various functionalities. +Multi LLMs support | Use any Pieces supported LLMs to power apps. + + +## Community +If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). + +If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). diff --git a/docs/build/sdks/python/quickstart/index.mdx b/docs/build/sdks/python/quickstart/index.mdx new file mode 100644 index 000000000..6d77073aa --- /dev/null +++ b/docs/build/sdks/python/quickstart/index.mdx @@ -0,0 +1,91 @@ +--- +title: Pieces OS Python SDK +description: Learn how to set up and use the Pieces OS Python SDK. +--- + +Follow these steps to use the Pieces Python SDK. + +## Download Pieces OS + +:::info + +You must either have Pieces OS installed on your local machine or have access to a remote instance of Pieces OS to use this SDK. + +::: + +Download [**Pieces OS**](/installation-getting-started/pieces-os) for your operating system: + +- [**macOS**](/installation-getting-started/macos) +- [**Windows**](/installation-getting-started/windows) +- [**Linux**](/installation-getting-started/linux) + +## Install Python SDK + +Use pip to install the Pieces Python SDK using the following command: + +```sh +pip install pieces_os_client +``` + +## Initialize SDK + +After installing the SDK, you must initialize the SDK with your base URL. The base URL will depend on your setup. + +If you are using a local instance of Pieces OS: +- On macOS/Windows, use http://localhost:1000 +- On Linux, use http://localhost:5323 + +If you are using a remote instance of Pieces OS, use the URL you have set up for that. + +```python +from pieces_copilot_sdk import PiecesClient + +# Replace 'your_base_url' with your actual base URL +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +``` + +## Getting started + +First, we will create a Python script to test the connection to the Pieces OS server. This involves creating a config.py file to store your configuration info and a wellknown.py file to test the connection. + +```python +import pieces_os_client +import platform + +# Defining the port based on the operating system. For Linux, the port is 5323, and for macOS/Windows, the port is 1000. +platform_info = platform.platform() +if 'Linux' in platform_info: + port = 5323 +else: + port = 1000 + +# The `basePath` defaults to http://localhost:1000, however we need to change it to the correct port based on the operating system. +configuration = pieces_os_client.Configuration(host=f"http://localhost:{port}") + +# Initialize the Pieces ApiClient +api_client = pieces_os_client.ApiClient(configuration) + +# Enter a context with an instance of the ApiClient +with pieces_os_client.ApiClient(configuration) as api_client: + # Create an instance of the WellKnownApi class + api_instance = pieces_os_client.WellKnownApi(api_client) + + try: + # Retrieve the (wellknown) health of the Pieces OS + api_response = api_instance.get_well_known_health() + print("The response of WellKnownApi().get_well_known_health:") + print(api_response) # Response: ok + except Exception as e: + print("Exception when calling WellKnownApi->get_well_known_health: %s\n" % e) +``` + +Run the following command to execute the script: + +```sh +python3 main.py +``` + +## Community +If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). + +If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). diff --git a/sidebars.ts b/sidebars.ts index b0b787293..63523b39a 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -569,22 +569,16 @@ const sidebars: SidebarsConfig = { id: 'build/examples/index', label: 'πŸ“š Examples', }, + { + type: 'doc', + id: 'build/sdks/python/index', + label: 'πŸ“š Python', + }, // { // type: 'doc', // id: 'build/tutorials/index', // label: 'πŸ“š Tutorials', // }, - { - type: 'category', - label: 'πŸ“š Copilot', - items:[ - { - type: 'doc', - id: 'build/copilot/python/index', - label: 'Python', - }, - ] - }, // { // type: 'doc', // id: 'build/concepts/index', @@ -612,6 +606,7 @@ const sidebars: SidebarsConfig = { ] }, ], +<<<<<<< Updated upstream // Pieces CLI Sidebar cliSidebar: [ @@ -669,5 +664,39 @@ const sidebars: SidebarsConfig = { // Generates sidebar for each active SDK ...generatedSDKSidebars, }; +======= + // Generates sidebar for each active SDK + ...generatedSDKSidebars, + + // Python SDK WrapperSidebar + pythonSDKWrapperSidebar: [ + { + type: 'ref', + id: 'build/index', + label: '← Back to Build', + }, + { + type: 'doc', + id: 'build/sdks/python/index', + label: 'Overview', + }, + { + type: 'doc', + id: 'build/sdks/python/quickstart', + label: 'Quickstart', + }, + { + type: 'doc', + id: 'build/sdks/python/assets', + label: 'Assets', + }, + { + type: 'doc', + id: 'build/sdks/python/copilot', + label: 'Copilot', + }, + ], + }; +>>>>>>> Stashed changes export default sidebars; diff --git a/src/lib/activeSDK.ts b/src/lib/activeSDK.ts index d53c264b5..acd6818fd 100644 --- a/src/lib/activeSDK.ts +++ b/src/lib/activeSDK.ts @@ -2,14 +2,10 @@ // List of SDKs to display on the docs const activeSDKs = [ - 'TypeScript', 'Python', ]; -const inactiveSDKs = [ - 'Dart', - 'Kotlin', -] -export const allSDKs = [...activeSDKs, ...inactiveSDKs]; + +export const allSDKs = [...activeSDKs]; // Template for the sidebar items for each SDK const baseSidebarItems: { From de652ea88bf62a8dcee8b16a9a2ae5ca320a6c49 Mon Sep 17 00:00:00 2001 From: choir27 Date: Thu, 22 Aug 2024 20:40:20 -0400 Subject: [PATCH 04/19] organize python sdk in sidebar. add methods, properties, and class methods and properties to copilot and assets for python sdk --- docs/build/sdks/python/assets/index.mdx | 213 ++++++++++- docs/build/sdks/python/copilot/index.mdx | 381 +++++++++++++++++++- docs/build/sdks/python/quickstart/index.mdx | 33 +- sidebars.ts | 66 +--- 4 files changed, 601 insertions(+), 92 deletions(-) diff --git a/docs/build/sdks/python/assets/index.mdx b/docs/build/sdks/python/assets/index.mdx index b65aa9970..261de184a 100644 --- a/docs/build/sdks/python/assets/index.mdx +++ b/docs/build/sdks/python/assets/index.mdx @@ -1,6 +1,215 @@ --- -title: Pieces OS Python SDK -description: Learn how to set up and use the Pieces OS Python SDK. +title: Pieces Wrapper Python SDK Assets +description: Learn how to set up and use the Pieces Wrapper Python SDK Asset methods --- +# Pieces wrapper python SDK asset methods +## create_asset() + +```python +create_asset(content, metadata) +``` + +Creates a new asset. + +### Parameters + +Name | Type | Notes +------------- | ------------ | ------------- + **content** | **string**| [required] + **metadata** | **FragmentMetadata**| [optional] + +### Example + +```python +from pieces_os_client.wrapper import PiecesClient +from pieces_os_client import FragmentMetadata + +# Replace 'your_base_url' with the base URL of your Pieces OS server +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +# Set the content and metadata for the new asset +content = "print('Hello, World!')" +metadata = FragmentMetadata(ext=ClassificationSpecificEnum.PY) # optional metadata + +# Create the new asset using the content and metadata +new_asset_id = pieces_client.create_asset(content, metadata) + +print(f"Created asset with ID: {new_asset_id}") +``` + +## assets() + +```python +assets() +``` + +Gets all your assets. + +### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Replace 'your_base_url' with the base URL of your Pieces OS server +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +# Get all assets and print their names +assets = pieces_client.assets() +for asset in assets: + logger.info(f"Asset Name: {asset.name}") +``` + +## BasicAsset + +The BasicAsset class provides a way to manage assets with various properties and methods. This document outlines the properties and methods available in the BasicAsset class. + +```python +BasicAsset(id) +``` + +### Parameters + +| Name | Description | Type | Notes | +|------------- | ------------ | -------------| -------------| +| **id** | Your asset id. Raises: ValueError if the provided ID is invalid. | **string** | [required] | + +### Properties + +#### id +Returns the asset ID. + +#### raw_content +Edit the original format of the asset. + +##### Arguments: + +| Name | Description | +| ------------- | ------------ | +| data | The new data to be set. | + +##### Raises: + +| Name | Description | +| ------------- | ------------ | +| NotImplementedError | If the asset is an image.| + +#### is_image +Check if the asset is an image. + +##### On return + +| Type | Description | +| ------------- | ------------ | +| bool | True if the asset is an image, otherwise False. | + +#### classification +Get the specific classification of the asset (e.g., py). + +##### On return + +| Type | Description | +| ------------- | ------------ | +| classification value/None | The classification value of the asset, or None if not available. | + +#### classification setter +Reclassify an asset + +#### name setter +Edit the name of the asset. + +- name: The new name to be set for the asset. + +#### description +Retrieve the description of the asset. + +##### On return + +| Type | Description | +| ------------- | ------------ | +| string/None | The description text of the asset, or None if not available. | + +#### annotations +Get all annotations of the asset. + +| Type | Description | +| ------------- | ------------ | +|Optional[Annotations]/None|The annotations if available, otherwise None.| + +### Methods + +#### `delete()` +Delete the asset. + +#### `create()` +Create a new asset. + +Args: + +raw_content (str): The raw content of the asset. +metadata (Optional[FragmentMetadata]): The metadata of the asset. +Returns: str - The ID of the created asset. + +### Example + +```python +from pieces_copilot_sdk import PiecesClient +from pieces_copilot_sdk.basic_identifier import BasicAsset +from pieces_os_client import ClassificationSpecificEnum + +# Replace 'your_base_url' with your actual base URL +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +asset = pieces_client.assets()[0] + +# Get the asset ID +asset_id = asset.id +print(f"Asset ID: {asset_id}") + +# Check if the asset is an image +if asset.is_image: + print("The asset is an image.") +else: + print("The asset is not an image.") + +# Get and set the asset name +print(f"Current Asset Name: {asset.name}") +asset.name = "Updated Asset Name" +print(f"Updated Asset Name: {asset.name}") + +# Retrieve and modify the asset content +content = asset.raw_content +print(f"Original Content: {content}") +asset.raw_content = content + "\n# This is a comment" +print(f"Updated Content: {asset.raw_content}") + +# Get the asset classification +classification = asset.classification.value if asset.classification else "None" +print(f"Asset Classification: {classification}") + +asset.classification = ClassificationSpecificEnum.SH # Reclassify to shell +print(f"New Classification: {classification}") + +# Get the asset description +description = asset.description if asset.description else "No description available." +print(f"Asset Description: {description}") + +# Get the asset annotations +annotations = asset.annotations if asset.annotations else "No annotations available." +print(f"Asset Annotations: {annotations}") + +# Delete the asset +asset.delete() +print("Asset deleted.") + +# Create a new asset +new_asset_id = BasicAsset.create("New Asset content") +print(f"New Asset ID: {new_asset_id}") +pieces_client.close() +``` + +## Community +If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). + +If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). \ No newline at end of file diff --git a/docs/build/sdks/python/copilot/index.mdx b/docs/build/sdks/python/copilot/index.mdx index 604098e6b..f20030655 100644 --- a/docs/build/sdks/python/copilot/index.mdx +++ b/docs/build/sdks/python/copilot/index.mdx @@ -1,10 +1,383 @@ --- -title: Pieces OS Python SDK -description: Learn how to set up and use the Pieces OS Python SDK. +title: Pieces Wrapper Python SDK Copilot +description: Learn how to set up and use the Pieces Wrapper Python SDK Copilot methods --- +# Pieces wrapper python SDK copilot methods +## stream_question() -# Pieces OS Python SDK +```python +stream_question(question) +``` -The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server to enable features such as copilot chats, asset saving, and more. +Ask Pieces Copilot a question and stream the response. + +### Parameters + +Name | Type | Notes +------------- | ------------ | ------------- + **question** | **string**| [required] + +### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +# Set the question you want to ask +question = "What is Object-Oriented Programming?" + +# Ask the question and stream the response +for response in pieces_client.copilot.stream_question(question): + if response.question: + # Each answer is a chunk of the entire response to the question + answers = response.question.answers.iterable + for answer in answers: + print(answer.text,end="") +``` + +## BasicChat + +```python +BasicChat(id) +``` + +### Parameters + +| Name | Description | Type | Notes | +|------------- | ------------ | -------------| -------------| +| **id** | Your conversation id. | **string** | [required] | + +### Methods + +####id +Gets the ID of the conversation. + +##### On return + +| Type | Description | +| ------------- | ------------ | +| string | The ID of the conversation.| + +#### name +Gets the name of the conversation. + +##### Returns: + +| Type | Description | +| ------------- | ------------ | +| string | The name of the conversation, or "New Conversation" if the name is not set.| + +name = name: str +Sets the name of the conversation. + +##### Arguments + +| Name | Description | +| ------------- | ------------ | +| str | The new name of the conversation. | + + +#### messages() +Retrieves the messages in the conversation. + +##### Returns: + +| Type | Description | +| ------------- | ------------ | +| list | A list of BasicMessage instances representing the messages in the conversation. +annotations | + +#### annotations +Gets the annotations of the conversation. + +Returns: + +##### Returns: + +| Type | Description | +| ------------- | ------------ | +| dict/None | The annotations of the conversation, or None if not available. | + +#### description +Gets the conversation description. + +##### Returns: + +| Type | Description | +| ------------- | ------------ | +| string | The description of the conversation. | + +#### delete() +Deletes the conversation. + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +# Replace 'your_base_url' with your actual base URL +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +# Initialize a BasicChat instance +chat = pieces_client.copilot.chats()[0] + +# Get the ID of the conversation +conversation_id = chat.id +print(f"Conversation ID: {conversation_id}") + +# Get the name of the conversation +conversation_name = chat.name +print(f"Conversation Name: {conversation_name}") + +# Set a new name for the conversation +chat.name = "Project Discussion" +print(f"Updated Conversation Name: {chat.name}") + +# Retrieve the messages in the conversation +messages = chat.messages() +for message in messages: + print(f"Message: {message.raw_content}") + print(f"Message Role: {message.role}") + +# Get the annotations of the conversation +annotations = chat.annotations +if annotations: + print(f"Annotations: {annotations}") +else: + print("No annotations available.") + +# Get the description of the conversation +description = chat.description +print(f"Description: {description}") + +# Delete the conversation +chat.delete() +print("Conversation deleted.") + +pieces_client.close() +``` + +## BasicMessage + +This represents a Copilot chat message to opentain that model you should be using pieces_client.copilot.chat.messages() to opentain the messages of the current chat. + +### Properties + +#### raw_content +Sets the raw content of the message and updates it in the API. + +#### role +Gets the role of the message. + +##### Returns: + +| Type | Description | +| ------------- | ------------ | +| Literal["USER", "SYSTEM", "ASSISTANT"] | The role of the message. | + +#### id +Gets the ID of the message. + +| Type | Description | +| ------------- | ------------ | +| string | The ID of the message. | + +#### delete +Deletes the message. + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +# Replace 'your_base_url' with your actual base URL +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +# Initialize a BasicChat instance +chat = pieces_client.copilot.chats()[0] +messages = chat.messages() + +# Set the raw content of the message +message.raw_content = "This is the updated raw content of the message." +print("Raw content updated.") + +# Get the role of the message +role = message.role +print(f"Role: {role}") + +# Get the ID of the message +message_id = message.id +print(f"Message ID: {message_id}") + +# Delete the message +message.delete() +print("Message deleted.") + +pieces_client.close() +``` + +## stream_question() + +```python +stream_question(query, pipeline) +``` + +Asks a question to the QGPT model and streams the responses. by default it will create a new conversation and always use it in the ask. You can always change the conversation in copilot.chat = BasicChat(chat_id="YOU ID GOES HERE") + +### Parameters + +| Name | Description | Note | +|------------- | ------------ |------------ | +| query | The question to ask. | [required] | +| pipeline | pipeline to follow. | [optional] | + +### Returns + +| Type | Description | +| ------------- | ------------ | +| QGPTStreamOutput | The streamed output from the QGPT model.| + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +# Replace 'your_base_url' with your actual base URL +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +for response in pieces_client.copilot.stream_question("Your question"): + if response.question: + answers = response.question.answers.iterable + for answer in answers: + print(answer.text,end="") +``` + +## question() + +```python +question(query, pipeline) +``` + +Asks a question to the QGPT model and return the responses Note: the question is not a part of any conversation. + +### Parameters + +| Name | Description | Note | +|------------- | ------------ |------------ | +| query | The question to ask. | [required] | +| pipeline | pipeline to follow. | [optional] | + +### Returns + +| Type | Description | +| ------------- | ------------ | +| QGPTStreamOutput | The streamed output from the QGPT model.| + +### Example + +```python +from pieces_copilot_sdk import PiecesClient + +# Replace 'your_base_url' with your actual base URL +pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) + +text = pieces_client.copilot.question("Your question").answers.iterable[0].text +print(text) +``` + +## context + +```python +copilot.context +``` + +Returns a context model to interact with the conversation context. + +```python +context = copilot.context +context.paths.append("/path/to/folder/or/file") +context.message.append(BasicMessage("my_message_id")) +context.assets.append(BasicAsset("my_message_id")) +context.raw_assets.append("import sublime") # snippet content +context.clear() # clear all the context +``` + +Note if you setted the context of the copilot you will get a value error in the ask_stream method if you added an invalid type + +### chats() + +```python +chats() +``` + +Retrieves a list of all chat identifiers. + +### Returns + +| Type | Description | +| ------------- | ------------ | +| **list[BasicChat]** | A list of BasicChat instances representing the chat identifiers. | + +### Example + +```python +chat_list = copilot.chats() +for chat in chat_list: + print(f"Chat ID: {chat.id}, Chat Name: {chat.name}") +``` + +## chat (getter) + +```python +copilot.chat +``` + +Gets the current conversation being used in the copilot. + +### Returns + +| Type | Description | +| ------------- | ------------ | +| **BasicChat/None** | The current BasicChat instance or None if no chat is set. | + +### Example + +```python +current_chat = copilot.chat +if current_chat: + print(f"Current Chat ID: {current_chat.id}") +else: + print("No chat is currently set.") +``` + +## chat (setter) + +```python +copilot.chat = your_value_here +``` + +Sets the current conversation to be used in the copilot. + +### Arguments + +| Type | Description | +| ------------- | ------------ | +| **BasicChat/None** | The BasicChat instance is set. | + +### Raises + +| Type | Description | +| ------------- | ------------ | +| **ValueError** | If the provided chat is not a valid BasicChat` instance. | + +```python +new_chat = copilot.chats[0] +try: + copilot.chat = new_chat + print("Chat set successfully.") +except ValueError as e: + print(f"Failed to set chat: {e}") +``` \ No newline at end of file diff --git a/docs/build/sdks/python/quickstart/index.mdx b/docs/build/sdks/python/quickstart/index.mdx index 6d77073aa..17218e29b 100644 --- a/docs/build/sdks/python/quickstart/index.mdx +++ b/docs/build/sdks/python/quickstart/index.mdx @@ -49,36 +49,23 @@ pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) First, we will create a Python script to test the connection to the Pieces OS server. This involves creating a config.py file to store your configuration info and a wellknown.py file to test the connection. ```python -import pieces_os_client +from pieces_os_client.wrapper import PiecesClient import platform -# Defining the port based on the operating system. For Linux, the port is 5323, and for macOS/Windows, the port is 1000. +# Defining the port based on the operating system platform_info = platform.platform() if 'Linux' in platform_info: - port = 5323 + port = 5323 else: - port = 1000 - -# The `basePath` defaults to http://localhost:1000, however we need to change it to the correct port based on the operating system. -configuration = pieces_os_client.Configuration(host=f"http://localhost:{port}") - -# Initialize the Pieces ApiClient -api_client = pieces_os_client.ApiClient(configuration) - -# Enter a context with an instance of the ApiClient -with pieces_os_client.ApiClient(configuration) as api_client: - # Create an instance of the WellKnownApi class - api_instance = pieces_os_client.WellKnownApi(api_client) - - try: - # Retrieve the (wellknown) health of the Pieces OS - api_response = api_instance.get_well_known_health() - print("The response of WellKnownApi().get_well_known_health:") - print(api_response) # Response: ok - except Exception as e: - print("Exception when calling WellKnownApi->get_well_known_health: %s\n" % e) + port = 1000 + +pieces_client = PiecesClient(config={'baseUrl': f'http://localhost:{port}'}) ``` +## Determining Your Base URL + +In the code snippet above, we use the platform package to determine the base URL based on the operating system. + Run the following command to execute the script: ```sh diff --git a/sidebars.ts b/sidebars.ts index 63523b39a..ea9d2d085 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -606,65 +606,6 @@ const sidebars: SidebarsConfig = { ] }, ], -<<<<<<< Updated upstream - - // Pieces CLI Sidebar - cliSidebar: [ - { - type: 'ref', - id: 'installation-getting-started/what-am-i-installing', - label: '← Back to Learn', - }, - { - type: 'doc', - id: 'extensions-plugins/cli/index', - label: 'Overview', - }, - { - type: 'doc', - id: 'extensions-plugins/cli/quickstart', - label: 'Quickstart', - }, - { - type: 'doc', - id: 'extensions-plugins/cli/commands', - label: 'Commands', - }, - ], - - // Raycast Sidebar - raycastSidebar: [ - { - type: 'ref', - id: 'installation-getting-started/what-am-i-installing', - label: '← Back to Learn', - }, - { - type: 'doc', - id: 'extensions-plugins/raycast/index', - label: 'Overview', - }, - { - type: 'doc', - id: 'extensions-plugins/raycast/quickstart', - label: 'Quickstart', - }, - { - type: 'doc', - id: 'extensions-plugins/raycast/commands', - label: 'Commands', - }, - { - type: 'doc', - id: 'extensions-plugins/raycast/troubleshooting', - label: 'Troubleshooting', - } - ], - - // Generates sidebar for each active SDK - ...generatedSDKSidebars, -}; -======= // Generates sidebar for each active SDK ...generatedSDKSidebars, @@ -682,21 +623,20 @@ const sidebars: SidebarsConfig = { }, { type: 'doc', - id: 'build/sdks/python/quickstart', + id: 'build/sdks/python/quickstart/index', label: 'Quickstart', }, { type: 'doc', - id: 'build/sdks/python/assets', + id: 'build/sdks/python/assets/index', label: 'Assets', }, { type: 'doc', - id: 'build/sdks/python/copilot', + id: 'build/sdks/python/copilot/index', label: 'Copilot', }, ], }; ->>>>>>> Stashed changes export default sidebars; From a69d7f5d4c38934785af0dbfc5d986700e2ce6c6 Mon Sep 17 00:00:00 2001 From: choir27 Date: Thu, 22 Aug 2024 20:58:51 -0400 Subject: [PATCH 05/19] clean up formatting --- docs/build/sdks/python/assets/index.mdx | 14 ++++---- docs/build/sdks/python/copilot/index.mdx | 44 +++++++++++++++--------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/docs/build/sdks/python/assets/index.mdx b/docs/build/sdks/python/assets/index.mdx index 261de184a..c66fb532b 100644 --- a/docs/build/sdks/python/assets/index.mdx +++ b/docs/build/sdks/python/assets/index.mdx @@ -87,13 +87,13 @@ Edit the original format of the asset. | Name | Description | | ------------- | ------------ | -| data | The new data to be set. | +| **data** | The new data to be set. | ##### Raises: | Name | Description | | ------------- | ------------ | -| NotImplementedError | If the asset is an image.| +| **NotImplementedError** | If the asset is an image.| #### is_image Check if the asset is an image. @@ -102,7 +102,7 @@ Check if the asset is an image. | Type | Description | | ------------- | ------------ | -| bool | True if the asset is an image, otherwise False. | +| **bool** | `True` if the asset is an image, otherwise `False`. | #### classification Get the specific classification of the asset (e.g., py). @@ -111,7 +111,7 @@ Get the specific classification of the asset (e.g., py). | Type | Description | | ------------- | ------------ | -| classification value/None | The classification value of the asset, or None if not available. | +| **classification value**/**None** | The classification value of the asset, or `None` if not available. | #### classification setter Reclassify an asset @@ -119,7 +119,7 @@ Reclassify an asset #### name setter Edit the name of the asset. -- name: The new name to be set for the asset. +- `name`: The new name to be set for the asset. #### description Retrieve the description of the asset. @@ -128,14 +128,14 @@ Retrieve the description of the asset. | Type | Description | | ------------- | ------------ | -| string/None | The description text of the asset, or None if not available. | +| **string/None** | The description text of the asset, or `None` if not available. | #### annotations Get all annotations of the asset. | Type | Description | | ------------- | ------------ | -|Optional[Annotations]/None|The annotations if available, otherwise None.| +|**Optional[Annotations]/None** |The annotations if available, otherwise `None`.| ### Methods diff --git a/docs/build/sdks/python/copilot/index.mdx b/docs/build/sdks/python/copilot/index.mdx index f20030655..97d7d050b 100644 --- a/docs/build/sdks/python/copilot/index.mdx +++ b/docs/build/sdks/python/copilot/index.mdx @@ -59,7 +59,7 @@ Gets the ID of the conversation. | Type | Description | | ------------- | ------------ | -| string | The ID of the conversation.| +| **string** | The ID of the conversation.| #### name Gets the name of the conversation. @@ -68,7 +68,7 @@ Gets the name of the conversation. | Type | Description | | ------------- | ------------ | -| string | The name of the conversation, or "New Conversation" if the name is not set.| +| **string** | The name of the conversation, or "New Conversation" if the name is not set.| name = name: str Sets the name of the conversation. @@ -77,7 +77,7 @@ Sets the name of the conversation. | Name | Description | | ------------- | ------------ | -| str | The new name of the conversation. | +| **str** | The new name of the conversation. | #### messages() @@ -87,7 +87,7 @@ Retrieves the messages in the conversation. | Type | Description | | ------------- | ------------ | -| list | A list of BasicMessage instances representing the messages in the conversation. +| **list** | A list of BasicMessage instances representing the messages in the conversation. annotations | #### annotations @@ -99,7 +99,7 @@ Returns: | Type | Description | | ------------- | ------------ | -| dict/None | The annotations of the conversation, or None if not available. | +| **dict**/**None** | The annotations of the conversation, or None if not available. | #### description Gets the conversation description. @@ -108,7 +108,7 @@ Gets the conversation description. | Type | Description | | ------------- | ------------ | -| string | The description of the conversation. | +| **string** | The description of the conversation. | #### delete() Deletes the conversation. @@ -176,14 +176,14 @@ Gets the role of the message. | Type | Description | | ------------- | ------------ | -| Literal["USER", "SYSTEM", "ASSISTANT"] | The role of the message. | +| **Literal["USER", "SYSTEM", "ASSISTANT"]** | The role of the message. | #### id Gets the ID of the message. | Type | Description | | ------------- | ------------ | -| string | The ID of the message. | +| **string** | The ID of the message. | #### delete Deletes the message. @@ -231,14 +231,14 @@ Asks a question to the QGPT model and streams the responses. by default it will | Name | Description | Note | |------------- | ------------ |------------ | -| query | The question to ask. | [required] | -| pipeline | pipeline to follow. | [optional] | +| **query** | The question to ask. | [required] | +| **pipeline** | pipeline to follow. | [optional] | ### Returns | Type | Description | | ------------- | ------------ | -| QGPTStreamOutput | The streamed output from the QGPT model.| +| **QGPTStreamOutput** | The streamed output from the QGPT model.| ### Example @@ -261,20 +261,26 @@ for response in pieces_client.copilot.stream_question("Your question"): question(query, pipeline) ``` -Asks a question to the QGPT model and return the responses Note: the question is not a part of any conversation. +Asks a question to the QGPT model and return the responses + +:::info + +The question is not a part of any conversation. + +::: ### Parameters | Name | Description | Note | |------------- | ------------ |------------ | -| query | The question to ask. | [required] | -| pipeline | pipeline to follow. | [optional] | +| **query** | The question to ask. | [required] | +| **pipeline** | pipeline to follow. | [optional] | ### Returns | Type | Description | | ------------- | ------------ | -| QGPTStreamOutput | The streamed output from the QGPT model.| +| **QGPTStreamOutput** | The streamed output from the QGPT model.| ### Example @@ -305,7 +311,11 @@ context.raw_assets.append("import sublime") # snippet content context.clear() # clear all the context ``` -Note if you setted the context of the copilot you will get a value error in the ask_stream method if you added an invalid type +:::info + +If you setted the context of the copilot you will get a value error in the ask_stream method if you added an invalid type + +::: ### chats() @@ -341,7 +351,7 @@ Gets the current conversation being used in the copilot. | Type | Description | | ------------- | ------------ | -| **BasicChat/None** | The current BasicChat instance or None if no chat is set. | +| **BasicChat**/**None** | The current BasicChat instance or None if no chat is set. | ### Example From 2579ab9e3d9b0b4670cdb76865876159e316eccf Mon Sep 17 00:00:00 2001 From: choir27 Date: Thu, 22 Aug 2024 21:19:19 -0400 Subject: [PATCH 06/19] update code samples to be more consistent and fix any small mistakes in formatting --- docs/build/index.mdx | 51 +-------------------- docs/build/sdks/python/assets/index.mdx | 17 +++++-- docs/build/sdks/python/copilot/index.mdx | 20 ++++---- docs/build/sdks/python/index.mdx | 3 +- docs/build/sdks/python/quickstart/index.mdx | 9 +--- 5 files changed, 25 insertions(+), 75 deletions(-) diff --git a/docs/build/index.mdx b/docs/build/index.mdx index d78d768d5..ee9e58249 100644 --- a/docs/build/index.mdx +++ b/docs/build/index.mdx @@ -58,58 +58,11 @@ We're always working on improving and extending the current stack of available S

Python SDK for Pieces OS

- -
-
- {'Dart - Dart SDK -
- -

Dart SDK for Pieces OS

- -
-
-
- {'Kotlin - Kotlin SDK -
- -

Kotlin SDK for Pieces OS

-
+ diff --git a/docs/build/sdks/python/assets/index.mdx b/docs/build/sdks/python/assets/index.mdx index c66fb532b..62baa8442 100644 --- a/docs/build/sdks/python/assets/index.mdx +++ b/docs/build/sdks/python/assets/index.mdx @@ -63,7 +63,7 @@ for asset in assets: ## BasicAsset -The BasicAsset class provides a way to manage assets with various properties and methods. This document outlines the properties and methods available in the BasicAsset class. +The `BasicAsset` class provides a way to manage assets with various properties and methods. ```python BasicAsset(id) @@ -145,11 +145,18 @@ Delete the asset. #### `create()` Create a new asset. -Args: +##### Arguments -raw_content (str): The raw content of the asset. -metadata (Optional[FragmentMetadata]): The metadata of the asset. -Returns: str - The ID of the created asset. +| Name | Type| Description | +| ------------- | ------------ | ------------ | +| **raw_content** | **string** | The raw content of the asset. | +| **metadata** | **(Optional[FragmentMetadata])**| The metadata of the asset. | + +##### Returns + +| Type | Description | +| ------------- | ------------ | +| **string** | The ID of the created asset. | ### Example diff --git a/docs/build/sdks/python/copilot/index.mdx b/docs/build/sdks/python/copilot/index.mdx index 97d7d050b..c0a58dddb 100644 --- a/docs/build/sdks/python/copilot/index.mdx +++ b/docs/build/sdks/python/copilot/index.mdx @@ -52,7 +52,7 @@ BasicChat(id) ### Methods -####id +#### id Gets the ID of the conversation. ##### On return @@ -70,7 +70,7 @@ Gets the name of the conversation. | ------------- | ------------ | | **string** | The name of the conversation, or "New Conversation" if the name is not set.| -name = name: str +#### name = name: str Sets the name of the conversation. ##### Arguments @@ -93,8 +93,6 @@ annotations | #### annotations Gets the annotations of the conversation. -Returns: - ##### Returns: | Type | Description | @@ -162,7 +160,7 @@ pieces_client.close() ## BasicMessage -This represents a Copilot chat message to opentain that model you should be using pieces_client.copilot.chat.messages() to opentain the messages of the current chat. +This represents a Copilot chat message to opentain that model you should be using `pieces_client.copilot.chat.messages()` to open and maintain the messages of the current chat. ### Properties @@ -225,7 +223,7 @@ pieces_client.close() stream_question(query, pipeline) ``` -Asks a question to the QGPT model and streams the responses. by default it will create a new conversation and always use it in the ask. You can always change the conversation in copilot.chat = BasicChat(chat_id="YOU ID GOES HERE") +Asks a question to the QGPT model and streams the responses. By default it will create a new conversation and it always use it in the ask. You can always change the conversation in `copilot.chat = BasicChat(chat_id="YOU ID GOES HERE")` ### Parameters @@ -313,7 +311,7 @@ context.clear() # clear all the context :::info -If you setted the context of the copilot you will get a value error in the ask_stream method if you added an invalid type +If you setted the context of the copilot you will get a value error in the `ask_stream` method if you added an invalid type ::: @@ -329,7 +327,7 @@ Retrieves a list of all chat identifiers. | Type | Description | | ------------- | ------------ | -| **list[BasicChat]** | A list of BasicChat instances representing the chat identifiers. | +| **list[BasicChat]** | A list of `BasicChat` instances representing the chat identifiers. | ### Example @@ -351,7 +349,7 @@ Gets the current conversation being used in the copilot. | Type | Description | | ------------- | ------------ | -| **BasicChat**/**None** | The current BasicChat instance or None if no chat is set. | +| **BasicChat**/**None** | The current `BasicChat` instance or `None` if no chat is set. | ### Example @@ -375,13 +373,13 @@ Sets the current conversation to be used in the copilot. | Type | Description | | ------------- | ------------ | -| **BasicChat/None** | The BasicChat instance is set. | +| **BasicChat/None** | The `BasicChat` instance is set. | ### Raises | Type | Description | | ------------- | ------------ | -| **ValueError** | If the provided chat is not a valid BasicChat` instance. | +| **ValueError** | If the provided chat is not a valid `BasicChat` instance. | ```python new_chat = copilot.chats[0] diff --git a/docs/build/sdks/python/index.mdx b/docs/build/sdks/python/index.mdx index 1ab7e751a..578793c11 100644 --- a/docs/build/sdks/python/index.mdx +++ b/docs/build/sdks/python/index.mdx @@ -9,7 +9,7 @@ The Pieces SDK is a powerful code engine package designed for writing applicatio ## Requirements -The Pieces SDK has the following system requirements: +The Pieces Python SDK has the following system requirements: - Pieces OS running as a backend service. - Python environment with `pip` for installing the SDK package. @@ -20,7 +20,6 @@ Feature | Description ------------- | ------------- Simplified Interaction | The Pieces Copilot SDK simplifies the interaction with the Pieces OS Client SDK by providing easy-to-use methods for various operations. Manage Conversations | The SDK provides various methods to manage conversations such as fetching a specific conversation, updating conversation name, and more. -Get User Profile Picture | Retrieve the user's profile picture using the `get_user_profile_picture()` method. Copilot Chats | Communicate seamlessly with copilot chats functionality. Asset Management | Save and manage assets and formats efficiently. Local Server Interaction | Interact with a locally hosted server for various functionalities. diff --git a/docs/build/sdks/python/quickstart/index.mdx b/docs/build/sdks/python/quickstart/index.mdx index 17218e29b..2c655f78a 100644 --- a/docs/build/sdks/python/quickstart/index.mdx +++ b/docs/build/sdks/python/quickstart/index.mdx @@ -37,16 +37,9 @@ If you are using a local instance of Pieces OS: If you are using a remote instance of Pieces OS, use the URL you have set up for that. -```python -from pieces_copilot_sdk import PiecesClient - -# Replace 'your_base_url' with your actual base URL -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) -``` - ## Getting started -First, we will create a Python script to test the connection to the Pieces OS server. This involves creating a config.py file to store your configuration info and a wellknown.py file to test the connection. +First, we will create a Python script to test the connection to the Pieces OS server. This involves creating a `config.py` file to store your configuration info and a `wellknown.py` file to test the connection. ```python from pieces_os_client.wrapper import PiecesClient From f8f3e0a504b2d66765c8c3575c96d92de9c63544 Mon Sep 17 00:00:00 2001 From: choir27 Date: Fri, 23 Aug 2024 06:44:20 -0400 Subject: [PATCH 07/19] clean up docs --- docs/build/sdks/python/assets/index.mdx | 49 +++++----- docs/build/sdks/python/copilot/index.mdx | 101 ++++++++++---------- docs/build/sdks/python/index.mdx | 12 +-- docs/build/sdks/python/quickstart/index.mdx | 14 +-- 4 files changed, 88 insertions(+), 88 deletions(-) diff --git a/docs/build/sdks/python/assets/index.mdx b/docs/build/sdks/python/assets/index.mdx index 62baa8442..e20b4c3c4 100644 --- a/docs/build/sdks/python/assets/index.mdx +++ b/docs/build/sdks/python/assets/index.mdx @@ -3,7 +3,7 @@ title: Pieces Wrapper Python SDK Assets description: Learn how to set up and use the Pieces Wrapper Python SDK Asset methods --- -# Pieces wrapper python SDK asset methods +# Python Assets ## create_asset() @@ -15,7 +15,7 @@ Creates a new asset. ### Parameters -Name | Type | Notes +Param Name | Param Type | Param Notes ------------- | ------------ | ------------- **content** | **string**| [required] **metadata** | **FragmentMetadata**| [optional] @@ -65,56 +65,53 @@ for asset in assets: The `BasicAsset` class provides a way to manage assets with various properties and methods. -```python -BasicAsset(id) -``` - ### Parameters -| Name | Description | Type | Notes | +| Param Name | Param Description | Param Type | Param Notes | |------------- | ------------ | -------------| -------------| -| **id** | Your asset id. Raises: ValueError if the provided ID is invalid. | **string** | [required] | +| **id** | Your asset id. `Raises: ValueError` if the provided ID is invalid. | **string** | [required] | ### Properties #### id + Returns the asset ID. #### raw_content Edit the original format of the asset. -##### Arguments: +##### Parameters -| Name | Description | +| Param Name | Param Description | | ------------- | ------------ | | **data** | The new data to be set. | -##### Raises: +##### Raises -| Name | Description | +| Raise Name | Raise Description | | ------------- | ------------ | | **NotImplementedError** | If the asset is an image.| #### is_image Check if the asset is an image. -##### On return +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **bool** | `True` if the asset is an image, otherwise `False`. | #### classification -Get the specific classification of the asset (e.g., py). +Get the specific classification of the asset (ie. py). -##### On return +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **classification value**/**None** | The classification value of the asset, or `None` if not available. | #### classification setter -Reclassify an asset +Reclassify an asset. #### name setter Edit the name of the asset. @@ -124,16 +121,18 @@ Edit the name of the asset. #### description Retrieve the description of the asset. -##### On return +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **string/None** | The description text of the asset, or `None` if not available. | #### annotations Get all annotations of the asset. -| Type | Description | +##### Parameters + +| Param Type | Param Description | | ------------- | ------------ | |**Optional[Annotations]/None** |The annotations if available, otherwise `None`.| @@ -145,16 +144,16 @@ Delete the asset. #### `create()` Create a new asset. -##### Arguments +##### Parameters -| Name | Type| Description | +| Param Name | Param Type| Param Description | | ------------- | ------------ | ------------ | | **raw_content** | **string** | The raw content of the asset. | -| **metadata** | **(Optional[FragmentMetadata])**| The metadata of the asset. | +| **metadata** | **Optional[FragmentMetadata]**| The metadata of the asset. | ##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **string** | The ID of the created asset. | diff --git a/docs/build/sdks/python/copilot/index.mdx b/docs/build/sdks/python/copilot/index.mdx index c0a58dddb..5274662df 100644 --- a/docs/build/sdks/python/copilot/index.mdx +++ b/docs/build/sdks/python/copilot/index.mdx @@ -3,7 +3,7 @@ title: Pieces Wrapper Python SDK Copilot description: Learn how to set up and use the Pieces Wrapper Python SDK Copilot methods --- -# Pieces wrapper python SDK copilot methods +# Python Copilot ## stream_question() @@ -15,7 +15,7 @@ Ask Pieces Copilot a question and stream the response. ### Parameters -Name | Type | Notes +Param Name | Param Type | Param Notes ------------- | ------------ | ------------- **question** | **string**| [required] @@ -46,7 +46,7 @@ BasicChat(id) ### Parameters -| Name | Description | Type | Notes | +| Param Name | Param Description | Param Type | Param Notes | |------------- | ------------ | -------------| -------------| | **id** | Your conversation id. | **string** | [required] | @@ -55,56 +55,55 @@ BasicChat(id) #### id Gets the ID of the conversation. -##### On return +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **string** | The ID of the conversation.| #### name Gets the name of the conversation. -##### Returns: +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | -| **string** | The name of the conversation, or "New Conversation" if the name is not set.| +| **string** | Name of the conversation, or "New Conversation" if name is not set.| #### name = name: str Sets the name of the conversation. -##### Arguments +##### Parameters -| Name | Description | -| ------------- | ------------ | -| **str** | The new name of the conversation. | +| Param Name | Param Type | Param Description | +| ------------- | ------------ | ------------ | +| **name** | **string** | The new name of the conversation. | #### messages() Retrieves the messages in the conversation. -##### Returns: +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | -| **list** | A list of BasicMessage instances representing the messages in the conversation. -annotations | +| **list** | A list of `BasicMessage` instances representing the messages in the conversation. | #### annotations Gets the annotations of the conversation. -##### Returns: +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | -| **dict**/**None** | The annotations of the conversation, or None if not available. | +| **dict**/**None** | The annotations of the conversation, or `None` if not available. | #### description Gets the conversation description. -##### Returns: +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **string** | The description of the conversation. | @@ -160,7 +159,7 @@ pieces_client.close() ## BasicMessage -This represents a Copilot chat message to opentain that model you should be using `pieces_client.copilot.chat.messages()` to open and maintain the messages of the current chat. +TheΒ BasicMessageΒ class represents a Copilot chat message. To open and maintain the model, you should be usingΒ `pieces_client.copilot.chat.messages()`Β to open and maintain the messages of the current chat. ### Properties @@ -170,16 +169,18 @@ Sets the raw content of the message and updates it in the API. #### role Gets the role of the message. -##### Returns: +##### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **Literal["USER", "SYSTEM", "ASSISTANT"]** | The role of the message. | #### id Gets the ID of the message. -| Type | Description | +##### Returns + +| Return Type | Return Description | | ------------- | ------------ | | **string** | The ID of the message. | @@ -223,20 +224,20 @@ pieces_client.close() stream_question(query, pipeline) ``` -Asks a question to the QGPT model and streams the responses. By default it will create a new conversation and it always use it in the ask. You can always change the conversation in `copilot.chat = BasicChat(chat_id="YOU ID GOES HERE")` +Asks a question to the QGPT model and streams the responses. By default, it will create a new conversation, and it always uses it in the ask. You can always change the conversation inΒ `copilot.chat = BasicChat(chat_id="YOU ID GOES HERE")`. ### Parameters -| Name | Description | Note | +| Param Name | Param Description | Param Note | |------------- | ------------ |------------ | | **query** | The question to ask. | [required] | -| **pipeline** | pipeline to follow. | [optional] | +| **pipeline** | The pipeline to follow. | [optional] | ### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | -| **QGPTStreamOutput** | The streamed output from the QGPT model.| +| **QGPTStreamOutput** | The streamed output from the `QGPT` model.| ### Example @@ -259,7 +260,7 @@ for response in pieces_client.copilot.stream_question("Your question"): question(query, pipeline) ``` -Asks a question to the QGPT model and return the responses +Asks a question to the `QGPT` model and return the responses. :::info @@ -269,16 +270,16 @@ The question is not a part of any conversation. ### Parameters -| Name | Description | Note | +| Param Name | Param Description | Param Note | |------------- | ------------ |------------ | | **query** | The question to ask. | [required] | -| **pipeline** | pipeline to follow. | [optional] | +| **pipeline** | The pipeline to follow. | [optional] | ### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | -| **QGPTStreamOutput** | The streamed output from the QGPT model.| +| **QGPTStreamOutput** | The streamed output from the `QGPT` model.| ### Example @@ -300,6 +301,16 @@ copilot.context Returns a context model to interact with the conversation context. + +:::info + +If you set the context of the copilot, you will get a value error in the `ask_stream` method if you add an invalid type + +::: + + +### Example + ```python context = copilot.context context.paths.append("/path/to/folder/or/file") @@ -309,23 +320,13 @@ context.raw_assets.append("import sublime") # snippet content context.clear() # clear all the context ``` -:::info - -If you setted the context of the copilot you will get a value error in the `ask_stream` method if you added an invalid type - -::: - ### chats() -```python -chats() -``` - Retrieves a list of all chat identifiers. ### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **list[BasicChat]** | A list of `BasicChat` instances representing the chat identifiers. | @@ -347,7 +348,7 @@ Gets the current conversation being used in the copilot. ### Returns -| Type | Description | +| Return Type | Return Description | | ------------- | ------------ | | **BasicChat**/**None** | The current `BasicChat` instance or `None` if no chat is set. | @@ -369,15 +370,15 @@ copilot.chat = your_value_here Sets the current conversation to be used in the copilot. -### Arguments +### Parameters -| Type | Description | +| Param Type | Param Description | | ------------- | ------------ | | **BasicChat/None** | The `BasicChat` instance is set. | ### Raises -| Type | Description | +| Raise Type | Raise Description | | ------------- | ------------ | | **ValueError** | If the provided chat is not a valid `BasicChat` instance. | diff --git a/docs/build/sdks/python/index.mdx b/docs/build/sdks/python/index.mdx index 578793c11..3df5ceb51 100644 --- a/docs/build/sdks/python/index.mdx +++ b/docs/build/sdks/python/index.mdx @@ -1,11 +1,11 @@ --- -title: Pieces OS Python SDK -description: Learn how to set up and use the Pieces OS Python SDK. +title: Pieces Wrapper Python SDK +description: Learn about the Pieces Wrapper Python SDK. --- -# Pieces OS Python SDK +# Python SDK -The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server to enable features such as copilot chats, asset saving, and more. +The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server, enabling features such as copilot chats, asset saving, and more. ## Requirements @@ -27,6 +27,6 @@ Multi LLMs support | Use any Pieces supported LLMs to power apps. ## Community -If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). +If you have created your own SDK or any other technology-specific integration and would like us to list it here under community-maintained SDKs/integrations, please [contact us](https://github.com/pieces-app/opensource/discussions). -If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). +If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions), and you can also join our [Discord](https://discord.gg/getpieces). diff --git a/docs/build/sdks/python/quickstart/index.mdx b/docs/build/sdks/python/quickstart/index.mdx index 2c655f78a..67eeb7d7c 100644 --- a/docs/build/sdks/python/quickstart/index.mdx +++ b/docs/build/sdks/python/quickstart/index.mdx @@ -1,8 +1,10 @@ --- -title: Pieces OS Python SDK -description: Learn how to set up and use the Pieces OS Python SDK. +title: Pieces Wrapper Python SDK Quick Start +description: Quickly set up the Pieces Wrapper Python SDK --- +# Python QuickStart + Follow these steps to use the Pieces Python SDK. ## Download Pieces OS @@ -39,7 +41,7 @@ If you are using a remote instance of Pieces OS, use the URL you have set up for ## Getting started -First, we will create a Python script to test the connection to the Pieces OS server. This involves creating a `config.py` file to store your configuration info and a `wellknown.py` file to test the connection. +Create a Python script to test the connection to the Pieces OS server. Create a `main.py` file to test the connection. ```python from pieces_os_client.wrapper import PiecesClient @@ -55,8 +57,6 @@ else: pieces_client = PiecesClient(config={'baseUrl': f'http://localhost:{port}'}) ``` -## Determining Your Base URL - In the code snippet above, we use the platform package to determine the base URL based on the operating system. Run the following command to execute the script: @@ -66,6 +66,6 @@ python3 main.py ``` ## Community -If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). +If you have created your own SDK or any other technology-specific integration and would like us to list it here under community-maintained SDKs/integrations, please [contact us](https://github.com/pieces-app/opensource/discussions). -If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). +If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions), and you can also join our [Discord](https://discord.gg/getpieces). From a6c405d494da3872ec113a9d2ffa9ce4660ccb3e Mon Sep 17 00:00:00 2001 From: choir27 Date: Fri, 23 Aug 2024 06:48:12 -0400 Subject: [PATCH 08/19] replace baseURL with host --- docs/build/sdks/python/assets/index.mdx | 6 +++--- docs/build/sdks/python/copilot/index.mdx | 10 +++++----- docs/build/sdks/python/quickstart/index.mdx | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/build/sdks/python/assets/index.mdx b/docs/build/sdks/python/assets/index.mdx index e20b4c3c4..5a198318d 100644 --- a/docs/build/sdks/python/assets/index.mdx +++ b/docs/build/sdks/python/assets/index.mdx @@ -27,7 +27,7 @@ from pieces_os_client.wrapper import PiecesClient from pieces_os_client import FragmentMetadata # Replace 'your_base_url' with the base URL of your Pieces OS server -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) # Set the content and metadata for the new asset content = "print('Hello, World!')" @@ -53,7 +53,7 @@ Gets all your assets. from pieces_os_client.wrapper import PiecesClient # Replace 'your_base_url' with the base URL of your Pieces OS server -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) # Get all assets and print their names assets = pieces_client.assets() @@ -165,7 +165,7 @@ from pieces_copilot_sdk.basic_identifier import BasicAsset from pieces_os_client import ClassificationSpecificEnum # Replace 'your_base_url' with your actual base URL -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) asset = pieces_client.assets()[0] diff --git a/docs/build/sdks/python/copilot/index.mdx b/docs/build/sdks/python/copilot/index.mdx index 5274662df..68091782d 100644 --- a/docs/build/sdks/python/copilot/index.mdx +++ b/docs/build/sdks/python/copilot/index.mdx @@ -24,7 +24,7 @@ Param Name | Param Type | Param Notes ```python from pieces_os_client.wrapper import PiecesClient -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) # Set the question you want to ask question = "What is Object-Oriented Programming?" @@ -116,7 +116,7 @@ Deletes the conversation. from pieces_copilot_sdk import PiecesClient # Replace 'your_base_url' with your actual base URL -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) # Initialize a BasicChat instance chat = pieces_client.copilot.chats()[0] @@ -193,7 +193,7 @@ Deletes the message. from pieces_copilot_sdk import PiecesClient # Replace 'your_base_url' with your actual base URL -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) # Initialize a BasicChat instance chat = pieces_client.copilot.chats()[0] @@ -245,7 +245,7 @@ Asks a question to the QGPT model and streams the responses. By default, it will from pieces_copilot_sdk import PiecesClient # Replace 'your_base_url' with your actual base URL -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) for response in pieces_client.copilot.stream_question("Your question"): if response.question: @@ -287,7 +287,7 @@ The question is not a part of any conversation. from pieces_copilot_sdk import PiecesClient # Replace 'your_base_url' with your actual base URL -pieces_client = PiecesClient(config={'baseUrl': 'your_base_url'}) +pieces_client = PiecesClient(config={'host': 'your_base_url'}) text = pieces_client.copilot.question("Your question").answers.iterable[0].text print(text) diff --git a/docs/build/sdks/python/quickstart/index.mdx b/docs/build/sdks/python/quickstart/index.mdx index 67eeb7d7c..8a51c6c2e 100644 --- a/docs/build/sdks/python/quickstart/index.mdx +++ b/docs/build/sdks/python/quickstart/index.mdx @@ -54,7 +54,7 @@ if 'Linux' in platform_info: else: port = 1000 -pieces_client = PiecesClient(config={'baseUrl': f'http://localhost:{port}'}) +pieces_client = PiecesClient(config={'host': f'http://localhost:{port}'}) ``` In the code snippet above, we use the platform package to determine the base URL based on the operating system. From 01fb7a7a6131e91bc0d25e9a6a4e0d353b74c2a4 Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Fri, 23 Aug 2024 13:41:48 -0400 Subject: [PATCH 09/19] docs(refactor): update SDK docs for Python integration --- docs/build/sdks/python/assets/index.mdx | 258 +++++++++++++------- docs/build/sdks/python/index.mdx | 53 ++-- docs/build/sdks/python/quickstart/index.mdx | 125 +++++++--- sidebars.ts | 138 ++++++++--- src/lib/activeSDK.ts | 8 +- 5 files changed, 392 insertions(+), 190 deletions(-) diff --git a/docs/build/sdks/python/assets/index.mdx b/docs/build/sdks/python/assets/index.mdx index 5a198318d..cbd5c8c44 100644 --- a/docs/build/sdks/python/assets/index.mdx +++ b/docs/build/sdks/python/assets/index.mdx @@ -1,30 +1,34 @@ --- -title: Pieces Wrapper Python SDK Assets -description: Learn how to set up and use the Pieces Wrapper Python SDK Asset methods +title: Pieces OS Client Python SDK Assets +description: Learn how to set up and use the Pieces OS Client Python SDK to manage assets. --- -# Python Assets +import Video from "/src/components/Video"; -## create_asset() +Use the following methods to manage your assets with the Pieces OS Client Python SDK. + +## Asset Management + +### `create_asset()` + +Creates a new asset. ```python create_asset(content, metadata) ``` -Creates a new asset. - -### Parameters +#### Parameters -Param Name | Param Type | Param Notes -------------- | ------------ | ------------- - **content** | **string**| [required] - **metadata** | **FragmentMetadata**| [optional] +| Param Name | Param Type | Param Notes | +|------------- |------------ |-------------| +| **content** | **string** | [required] | +| **metadata** | **FragmentMetadata** | [optional] | -### Example +#### Example ```python from pieces_os_client.wrapper import PiecesClient -from pieces_os_client import FragmentMetadata +from pieces_os_client import ClassificationSpecificEnum, FragmentMetadata # Replace 'your_base_url' with the base URL of your Pieces OS server pieces_client = PiecesClient(config={'host': 'your_base_url'}) @@ -37,17 +41,52 @@ metadata = FragmentMetadata(ext=ClassificationSpecificEnum.PY) # optional metada new_asset_id = pieces_client.create_asset(content, metadata) print(f"Created asset with ID: {new_asset_id}") + +# Close the client +pieces_client.close() ``` -## assets() +### `asset()` + +Gets a specific asset. ```python -assets() +asset(asset_id) +``` + +#### Parameters + +| Param Name | Param Type | Param Notes | +|------------- |------------ |-------------| +| **asset_id** | **string** | [required] | + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Replace 'your_base_url' with the base URL of your Pieces OS server +pieces_client = PiecesClient(config={'host': 'your_base_url'}) + +# Get the asset ID +asset_id = "your_asset_id" + +# Retrieve the asset +asset = pieces_client.asset(asset_id) + +# Close the client +pieces_client.close() ``` +### `assets()` + Gets all your assets. -### Example +```python +assets() +``` + +#### Example ```python from pieces_os_client.wrapper import PiecesClient @@ -58,110 +97,155 @@ pieces_client = PiecesClient(config={'host': 'your_base_url'}) # Get all assets and print their names assets = pieces_client.assets() for asset in assets: - logger.info(f"Asset Name: {asset.name}") + print(f"Asset Name: {asset.name}") + +# Close the client +pieces_client.close() ``` -## BasicAsset +## BasicAsset Class The `BasicAsset` class provides a way to manage assets with various properties and methods. -### Parameters - -| Param Name | Param Description | Param Type | Param Notes | -|------------- | ------------ | -------------| -------------| -| **id** | Your asset id. `Raises: ValueError` if the provided ID is invalid. | **string** | [required] | - ### Properties -#### id +| Property Name | Property Description | +|--------------- |----------------------| +| **id** | The ID of the asset. | +| **asset** | The full [Asset](/build/reference/python/models/Asset) object. Should **only** be used for properties not available in the `BasicAsset` class. | +| **raw_content** | The content of the asset. | +| **is_image** | Boolean indicating if the asset is an image. | +| **classification** | The specific classification of the asset (e.g., `py`). | +| **name** | The name of the asset. | +| **description** | The description of the asset. | +| **annotations** | The annotations of the asset. | + +### Methods -Returns the asset ID. +#### `create()` -#### raw_content -Edit the original format of the asset. +Creates a new asset. ##### Parameters -| Param Name | Param Description | -| ------------- | ------------ | -| **data** | The new data to be set. | +| Param Name | Param Type | Param Description | +|------------ |------------|------------------| +| **raw_content** | **string** | The raw content of the asset. | +| **metadata** | **Optional[FragmentMetadata]** | The metadata of the asset. | -##### Raises +##### Returns -| Raise Name | Raise Description | -| ------------- | ------------ | -| **NotImplementedError** | If the asset is an image.| +| Return Type | Return Description | +|------------- |-------------------| +| **string** | The ID of the created asset. | -#### is_image -Check if the asset is an image. +##### Example -##### Returns +```python +from pieces_os_client.wrapper import PiecesClient +from pieces_os_client.wrapper.basic_identifier.asset import BasicAsset +from pieces_os_client import ClassificationSpecificEnum, FragmentMetadata -| Return Type | Return Description | -| ------------- | ------------ | -| **bool** | `True` if the asset is an image, otherwise `False`. | +# Replace 'your_base_url' with the base URL of your Pieces OS server +pieces_client = PiecesClient(config={'host': 'http://localhost:1000'}) -#### classification -Get the specific classification of the asset (ie. py). +# Create a new asset +content = "print('Hello, World!')" +metadata = FragmentMetadata(ext=ClassificationSpecificEnum.PY) +new_asset_id = BasicAsset.create(content, metadata) +print(f"New Asset ID: {new_asset_id}") -##### Returns +# Close the client +pieces_client.close() +``` -| Return Type | Return Description | -| ------------- | ------------ | -| **classification value**/**None** | The classification value of the asset, or `None` if not available. | +#### `delete()` -#### classification setter -Reclassify an asset. +Deletes the asset. -#### name setter -Edit the name of the asset. +##### Example -- `name`: The new name to be set for the asset. +```python +# Retrieve the asset +asset = pieces_client.asset(asset_id) -#### description -Retrieve the description of the asset. +# Delete the asset +asset.delete() -##### Returns +# Close the client +pieces_client.close() +``` -| Return Type | Return Description | -| ------------- | ------------ | -| **string/None** | The description text of the asset, or `None` if not available. | +#### `raw_content` -#### annotations -Get all annotations of the asset. +Updates the raw content of the asset. -##### Parameters +##### Example -| Param Type | Param Description | -| ------------- | ------------ | -|**Optional[Annotations]/None** |The annotations if available, otherwise `None`.| +```python +# Retrieve the asset +asset = pieces_client.asset(new_asset_id) -### Methods +# Get the asset content +content = asset.raw_content +print(f"Original Content: {content}") -#### `delete()` -Delete the asset. +# Update the content +asset.raw_content = content + "\n# This is a comment" +print(f"Updated Content: {asset.raw_content}") -#### `create()` -Create a new asset. +# Close the client +pieces_client.close() +``` -##### Parameters +#### `classification` -| Param Name | Param Type| Param Description | -| ------------- | ------------ | ------------ | -| **raw_content** | **string** | The raw content of the asset. | -| **metadata** | **Optional[FragmentMetadata]**| The metadata of the asset. | +Updates the classification of the asset. -##### Returns +##### Example + +```python +# Retrieve the asset +asset = pieces_client.asset(new_asset_id) + +# Get the asset classification +classification = asset.classification.value if asset.classification else "None" +print(f"Asset Classification: {classification}") + +# Update the classification +asset.classification = ClassificationSpecificEnum.SH # Reclassify to shell +print(f"New Classification: {classification}") + +# Close the client +pieces_client.close() +``` -| Return Type | Return Description | -| ------------- | ------------ | -| **string** | The ID of the created asset. | +#### `name` -### Example +Updates the name of the asset. + +##### Example ```python -from pieces_copilot_sdk import PiecesClient -from pieces_copilot_sdk.basic_identifier import BasicAsset +# Retrieve the asset +asset = pieces_client.asset(new_asset_id) + +# Get the asset name +print(f"Current Asset Name: {asset.name}") + +# Update the name +asset.name = "Updated Asset Name" +print(f"Updated Asset Name: {asset.name}") + +# Close the client +pieces_client.close() +``` + +### Full Example + +```python +from pieces_os_client.wrapper import PiecesClient +from pieces_os_client.basic_asset import BasicAsset from pieces_os_client import ClassificationSpecificEnum # Replace 'your_base_url' with your actual base URL @@ -173,6 +257,10 @@ asset = pieces_client.assets()[0] asset_id = asset.id print(f"Asset ID: {asset_id}") +# Get the full asset object (only for properties not available in BasicAsset) +full_asset = asset.asset +print(f"Full Asset Object: {full_asset}") + # Check if the asset is an image if asset.is_image: print("The asset is an image.") @@ -212,10 +300,6 @@ print("Asset deleted.") # Create a new asset new_asset_id = BasicAsset.create("New Asset content") print(f"New Asset ID: {new_asset_id}") -pieces_client.close() -``` - -## Community -If you have created your own SDK or any other technology specific integration and would like us to list it here under community maintained SDKs/integrations please [contact us](https://github.com/pieces-app/opensource/discussions). -If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions) and you can also join our [Discord](https://discord.gg/getpieces). \ No newline at end of file +pieces_client.close() +``` \ No newline at end of file diff --git a/docs/build/sdks/python/index.mdx b/docs/build/sdks/python/index.mdx index 3df5ceb51..7274fffa3 100644 --- a/docs/build/sdks/python/index.mdx +++ b/docs/build/sdks/python/index.mdx @@ -1,32 +1,37 @@ --- -title: Pieces Wrapper Python SDK -description: Learn about the Pieces Wrapper Python SDK. +title: Pieces OS Client Python SDK +description: The Pieces OS Client SDK is a powerful code engine package designed for writing applications on top of Pieces OS. --- -# Python SDK +import Grid from "/src/components/Grid"; +import {CardWithoutCTA} from "/src/components/Card"; +import CTAButton from "/src/components/CTAButton"; -The Pieces SDK is a powerful code engine package designed for writing applications on top of Pieces OS. It facilitates communication with a locally hosted server, enabling features such as copilot chats, asset saving, and more. +The Pieces OS Client Python SDK is a powerful code engine package designed for writing applications on top of Pieces OS. The SDK provides easy-to-use methods for various operations such as managing conversations, copilot chats, asset management, local server interaction, and more. -## Requirements - -The Pieces Python SDK has the following system requirements: - -- Pieces OS running as a backend service. -- Python environment with `pip` for installing the SDK package. + ## Features -Feature | Description -------------- | ------------- -Simplified Interaction | The Pieces Copilot SDK simplifies the interaction with the Pieces OS Client SDK by providing easy-to-use methods for various operations. -Manage Conversations | The SDK provides various methods to manage conversations such as fetching a specific conversation, updating conversation name, and more. -Copilot Chats | Communicate seamlessly with copilot chats functionality. -Asset Management | Save and manage assets and formats efficiently. -Local Server Interaction | Interact with a locally hosted server for various functionalities. -Multi LLMs support | Use any Pieces supported LLMs to power apps. - - -## Community -If you have created your own SDK or any other technology-specific integration and would like us to list it here under community-maintained SDKs/integrations, please [contact us](https://github.com/pieces-app/opensource/discussions). - -If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions), and you can also join our [Discord](https://discord.gg/getpieces). + +
+

πŸ€– Copilot Chats

+

Communicate seamlessly with our copilot functionality.

+
+
+

πŸ“ Asset Management

+

Save and manage assets and formats efficiently.

+
+
+

πŸ–₯ Local Server Interaction

+

Interact with a locally hosted server for various functionalities.

+
+
+

🧠 Cloud & Local LLM Support

+

Tap into your favorite cloud or local LLM with ease.

+
+
+ +## Want to Contribute? + +Don't see a feature you need? We welcome contributions to the Pieces OS Client Python SDK. Check out the [GitHub repository](https://github.com/pieces-app/pieces-os-client-sdk-for-python) to get started. \ No newline at end of file diff --git a/docs/build/sdks/python/quickstart/index.mdx b/docs/build/sdks/python/quickstart/index.mdx index 8a51c6c2e..d6132a8a0 100644 --- a/docs/build/sdks/python/quickstart/index.mdx +++ b/docs/build/sdks/python/quickstart/index.mdx @@ -1,71 +1,118 @@ --- -title: Pieces Wrapper Python SDK Quick Start +title: Pieces Wrapper Python SDK Quickstart description: Quickly set up the Pieces Wrapper Python SDK --- -# Python QuickStart +# Quickstart with Pieces OS Client Python SDK -Follow these steps to use the Pieces Python SDK. +The Pieces OS Client SDK has a built-in wrapper that simplifies the process of interacting with the Pieces OS server. Here's how you can get started with the wrapper. -## Download Pieces OS +## Installation -:::info +To get started with the Pieces OS Client SDK, follow these steps: -You must either have Pieces OS installed on your local machine or have access to a remote instance of Pieces OS to use this SDK. +1. **Download Pieces OS**: Pieces OS serves as the primary backend service, providing essential functionality for the SDK. Download the appropriate version for your operating system: + - [macOS](https://docs.pieces.app/installation-getting-started/macos) + - [Windows](https://docs.pieces.app/installation-getting-started/windows) + - [Linux](https://docs.pieces.app/installation-getting-started/linux) -::: +2. **Install the SDK**: Use pip to install the Pieces OS Client SDK package: + ```shell + pip install pieces_os_client + ``` -Download [**Pieces OS**](/installation-getting-started/pieces-os) for your operating system: +## Initialize the Pieces Client -- [**macOS**](/installation-getting-started/macos) -- [**Windows**](/installation-getting-started/windows) -- [**Linux**](/installation-getting-started/linux) - -## Install Python SDK +```python +from pieces_os_client.wrapper import PiecesClient +import platform -Use pip to install the Pieces Python SDK using the following command: +# Defining the port based on the operating system +platform_info = platform.platform() +if 'Linux' in platform_info: + port = 5323 +else: + port = 1000 -```sh -pip install pieces_os_client +pieces_client = PiecesClient(config={'host': f'http://localhost:{port}'}) ``` -## Initialize SDK +### Determining Your Base URL + +In the code snippet above, we use the `platform` package to determine the base URL based on the operating system. However, you can also set the base URL manually if you know your application will only run on a specific operating system. -After installing the SDK, you must initialize the SDK with your base URL. The base URL will depend on your setup. +- **Local Instance of Pieces OS:** + - On macOS/Windows, use `http://localhost:1000` + - On Linux, use `http://localhost:5323` +- **Remote Instance of Pieces OS:** + - Use the URL you have set up for your remote instance -If you are using a local instance of Pieces OS: -- On macOS/Windows, use http://localhost:1000 -- On Linux, use http://localhost:5323 +## Examples -If you are using a remote instance of Pieces OS, use the URL you have set up for that. +Here are some examples of how you can use to get familiar with the Pieces OS Client SDK. -## Getting started +### Create a New Asset -Create a Python script to test the connection to the Pieces OS server. Create a `main.py` file to test the connection. +To create a new asset, you can use the `create_asset` method of the Pieces Client. Here's an example of how to create a new asset: ```python from pieces_os_client.wrapper import PiecesClient -import platform +from pieces_os_client import FragmentMetadata -# Defining the port based on the operating system -platform_info = platform.platform() -if 'Linux' in platform_info: - port = 5323 -else: - port = 1000 +# Replace 'your_base_url' with the base URL of your Pieces OS server +pieces_client = PiecesClient(config={'host': 'your_base_url'}) + +# Set the content and metadata for the new asset +content = "print('Hello, World!')" +metadata = FragmentMetadata(ext=ClassificationSpecificEnum.PY) # optional metadata + +# Create the new asset using the content and metadata +new_asset_id = pieces_client.create_asset(content, metadata) + +print(f"Created asset with ID: {new_asset_id}") +``` + +### Get All Assets + +To get all your assets, you can use the `assets` method of the Pieces Client. Here's an example of how to get all your assets and print their names: + +```python +from pieces_os_client.wrapper import PiecesClient + +# Replace 'your_base_url' with the base URL of your Pieces OS server +pieces_client = PiecesClient(config={'host': 'your_base_url'}) + +# Get all assets and print their names +assets = pieces_client.assets() +for asset in assets: + logger.info(f"Asset Name: {asset.name}") -pieces_client = PiecesClient(config={'host': f'http://localhost:{port}'}) ``` -In the code snippet above, we use the platform package to determine the base URL based on the operating system. +### Ask a Question to Pieces Copilot -Run the following command to execute the script: +To ask a question to Pieces Copilot and stream the response, you can use the `stream_question` method of the Pieces Client. Here's an example of how to ask a question and stream the response: -```sh -python3 main.py +```python +from pieces_os_client.wrapper import PiecesClient + +pieces_client = PiecesClient(config={'host': 'your_base_url'}) + +# Set the question you want to ask +question = "What is Object-Oriented Programming?" + +# Ask the question and stream the response +for response in pieces_client.copilot.stream_question(question): + if response.question: + # Each answer is a chunk of the entire response to the question + answers = response.question.answers.iterable + for answer in answers: + print(answer.text,end="") ``` -## Community -If you have created your own SDK or any other technology-specific integration and would like us to list it here under community-maintained SDKs/integrations, please [contact us](https://github.com/pieces-app/opensource/discussions). +## Next Steps + +You can explore more features and functionalities of the built-in wrapper. -If you would like to help us expand Pieces' list of SDKs, you can start a new discussion on our [Open Source Discussions](https://github.com/pieces-app/opensource/discussions), and you can also join our [Discord](https://discord.gg/getpieces). +- [Assets SDK](/build/sdks/python/assets) +- [Copilot SDK](/build/sdks/python/copilot) diff --git a/sidebars.ts b/sidebars.ts index ea9d2d085..468d3cb23 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -564,15 +564,21 @@ const sidebars: SidebarsConfig = { id: 'build/index', label: 'Overview', }, + // { + // type: 'doc', + // id: 'build/examples/index', + // label: 'πŸ“š Examples', + // }, { - type: 'doc', - id: 'build/examples/index', - label: 'πŸ“š Examples', - }, - { - type: 'doc', - id: 'build/sdks/python/index', - label: 'πŸ“š Python', + type: 'category', + label: 'πŸ”§ SDKs', + items: [ + { + type: 'doc', + id: 'build/sdks/python/index', + label: 'Python SDK', + }, + ], }, // { // type: 'doc', @@ -606,37 +612,91 @@ const sidebars: SidebarsConfig = { ] }, ], - // Generates sidebar for each active SDK - ...generatedSDKSidebars, - // Python SDK WrapperSidebar - pythonSDKWrapperSidebar: [ - { - type: 'ref', - id: 'build/index', - label: '← Back to Build', - }, - { - type: 'doc', - id: 'build/sdks/python/index', - label: 'Overview', - }, - { - type: 'doc', - id: 'build/sdks/python/quickstart/index', - label: 'Quickstart', - }, - { - type: 'doc', - id: 'build/sdks/python/assets/index', - label: 'Assets', - }, - { - type: 'doc', - id: 'build/sdks/python/copilot/index', - label: 'Copilot', - }, - ], - }; + // Pieces CLI Sidebar + cliSidebar: [ + { + type: 'ref', + id: 'installation-getting-started/what-am-i-installing', + label: '← Back to Learn', + }, + { + type: 'doc', + id: 'extensions-plugins/cli/index', + label: 'Overview', + }, + { + type: 'doc', + id: 'extensions-plugins/cli/quickstart', + label: 'Quickstart', + }, + { + type: 'doc', + id: 'extensions-plugins/cli/commands', + label: 'Commands', + }, + ], + + // Raycast Sidebar + raycastSidebar: [ + { + type: 'ref', + id: 'installation-getting-started/what-am-i-installing', + label: '← Back to Learn', + }, + { + type: 'doc', + id: 'extensions-plugins/raycast/index', + label: 'Overview', + }, + { + type: 'doc', + id: 'extensions-plugins/raycast/quickstart', + label: 'Quickstart', + }, + { + type: 'doc', + id: 'extensions-plugins/raycast/commands', + label: 'Commands', + }, + { + type: 'doc', + id: 'extensions-plugins/raycast/troubleshooting', + label: 'Troubleshooting', + } + ], + + // Python SDK WrapperSidebar + pythonSDKWrapperSidebar: [ + { + type: 'ref', + id: 'build/index', + label: '← Back to Build', + }, + { + type: 'doc', + id: 'build/sdks/python/index', + label: 'Overview', + }, + { + type: 'doc', + id: 'build/sdks/python/quickstart/index', + label: 'Quickstart', + }, + { + type: 'doc', + id: 'build/sdks/python/assets/index', + label: 'Assets', + }, + { + type: 'doc', + id: 'build/sdks/python/copilot/index', + label: 'Copilot', + }, + ], + + // Generates sidebar for each active SDK + ...generatedSDKSidebars, +}; export default sidebars; diff --git a/src/lib/activeSDK.ts b/src/lib/activeSDK.ts index acd6818fd..b7cab17d6 100644 --- a/src/lib/activeSDK.ts +++ b/src/lib/activeSDK.ts @@ -2,10 +2,16 @@ // List of SDKs to display on the docs const activeSDKs = [ + 'Typescript', 'Python', ]; -export const allSDKs = [...activeSDKs]; +const inactiveSDKs = [ + 'Dart', + 'Kotlin', +] + +export const allSDKs = [...activeSDKs, ...inactiveSDKs]; // Template for the sidebar items for each SDK const baseSidebarItems: { From 36f4cfae0736c4e8730a39f7b90b326e551677cc Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Fri, 23 Aug 2024 13:42:39 -0400 Subject: [PATCH 10/19] style: Correct capitalization of TypeScript --- src/lib/activeSDK.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/activeSDK.ts b/src/lib/activeSDK.ts index b7cab17d6..d53c264b5 100644 --- a/src/lib/activeSDK.ts +++ b/src/lib/activeSDK.ts @@ -2,15 +2,13 @@ // List of SDKs to display on the docs const activeSDKs = [ - 'Typescript', + 'TypeScript', 'Python', ]; - const inactiveSDKs = [ 'Dart', 'Kotlin', ] - export const allSDKs = [...activeSDKs, ...inactiveSDKs]; // Template for the sidebar items for each SDK From 7f33ba2fafa7cbd818c0bb6dd83c2d16d3e073e1 Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Fri, 23 Aug 2024 15:14:25 -0400 Subject: [PATCH 11/19] docs: update Python SDK documentation and examples --- docs/build/examples/index.mdx | 12 + .../python/{assets/index.mdx => assets.mdx} | 34 +- docs/build/sdks/python/copilot/index.mdx | 390 +++--------------- docs/build/sdks/python/index.mdx | 2 +- .../{quickstart/index.mdx => quickstart.mdx} | 22 +- sidebars.ts | 23 +- src/lib/activeSDK.ts | 5 +- 7 files changed, 111 insertions(+), 377 deletions(-) rename docs/build/sdks/python/{assets/index.mdx => assets.mdx} (89%) rename docs/build/sdks/python/{quickstart/index.mdx => quickstart.mdx} (86%) diff --git a/docs/build/examples/index.mdx b/docs/build/examples/index.mdx index bdf938ae4..8c434c44c 100644 --- a/docs/build/examples/index.mdx +++ b/docs/build/examples/index.mdx @@ -8,6 +8,18 @@ import CTAButton from "/src/components/CTAButton"; import {GithubIcon} from "/src/components/Icons"; import {MiniSpacer} from "/src/components/Spacers"; +Explore projects that use the Pieces SDK in various frameworks. + +:::info + +These projects are community-contributed and may not be maintained by the Pieces team. + +These projects may not using our latest [SDKs](/build/sdks/python). We recommend using the built-in wrapper SDKs for an improved developer experience. + +::: + +## Examples +
diff --git a/docs/build/sdks/python/quickstart/index.mdx b/docs/build/sdks/python/quickstart.mdx similarity index 86% rename from docs/build/sdks/python/quickstart/index.mdx rename to docs/build/sdks/python/quickstart.mdx index d6132a8a0..363ede35d 100644 --- a/docs/build/sdks/python/quickstart/index.mdx +++ b/docs/build/sdks/python/quickstart.mdx @@ -25,16 +25,9 @@ To get started with the Pieces OS Client SDK, follow these steps: ```python from pieces_os_client.wrapper import PiecesClient -import platform -# Defining the port based on the operating system -platform_info = platform.platform() -if 'Linux' in platform_info: - port = 5323 -else: - port = 1000 - -pieces_client = PiecesClient(config={'host': f'http://localhost:{port}'}) +# Initialize the PiecesClient +pieces_client = PiecesClient() ``` ### Determining Your Base URL @@ -59,8 +52,8 @@ To create a new asset, you can use the `create_asset` method of the Pieces Clien from pieces_os_client.wrapper import PiecesClient from pieces_os_client import FragmentMetadata -# Replace 'your_base_url' with the base URL of your Pieces OS server -pieces_client = PiecesClient(config={'host': 'your_base_url'}) +# Initialize the PiecesClient +pieces_client = PiecesClient() # Set the content and metadata for the new asset content = "print('Hello, World!')" @@ -79,8 +72,8 @@ To get all your assets, you can use the `assets` method of the Pieces Client. He ```python from pieces_os_client.wrapper import PiecesClient -# Replace 'your_base_url' with the base URL of your Pieces OS server -pieces_client = PiecesClient(config={'host': 'your_base_url'}) +# Initialize the PiecesClient +pieces_client = PiecesClient() # Get all assets and print their names assets = pieces_client.assets() @@ -96,7 +89,8 @@ To ask a question to Pieces Copilot and stream the response, you can use the `st ```python from pieces_os_client.wrapper import PiecesClient -pieces_client = PiecesClient(config={'host': 'your_base_url'}) +# Initialize the PiecesClient +pieces_client = PiecesClient() # Set the question you want to ask question = "What is Object-Oriented Programming?" diff --git a/sidebars.ts b/sidebars.ts index 468d3cb23..194f8d530 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -564,11 +564,11 @@ const sidebars: SidebarsConfig = { id: 'build/index', label: 'Overview', }, - // { - // type: 'doc', - // id: 'build/examples/index', - // label: 'πŸ“š Examples', - // }, + { + type: 'doc', + id: 'build/examples/index', + label: 'πŸ“š Examples', + }, { type: 'category', label: 'πŸ”§ SDKs', @@ -580,6 +580,15 @@ const sidebars: SidebarsConfig = { }, ], }, + { + type: 'category', + label: 'πŸ” API Reference', + items: allSDKs.map(sdk => ({ + type: 'doc' as const, + id: `build/reference/${sdk.toLowerCase()}/index`, + label: `${sdk}` + })) + }, // { // type: 'doc', // id: 'build/tutorials/index', @@ -680,12 +689,12 @@ const sidebars: SidebarsConfig = { }, { type: 'doc', - id: 'build/sdks/python/quickstart/index', + id: 'build/sdks/python/quickstart', label: 'Quickstart', }, { type: 'doc', - id: 'build/sdks/python/assets/index', + id: 'build/sdks/python/assets', label: 'Assets', }, { diff --git a/src/lib/activeSDK.ts b/src/lib/activeSDK.ts index d53c264b5..32c901844 100644 --- a/src/lib/activeSDK.ts +++ b/src/lib/activeSDK.ts @@ -9,7 +9,10 @@ const inactiveSDKs = [ 'Dart', 'Kotlin', ] -export const allSDKs = [...activeSDKs, ...inactiveSDKs]; +export const allSDKs = [ + ...activeSDKs, + // ...inactiveSDKs +]; // Template for the sidebar items for each SDK const baseSidebarItems: { From ae33595624f6779640360cde228c1b8479a791f2 Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 10:41:30 -0400 Subject: [PATCH 12/19] docs: Update Python SDK Copilot documentation --- docs/build/sdks/python/copilot.mdx | 256 +++++++++++++++++++++++ docs/build/sdks/python/copilot/index.mdx | 110 ---------- docs/build/sdks/python/quickstart.mdx | 9 +- sidebars.ts | 2 +- 4 files changed, 265 insertions(+), 112 deletions(-) create mode 100644 docs/build/sdks/python/copilot.mdx delete mode 100644 docs/build/sdks/python/copilot/index.mdx diff --git a/docs/build/sdks/python/copilot.mdx b/docs/build/sdks/python/copilot.mdx new file mode 100644 index 000000000..53f80f93d --- /dev/null +++ b/docs/build/sdks/python/copilot.mdx @@ -0,0 +1,256 @@ +--- +title: Pieces OS Client Python SDK Copilot +description: Learn how to set up and use the Pieces OS Client Python SDK to communicate Pieces Copilot. +--- + +Use the following methods to communicate with Pieces Copilot using the Pieces OS Client Python SDK. + +## Copilot Management + +### Ask a Question to Pieces Copilot + +The `stream_question()` requires a question as a parameter and will stream the response. + +#### Parameters + +| Param Name | Param Type | Param Notes | +|------------- |------------ |-------------| +| **question** | **string** | [required] | + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Set the question you want to ask +question = "What is Object-Oriented Programming?" + +# Ask the question and stream the response +for response in pieces_client.copilot.stream_question(question): + if response.question: + # Each answer is a chunk of the entire response to the question + answers = response.question.answers.iterable + for answer in answers: + print(answer.text,end="") + +# Close the client +pieces_client.close() +``` + +If you do not want to stream the response, you can use the `quesiton()` method instead. + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Set the question you want to ask +question = "What is Object-Oriented Programming?" + +# Ask the question and get the response +response = pieces_client.copilot.question(question) + +# Print the response message +message = response.answers.iterable[0].text +print(message) + +# Close the client +pieces_client.close() +``` + +### Get All Chats + +The `chats()` method returns a list of all chats. + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Get all chats and print their names +chats = pieces_client.copilot.chats() +for chat in chats: + print(chat.name) + +# Close the client +pieces_client.close() +``` + +{/* need section on selecting an llm */} + +## LLM Management + +### Set the Current LLM + +The `model_name` setter method allows you to set the current LLM. + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Set the current LLM +pieces_client.model_name = "your_model_name" + +# Close the client +pieces_client.close() +``` + +### Get Availiable LLMs + +The `get_models()` method returns a list of available LLMs as a dictionary. + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient +from pieces_os_client import ClassificationSpecificEnum, FragmentMetadata + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Get all models and print their names +models = pieces_client.get_models() +for model_name, model_id in models.items(): + print(model_name) + +# Close the client +pieces_client.close() +``` + +### Copilot Class + +The `Copilot` class provides a way to manage copilot functionality with various properties and methods. + +#### Properties + +| Property Name | Property Description | +|--------------- |----------------------| +| **chat** | The chat object. | + +#### Methods + +##### Set the Current Chat + +The `chat` setter method allows you to set the current chat. + +:::info + +Changing the current chat will clear all context added to the chat. + +::: + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Get the chat ID +chat_id = "your_chat_id" + +# Set the current chat +pieces_client.copilot.chat = chat_id + +# Close the client +pieces_client.close() +``` + +## Chat Management + +### BasicChat Class + +The `BasicChat` class provides a way to manage chat with various properties and methods. + +#### Properties + +| Property Name | Property Description | +|--------------- |----------------------| +| **id** | The ID of the chat. | +| **conversation** | The [Conversation](/build/reference/python/models/conversation) object. Should **only** be used for properties not available in the `BasicChat` class. | +| **name** | The name of the chat. | +| **annotations** | The annotations of the chat. | + +#### Methods + +##### Get Chat Messages + +The `messages()` method returns a list of all messages in the chat. + +#### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Get the chat ID +chat_id = "your_chat_id" + +# Get all messages in the chat +messages = pieces_client.copilot.chat(chat_id).messages() +for message in messages: + print(message.text) + +# Close the client +pieces_client.close() +``` + +##### Set the Chat Name + +The `name` setter method allows you to set the chat name. + +###### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Get the chat ID +chat_id = "your_chat_id" + +# Set the chat name +pieces_client.copilot.chat(chat_id).name = "New Chat Name" + +# Close the client +pieces_client.close() +``` + +##### Delete a Chat + +The `delete()` method of allows you to delete a chat. + +###### Example + +```python +from pieces_os_client.wrapper import PiecesClient + +# Initialize the PiecesClient +pieces_client = PiecesClient() + +# Get the chat ID +chat_id = "your_chat_id" + +# Delete the chat +pieces_client.copilot.chat(chat_id).delete() + +# Close the client +pieces_client.close() +``` \ No newline at end of file diff --git a/docs/build/sdks/python/copilot/index.mdx b/docs/build/sdks/python/copilot/index.mdx deleted file mode 100644 index 337140987..000000000 --- a/docs/build/sdks/python/copilot/index.mdx +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Pieces OS Client Python SDK Copilot -description: Learn how to set up and use the Pieces OS Client Python SDK to communicate Pieces Copilot. ---- - -Use the following methods to communicate with Pieces Copilot using the Pieces OS Client Python SDK. - -## Copilot Management - -### Ask a Question to Pieces Copilot - -The `stream_question()` method of the `Copilot` class allows you to ask a question to Pieces Copilot and stream the response. - -#### Parameters - -| Param Name | Param Type | Param Notes | -|------------- |------------ |-------------| -| **question** | **string** | [required] | - -#### Example - -```python -from pieces_os_client.wrapper import PiecesClient - -# Initialize the PiecesClient -pieces_client = PiecesClient() - -# Set the question you want to ask -question = "What is Object-Oriented Programming?" - -# Ask the question and stream the response -for response in pieces_client.copilot.stream_question(question): - if response.question: - # Each answer is a chunk of the entire response to the question - answers = response.question.answers.iterable - for answer in answers: - print(answer.text,end="") - -# Close the client -pieces_client.close() -``` - -### Get Availiable LLMs - -The `get_models()` method returns a list of available LLMs as a dictionary. - -#### Example - -```python -from pieces_os_client.wrapper import PiecesClient -from pieces_os_client import ClassificationSpecificEnum, FragmentMetadata - -# Initialize the PiecesClient -pieces_client = PiecesClient() - -# Get all models and print their names -models = pieces_client.get_models() -for model_name, model_id in models.items(): - print(model_name) - -# Close the client -pieces_client.close() -``` - -### Copilot Class - -The `Copilot` class provides a way to manage copilot functionality with various properties and methods. - -#### Properties - -| Property Name | Property Description | -|--------------- |----------------------| -| **chat** | The chat object. | - -### BasicChat Class - -The `BasicChat` class provides a way to manage chat with various properties and methods. - -#### Properties - -| Property Name | Property Description | -|--------------- |----------------------| -| **conversation** | The conversation object. | -| **id** | The ID of the chat. | -| **name** | The name of the chat. | -| **annotations** | The annotations of the chat. | - -### Methods - -#### `delete()` - -The `delete()` method deletes the chat. - -#### Example - -```python -from pieces_os_client.wrapper import PiecesClient - -# Initialize the PiecesClient -pieces_client = PiecesClient() - -# Get the chat ID -chat_id = "your_chat_id" - -# Delete the chat -pieces_client.copilot.chat(chat_id).delete() - -# Close the client -pieces_client.close() -``` \ No newline at end of file diff --git a/docs/build/sdks/python/quickstart.mdx b/docs/build/sdks/python/quickstart.mdx index 363ede35d..14b263106 100644 --- a/docs/build/sdks/python/quickstart.mdx +++ b/docs/build/sdks/python/quickstart.mdx @@ -61,8 +61,10 @@ metadata = FragmentMetadata(ext=ClassificationSpecificEnum.PY) # optional metada # Create the new asset using the content and metadata new_asset_id = pieces_client.create_asset(content, metadata) - print(f"Created asset with ID: {new_asset_id}") + +# Close the client +pieces_client.close() ``` ### Get All Assets @@ -80,6 +82,8 @@ assets = pieces_client.assets() for asset in assets: logger.info(f"Asset Name: {asset.name}") +# Close the client +pieces_client.close() ``` ### Ask a Question to Pieces Copilot @@ -102,6 +106,9 @@ for response in pieces_client.copilot.stream_question(question): answers = response.question.answers.iterable for answer in answers: print(answer.text,end="") + +# Close the client +pieces_client.close() ``` ## Next Steps diff --git a/sidebars.ts b/sidebars.ts index 194f8d530..f41d88f89 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -699,7 +699,7 @@ const sidebars: SidebarsConfig = { }, { type: 'doc', - id: 'build/sdks/python/copilot/index', + id: 'build/sdks/python/copilot', label: 'Copilot', }, ], From 13d47342d6f17ab66d102ded30ea54692db82e97 Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 10:56:22 -0400 Subject: [PATCH 13/19] docs: Fix Conversation link capitalization --- docs/build/sdks/python/copilot.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build/sdks/python/copilot.mdx b/docs/build/sdks/python/copilot.mdx index 53f80f93d..bb2f46565 100644 --- a/docs/build/sdks/python/copilot.mdx +++ b/docs/build/sdks/python/copilot.mdx @@ -181,7 +181,7 @@ The `BasicChat` class provides a way to manage chat with various properties and | Property Name | Property Description | |--------------- |----------------------| | **id** | The ID of the chat. | -| **conversation** | The [Conversation](/build/reference/python/models/conversation) object. Should **only** be used for properties not available in the `BasicChat` class. | +| **conversation** | The [Conversation](/build/reference/python/models/Conversation) object. Should **only** be used for properties not available in the `BasicChat` class. | | **name** | The name of the chat. | | **annotations** | The annotations of the chat. | From a8f9649f5a59fd004a5c3ba1bb015a598675a522 Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 11:10:13 -0400 Subject: [PATCH 14/19] docs: Update Python SDK copilot usage example --- docs/build/sdks/python/copilot.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/build/sdks/python/copilot.mdx b/docs/build/sdks/python/copilot.mdx index bb2f46565..4937bc2d0 100644 --- a/docs/build/sdks/python/copilot.mdx +++ b/docs/build/sdks/python/copilot.mdx @@ -156,6 +156,7 @@ Changing the current chat will clear all context added to the chat. ```python from pieces_os_client.wrapper import PiecesClient +from pieces_os_client.wrapper.basic_identifier.chat import BasicChat # Initialize the PiecesClient pieces_client = PiecesClient() @@ -164,7 +165,7 @@ pieces_client = PiecesClient() chat_id = "your_chat_id" # Set the current chat -pieces_client.copilot.chat = chat_id +pieces_client.copilot.chat = BasicChat(chat_id) # Close the client pieces_client.close() From 5cea1c6f824c4da1b71b6281201075834a0cb110 Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 11:20:16 -0400 Subject: [PATCH 15/19] docs: Add return types to asset properties table --- docs/build/sdks/python/assets.mdx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/build/sdks/python/assets.mdx b/docs/build/sdks/python/assets.mdx index 17d235178..c3ba6184b 100644 --- a/docs/build/sdks/python/assets.mdx +++ b/docs/build/sdks/python/assets.mdx @@ -107,16 +107,16 @@ The `BasicAsset` class provides a way to manage assets with various properties a ### Properties -| Property Name | Property Description | -|--------------- |----------------------| -| **id** | The ID of the asset. | -| **asset** | The full [Asset](/build/reference/python/models/Asset) object. Should **only** be used for properties not available in the `BasicAsset` class. | -| **raw_content** | The content of the asset. | -| **is_image** | Boolean indicating if the asset is an image. | -| **classification** | The specific classification of the asset (e.g., `py`). | -| **name** | The name of the asset. | -| **description** | The description of the asset. | -| **annotations** | The annotations of the asset. | +| Property Name | Property Description | Return Type | +|--------------- |---------------------- |------------| +| **id** | The ID of the asset. | **string** | +| **asset** | Should **only** be used for properties not available in the `BasicAsset` class. | [**Asset**](/build/reference/python/models/Asset) | +| **raw_content** | The content of the asset. | **string** | +| **is_image** | Boolean indicating if the asset is an image. | **bool** | +| **classification** | The specific classification of the asset (e.g., `py`). | [**ClassificationSpecificEnum**](/build/reference/python/models/ClassificationSpecificEnum) | +| **name** | The name of the asset. | **string** | +| **description** | The description of the asset. | **string** | +| **annotations** | The annotations of the asset. | [**Annotations**](/build/reference/python/models/Annotations) | ### Methods From 028ea33f96ed1ff8a8294ce7c2697cb1e0868acb Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 11:24:06 -0400 Subject: [PATCH 16/19] docs: standardize table headers in Python SDK docs --- docs/build/sdks/python/assets.mdx | 26 +++++++++++++------------- docs/build/sdks/python/copilot.mdx | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/build/sdks/python/assets.mdx b/docs/build/sdks/python/assets.mdx index c3ba6184b..85783af64 100644 --- a/docs/build/sdks/python/assets.mdx +++ b/docs/build/sdks/python/assets.mdx @@ -54,7 +54,7 @@ asset(asset_id) #### Parameters -| Param Name | Param Type | Param Notes | +| Name | Type | Notes | |------------- |------------ |-------------| | **asset_id** | **string** | [required] | @@ -107,16 +107,16 @@ The `BasicAsset` class provides a way to manage assets with various properties a ### Properties -| Property Name | Property Description | Return Type | -|--------------- |---------------------- |------------| -| **id** | The ID of the asset. | **string** | -| **asset** | Should **only** be used for properties not available in the `BasicAsset` class. | [**Asset**](/build/reference/python/models/Asset) | -| **raw_content** | The content of the asset. | **string** | -| **is_image** | Boolean indicating if the asset is an image. | **bool** | -| **classification** | The specific classification of the asset (e.g., `py`). | [**ClassificationSpecificEnum**](/build/reference/python/models/ClassificationSpecificEnum) | -| **name** | The name of the asset. | **string** | -| **description** | The description of the asset. | **string** | -| **annotations** | The annotations of the asset. | [**Annotations**](/build/reference/python/models/Annotations) | +| Name | Type | Notes | +|--------------- |------------ |----------------------| +| **id** | **string** | The ID of the asset. | +| **asset** | [**Asset**](/build/reference/python/models/Asset) | Should **only** be used for properties not available in the `BasicAsset` class. | +| **raw_content** | **string** | The content of the asset. | +| **is_image** | **bool** | Boolean indicating if the asset is an image. | +| **classification** | [**ClassificationSpecificEnum**](/build/reference/python/models/ClassificationSpecificEnum) | The specific language classification of the asset. To get the string value, you must use `asset.classification.value` | +| **name** | **string** | The name of the asset. | +| **description** | **string** | The description of the asset. | +| **annotations** | [**Annotations**](/build/reference/python/models/Annotations) | The annotations of the asset. | ### Methods @@ -126,14 +126,14 @@ Creates a new asset. ##### Parameters -| Param Name | Param Type | Param Description | +| Name | Type | Notes | |------------ |------------|------------------| | **raw_content** | **string** | The raw content of the asset. | | **metadata** | **Optional[FragmentMetadata]** | The metadata of the asset. | ##### Returns -| Return Type | Return Description | +| Type | Notes | |------------- |-------------------| | **string** | The ID of the created asset. | diff --git a/docs/build/sdks/python/copilot.mdx b/docs/build/sdks/python/copilot.mdx index 4937bc2d0..d12ce8ebe 100644 --- a/docs/build/sdks/python/copilot.mdx +++ b/docs/build/sdks/python/copilot.mdx @@ -13,7 +13,7 @@ The `stream_question()` requires a question as a parameter and will stream the r #### Parameters -| Param Name | Param Type | Param Notes | +| Name | Type | Notes | |------------- |------------ |-------------| | **question** | **string** | [required] | @@ -136,7 +136,7 @@ The `Copilot` class provides a way to manage copilot functionality with various #### Properties -| Property Name | Property Description | +| Name | Notes | |--------------- |----------------------| | **chat** | The chat object. | @@ -179,7 +179,7 @@ The `BasicChat` class provides a way to manage chat with various properties and #### Properties -| Property Name | Property Description | +| Name | Notes | |--------------- |----------------------| | **id** | The ID of the chat. | | **conversation** | The [Conversation](/build/reference/python/models/Conversation) object. Should **only** be used for properties not available in the `BasicChat` class. | From 3f69c3efd40a6701732f9529c7efbbbf49f1977b Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 11:24:16 -0400 Subject: [PATCH 17/19] docs: Update parameter table in Python SDK docs --- docs/build/sdks/python/assets.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build/sdks/python/assets.mdx b/docs/build/sdks/python/assets.mdx index 85783af64..d0a7c3460 100644 --- a/docs/build/sdks/python/assets.mdx +++ b/docs/build/sdks/python/assets.mdx @@ -17,7 +17,7 @@ create_asset(content, metadata) #### Parameters -| Param Name | Param Type | Param Notes | +| Name | Type | Notes | |------------- |------------ |-------------| | **content** | **string** | [required] | | **metadata** | **FragmentMetadata** | [optional] | From 5a38a88df3b1b8b711ec87e1a8ae6b6aafd763cd Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 11:30:55 -0400 Subject: [PATCH 18/19] docs: Update Pieces Client host URL setup guide --- docs/build/sdks/python/quickstart.mdx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/build/sdks/python/quickstart.mdx b/docs/build/sdks/python/quickstart.mdx index 14b263106..61424fde5 100644 --- a/docs/build/sdks/python/quickstart.mdx +++ b/docs/build/sdks/python/quickstart.mdx @@ -30,15 +30,18 @@ from pieces_os_client.wrapper import PiecesClient pieces_client = PiecesClient() ``` -### Determining Your Base URL +### Custom Host URL -In the code snippet above, we use the `platform` package to determine the base URL based on the operating system. However, you can also set the base URL manually if you know your application will only run on a specific operating system. +When we initialize the Pieces Client, it defaults to `http://localhost:1000` for macOS/Windows and `http://localhost:5323` for Linux. If you have a remote instance of Pieces OS running, you can specify the host URL when initializing the Pieces Client: -- **Local Instance of Pieces OS:** - - On macOS/Windows, use `http://localhost:1000` - - On Linux, use `http://localhost:5323` -- **Remote Instance of Pieces OS:** - - Use the URL you have set up for your remote instance +```python +from pieces_os_client.wrapper import PiecesClient + +# Specify the host URL +host_url = "http://your-host-url:your-port" + +pieces_client = PiecesClient(host=host_url) +``` ## Examples From 1ba91a7a8241f6f9ea82fd4be4ad425dc9cf0236 Mon Sep 17 00:00:00 2001 From: Mason Williams Date: Sat, 24 Aug 2024 11:32:20 -0400 Subject: [PATCH 19/19] docs: Add client closing instructions to Python SDK --- docs/build/sdks/python/quickstart.mdx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/build/sdks/python/quickstart.mdx b/docs/build/sdks/python/quickstart.mdx index 61424fde5..40e3160ce 100644 --- a/docs/build/sdks/python/quickstart.mdx +++ b/docs/build/sdks/python/quickstart.mdx @@ -43,6 +43,14 @@ host_url = "http://your-host-url:your-port" pieces_client = PiecesClient(host=host_url) ``` +### Closing the Client + +After you have finished using the Pieces Client, you should always close the client to free up resources: + +```python +pieces_client.close() +``` + ## Examples Here are some examples of how you can use to get familiar with the Pieces OS Client SDK.