Skip to content

Commit 54e0fa5

Browse files
authored
Update blog
1 parent b5e4d29 commit 54e0fa5

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

_posts/2024-10-17-integrate-a-large-language-model-with-the-xeus-cpp-jupyter-kernel_final_blogpost.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,73 @@ I am Tharun A, this summer I contributed to Xeus-cpp, started by the wonderful d
1515

1616
**Mentors**: Anutosh Bhat, Johan Mabille, Aaron Jomy, David Lange, Vassil Vassilev
1717

18+
---
19+
1820
### Project Overview
1921

2022
Xeus-cpp is a Jupyter kernel for C++ built on the native Jupyter protocol, enabling interactive coding with REPL functionality for quick prototyping without separate compilation. This project aims to integrate a large language model with the xeus-cpp kernel, allowing users to generate and execute C++ code interactively with AI-powered assistance.
2123

24+
---
25+
2226
### Implementation
2327

2428
![Codeflow](./images/blog/codeflow.png)
2529

2630
I created a magic function called XAssist that connects to a specific LLM based on the user's preference. It utilizes utility functions and the cURL library to connect with the LLM and retrieve the respective response. The user saves the API keys for OpenAI and Gemini, sets the URL for Ollama, saves a particular model, and then uses the LLM.
2731

32+
#### Coding Phase 1
33+
34+
1. **Establishing Test Coverage**
35+
- Focused on creating test coverage, which was instrumental in understanding the codebase.
36+
- Tracked every function to comprehend its purpose and behavior, enhancing familiarity with the project.
37+
38+
2. **Setting Up a Testing Framework**
39+
- Developed a testing framework to ensure that the Jupyter notebooks functioned as intended.
40+
- This allowed for early identification of issues and ensured smooth functionality.
41+
42+
3. **Understanding the Functionality of XMagics**
43+
- Gained insights into the functionality of `xmagics`, which was critical for my project.
44+
- This understanding laid the groundwork for further development and integration.
45+
46+
4. **Research on OpenLLM**
47+
- Conducted research on OpenLLM to evaluate its potential application in the project.
48+
- Determined that OpenLLM was not suitable, leading to the decision to build a custom framework.
49+
50+
5. **Building a Custom Framework for LLM Integration**
51+
- Developed a framework to connect with various LLMs using C++ and the **cURL library**.
52+
- Key functionalities included:
53+
- **Support for OpenAI and Gemini**: Integrated support for these specific LLMs, expanding the framework’s capabilities.
54+
- **API Key Management**: Saved API keys in text files to maintain security and accessibility.
55+
- **Customized JSON Calls**: Created tailored JSON requests for each model, ensuring proper integration.
56+
57+
#### Coding Phase 2
58+
59+
1. **Fixing Issues with the Initial PR**
60+
- Focused on addressing feedback from the initial pull request (PR) to improve code quality.
61+
- Made necessary adjustments to meet project standards and enhance functionality.
62+
63+
2. **Debugging Windows-Specific Issues**
64+
- Encountered challenges with importing the **cURL library** on Windows systems.
65+
- Investigated and resolved compatibility issues to ensure the framework worked across different platforms.
66+
67+
3. **Adding Context (Chat History) to LLM Calls**
68+
- Enhanced user experience by implementing the ability to include conversation context in LLM calls.
69+
- Allowed users to engage in seamless and continuous conversations with the LLM, improving interactivity.
70+
71+
4. **Providing Flexibility in Model Selection**
72+
- Introduced the option for users to select from multiple LLM models based on their preferences.
73+
- This flexibility empowered users to tailor their interactions with the LLMs to better meet their needs.
74+
75+
5. **Integrating Support for Ollama (Open Source Model)**
76+
- Added support for **Ollama**, enabling users to utilize their private models within the `xeus` kernel.
77+
- This feature expanded the project’s utility, allowing for greater customization and flexibility.
78+
79+
6. **Improving Documentation**
80+
- Updated and enhanced project documentation to make it more comprehensive and user-friendly.
81+
- Focused on providing clear instructions for setup, usage, and functionality, benefiting future contributors and users.
82+
83+
---
84+
2885
### Contributions
2986

3087
| PR | Description |
@@ -37,23 +94,35 @@ I created a magic function called XAssist that connects to a specific LLM based
3794
| [#160](https://github.com/compiler-research/xeus-cpp/pull/160) | XAssist Implementation - Update tests |
3895
| [#161](https://github.com/compiler-research/xeus-cpp/pull/161) | XAssist Implementation - Handle prompts with special cases |
3996

40-
During Coding Phase 1, the focus was on establishing test coverage, setting up a testing framework, understanding XMagics, conducting research on OpenLLM, using the cURL library in C++, saving API keys in text files, and creating customized JSON calls for each model. In Coding Phase 2, efforts were directed toward fixing issues with the initial PR, debugging Windows-specific issues, adding context (chat history) to LLM calls, giving users more flexibility in selecting models, supporting Ollama, and improving documentation.
97+
---
4198

4299
### Result
43100

44101
Here is an example that demonstrates how one can use XAssist.
45102

46103
![Gemini](./images/blog/gemini.png)
47104

105+
---
106+
48107
### Future Work
49108

50109
Potential enhancements to XAssist that could significantly increase its usefulness include enabling the LLM to output code directly into subsequent cells, allowing the entire notebook to be analyzed for potential errors, and refining the output format to improve readability and presentation. This has been opened as an issue at [#162](https://github.com/compiler-research/xeus-cpp/issues/162).
51110

111+
---
112+
52113
### Conclusion
53114

54115
This project will help developers seamlessly integrate OpenAI, Gemini, and Ollama into their workflows, enabling smoother adoption of advanced language models and making development tasks easier and more efficient. By automating complex interactions and streamlining API usage, XAssist aims to reduce manual effort, improve productivity, and enhance the developer experience across various domains.
55116

56-
From day one, the learning experience has been incredibly rewarding. I would like to express my gratitude to my mentors—Anutosh Bhat, Johan Mabille, Aaron Jomy, David Lange, and Vassil Vassilev—for their outstanding support, as well as to my peers and fellow contributors from the compiler research organization for their invaluable assistance and collaboration. These past few months have been transformative for my professional growth, allowing me to sharpen my technical skills, and strengthen my problem-solving abilities. Moving forward, I plan to continue contributing to xeus-cpp and other projects within the organization, expand my involvement in open-source initiatives, and explore new areas where I can make meaningful contributions to the community.
117+
---
118+
119+
### Acknowledgements
120+
121+
From day one, the learning experience has been immensely rewarding. I would first like to express my gratitude to Vassil for his patience in addressing my doubts and guiding me through every stage of the process. I am also grateful to Johan for his valuable insights and code reviews, and to Anutosh for helping me understand the broader context. A special thanks to Matthew for always providing thoughtful feedback whenever I sought it. I would also like to acknowledge my peers and fellow contributors from the compiler research organization for their invaluable support and collaboration.
122+
123+
These past few months have been transformative for my professional growth, helping me refine my technical skills and enhance my problem-solving abilities. Looking ahead, I plan to continue contributing to xeus-cpp and other projects within the organization, deepen my engagement with open-source initiatives, and explore new areas where I can make meaningful contributions to the community.
124+
125+
---
57126

58127
### Related Links
59128

0 commit comments

Comments
 (0)