Skip to content

Commit 8cd5690

Browse files
committed
Update DEVELOPMENT.md
1 parent 3a2fe5d commit 8cd5690

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

DEVELOPMENT.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ Most of the logics are implemented inside the package `Core`.
2727

2828
## Building and Archiving the App
2929

30-
This project includes a Git submodule, `copilot.vim`, so you will need to either initialize the submodule or download it from the [copilot.vim](https://github.com/github/copilot.vim) repository.
31-
32-
Finally, archive the Copilot for Xcode target.
30+
1. Run `make setup` to setup the project. (You may need to install the specific version of python to install the dependencies, please check `Python/site-packages/install.sh` for details.)
31+
2. Build or archive the Copilot for Xcode target.
3332

3433
## Testing Extension
3534

@@ -45,6 +44,24 @@ For new tests, they should be added to the `TestPlan.xctestplan`.
4544

4645
To create a chat plugin, please use the `TerminalChatPlugin` as an example. You should add your plugin to the target `ChatPlugin` and register it in `ChatService`.
4746

47+
## LangChain and Python
48+
49+
The app uses PythonKit to execute Python code.
50+
51+
When running Python code, ensure that you wrap it inside `runPython`. This will automatically insert `GilStateEnsure` and `GilStateRelease` for you.
52+
53+
```swift
54+
import PythonHelper
55+
56+
try runPython {
57+
// access python here
58+
}
59+
```
60+
61+
Instead of throwing a `PythonError`, `runPython` will throw a `ReadablePythonError`.
62+
63+
If importing a Python module causes the app to crash, it is usually due to the thread's stack size being too small. To resolve this, try importing with `Python.attemptImportOnPythonThread`, which is defined in `PythonHelper`, or simply import from the main thread.
64+
4865
## Code Style
4966

5067
We use SwiftFormat to format the code.

0 commit comments

Comments
 (0)