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: {