Skip to content

Enabled file magic support for xeus-cpp-lite #261

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

Merged
merged 4 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ set(XEUS_CPP_SRC
src/xoptions.cpp
src/xparser.cpp
src/xutils.cpp
src/xmagics/os.cpp
)

if(NOT EMSCRIPTEN)
list(APPEND XEUS_CPP_SRC
src/xmagics/xassist.cpp
src/xmagics/os.cpp
)
endif()

Expand Down
Binary file added docs/source/file_magic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion docs/source/magics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Here are the magics available in xeus-cpp.
%%xassist
========================

Leverage the large language models to assist in your development process. Currently supported models are Gemini, OpenAI, Ollama.
Leverage the large language models to assist in your development process. Currently supported models are Gemini, OpenAI, Ollama. This magic command is supported in only xeus-cpp.

- Save the api key (for OpenAI and Gemini)

Expand Down Expand Up @@ -54,3 +54,23 @@ Leverage the large language models to assist in your development process. Curren
.. image:: gemini.png

.. image:: ollama.png


%%file
========================

This magic command copies the content of the cell in a file named `filename`. This magic command is supported in both xeus-cpp and xeus-cpp-lite.

.. code::

%%file [-a] filename

- Example

.. image:: file_magic.png

- Optional argument:

+------------+---------------------------------+
| -a | append the content to the file. |
+------------+---------------------------------+
4 changes: 2 additions & 2 deletions src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "xinput.hpp"
#include "xinspect.hpp"
#ifndef EMSCRIPTEN
#include "xmagics/os.hpp"
#ifndef EMSCRIPTEN
#include "xmagics/xassist.hpp"
#endif
#include "xparser.hpp"
Expand Down Expand Up @@ -372,9 +372,9 @@ __get_cxx_version ()
// preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("timeit",
// timeit(&m_interpreter));
// preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("python", pythonexec());
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("file", writefile());
#ifndef EMSCRIPTEN
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("xassist", xassist());
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("file", writefile());
#endif
}
}
Loading