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

xassist implementation #151

Merged
merged 1 commit into from
Sep 12, 2024
Merged

Conversation

tharun571
Copy link
Contributor

@tharun571 tharun571 commented Jun 20, 2024

Description

  • Introduced the "xassist" magic command to interact with large language models (LLMs) such as OpenAI and Gemini.
  • Integrated the curl library to facilitate HTTP requests to the LLM APIs.
  • Implemented functionality to save and load API keys for different models.
  • Added support for maintaining context and chat history within the "xassist" command.
  • Included necessary documentation to guide users on how to use the new features.
  • Added tests to ensure the functionality works as expected and to help users verify their setup.

Type of change

Please tick all options which are relevant.

  • Bug fix
  • New feature
  • Added/removed dependencies
  • Required documentation updates

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 15. Check the log or trigger a new build to see more.

src/xmagics/xassist.cpp Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2024

Codecov Report

Attention: Patch coverage is 80.74074% with 26 lines in your changes missing coverage. Please review.

Project coverage is 81.97%. Comparing base (7d20476) to head (4486eea).

Files with missing lines Patch % Lines
src/xmagics/xassist.cpp 80.45% 26 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
- Coverage   82.24%   81.97%   -0.27%     
==========================================
  Files          17       19       +2     
  Lines         625      760     +135     
  Branches       61       79      +18     
==========================================
+ Hits          514      623     +109     
- Misses        111      137      +26     
Files with missing lines Coverage Δ
src/xinterpreter.cpp 88.75% <100.00%> (+0.07%) ⬆️
src/xmagics/xassist.hpp 100.00% <100.00%> (ø)
src/xmagics/xassist.cpp 80.45% <80.45%> (ø)
Files with missing lines Coverage Δ
src/xinterpreter.cpp 88.75% <100.00%> (+0.07%) ⬆️
src/xmagics/xassist.hpp 100.00% <100.00%> (ø)
src/xmagics/xassist.cpp 80.45% <80.45%> (ø)

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.hpp Outdated Show resolved Hide resolved
src/xmagics/xassist.hpp Outdated Show resolved Hide resolved
src/xmagics/xassist.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/xmagics/xassist.hpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
@SylvainCorlay
Copy link
Collaborator

I think this shows we need an extension system for magics, so that we don't keep to much in core xeus-cpp and have such features in extensions.

@vgvassilev
Copy link
Contributor

Perhaps we need to implement #4. @tharun571, can you take a look?

I guess here the question is should we accept the PR and move it as a plugin or wait for the plugin system?

@tharun571 tharun571 force-pushed the xassist branch 2 times, most recently from d8fe129 to 58a77ab Compare August 7, 2024 17:59
@JohanMabille
Copy link
Collaborator

JohanMabille commented Sep 5, 2024

I think we can accept the PR and move it to the plugin system when we have it, because the implementation does not spread across the whole kernel. My only concern is the dependency on curl, but we can probably hide it behind a building flag if we package a new version of xeus-cpp before the plugin system is available.

Nitpicking: the naming convention of xeus-cpp is snake case, not camel case, but this can be changed later (as a mechanical change that would be fast to review).

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/xinterpreter.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Show resolved Hide resolved
src/xmagics/xassist.cpp Show resolved Hide resolved
src/xmagics/xassist.cpp Show resolved Hide resolved
src/xmagics/xassist.cpp Show resolved Hide resolved
src/xmagics/xassist.cpp Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
@tharun571 tharun571 force-pushed the xassist branch 4 times, most recently from b96a118 to b24d04a Compare September 9, 2024 16:12
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
src/xmagics/xassist.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the failures are actually regression in the master (see #155)

@vgvassilev vgvassilev merged commit 02a8ca3 into compiler-research:main Sep 12, 2024
8 of 10 checks passed
@anutosh491
Copy link
Collaborator

I guess this would involve having a wasm build for curl (to support the esmcripten CI) ?
I'm giving this an attempt today. Let me try to host a recipe for the same on emscripten-forge if we can get it to work that way.

@anutosh491
Copy link
Collaborator

anutosh491 commented Sep 24, 2024

Raised a recipe here (emscripten-forge/recipes#1332)

I guess having libcurl-static would suffice. We just need the curl.h file is it ?

let me know what all files out of the curl library are required here.

@tharun571
Copy link
Contributor Author

tharun571 commented Sep 24, 2024

I guess having libcurl-static would suffice. We just need the curl.h file is it ?

Yes curl.h would help.

@anutosh491
Copy link
Collaborator

anutosh491 commented Sep 24, 2024

I've added the recipe. Just needs to be reviewed by the folks there but in the meantime, any reviews from here (just confirming if I generate everything required or not would be great).

Currently I generate

 │ │ Files in package:
 │ │   - bin/curl
 │ │   - bin/curl-config
 │ │   - include/curl/curl.h
 │ │   - include/curl/curlver.h
 │ │   - include/curl/easy.h
 │ │   - include/curl/header.h
 │ │   - include/curl/mprintf.h
 │ │   - include/curl/multi.h
 │ │   - include/curl/options.h
 │ │   - include/curl/stdcheaders.h
 │ │   - include/curl/system.h
 │ │   - include/curl/typecheck-gcc.h
 │ │   - include/curl/urlapi.h
 │ │   - include/curl/websockets.h
 │ │   - lib/libcurl.a
 │ │   - lib/pkgconfig/libcurl.pc
 │ │   - info/about.json
 │ │   - info/hash_input.json
 │ │   - info/index.json
 │ │   - info/licenses/COPYING
 │ │   - info/paths.json
 │ │   - info/recipe/build.sh
 │ │   - info/recipe/recipe.yaml
 │ │   - info/recipe/rendered_recipe.yaml
 │ │   - info/recipe/variant_config.yaml
 │ │   - info/tests/tests.yaml

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

Successfully merging this pull request may close these issues.

6 participants