Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs in Python SDK build section on how to add context to a Pieces Copilot chat #564

Open
shivaypiece opened this issue Sep 2, 2024 · 2 comments

Comments

@shivaypiece
Copy link
Contributor

Include code example on how to add context to your Pieces Copilot conversation

@Ayush9026
Copy link

@shivay-at-pieces bhaiya i will solve this.

@shivaypiece
Copy link
Contributor Author

shivaypiece commented Sep 3, 2024

so here is how to add a context to the Copilot.
You can add 4 things as a context:
A file/folder path
A snippet
A raw snippet
A message
And all work the same way you append the context.(context type) list
Note: the conversation association is not implemented yet in the sdks (means it won't be synced across the other plugins) eg: you added a path and asked a question in a conversation in your code the desktop app won't know what context you added:

from pieces_os_client.wrapper import PiecesClient
copilot = PiecesClient().copilot
copilot.context.paths.append("STRING TO PATH") # adding a path
copilot.context.raw_assets.append("from pieces_os_client.wrapper import PiecesClient") # adding raw snippet
copilot.context.assets.append(BasicAsset("Asset ID")) # Adding an asset
copilot.context.messages.append(BasicMessage("Message ID")) # Adding a message
copilot.ask_stream("Question releated to the context")

Note: if the path is not valid or the raw_assets is not a string typed or the asset/ message is not a Basic typed it will release an error when asking the question
Also there is a bug which I fixed in that PR gonna be merged today and a release will be tagged where every time you do PiecesClient().copilot it will create a new instance instead of using the old instance which the copilot will be rested and all the context set will be removed so you should store the PiecesClient().copilot in a variable and use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants