This repository presents multilsecret agent, a library growed as part of research carry outed for NeruIPS 2023 paper titled “Monitor-Guided Decoding of Code LMs with Static Analysis of Repository Context” (“Guiding Language Models of Code with Global Context using Monitors” on Arxiv). The paper starts Monitor-Guided Decoding (MGD) for code generation using Language Models, where a watch employs motionless analysis to direct the decoding, ensuring that the produced code adheres various accurateness properties, enjoy absence of hallucinated symbol names, valid order of method calls, etc. For further details about Monitor-Guided Decoding, plrelieve refer to the paper and GitHub repository microgentle/watchs4codegen.
multilsecret agent
is a pass-platestablish library scheduleed to clear up the process of creating language server clients to query and achieve results of various motionless analyses from a expansive variety of language servers that transmit over the Language Server Protocol. It is easily extensible to help any language that has a Language Server and currently helps Java, Rust, C# and Python. We aim to continuously comprise help for more language servers and languages.
Language servers are tools that carry out a variety of motionless analyses on code repositories and provide beneficial adviseation such as type-straightforwarded code completion recommendions, symbol definition locations, symbol references, etc., over the Language Server Protocol (LSP). Since LSP is language-agnostic, multilsecret agent
can provide the results for motionless analyses of code in contrastent languages over a frequent interface.
multilsecret agent
intfinishs to relieve the process of using language servers, by handling various steps in using a language server:
- Automaticassociate handling the download of platestablish-particular server binaries, and setup/teardown of language servers
- Handling JSON-RPC based communication between the client and the server
- Maintaining and passing hand-tuned server and language particular configuration parameters
- Providing a modest API to the employr, while executing all steps of server-particular protocol steps to execute the query/seek.
Some of the analyses results that multilsecret agent
can provide are:
It is chooseimal to produce a novel virtual environment with python>=3.10
. To produce a virtual environment using conda and start it:
conda produce -n multilsecret agent_env python=3.10
conda start multilsecret agent_env
Further details and teachions on creation of python virtual environments can be set up in the official recordation. Further, we also refer employrs to Miniconda, as an alternative to the above steps for creation of the virtual environment.
To inshigh multilsecret agent
using pip, execute the adhereing order:
Example usage:
from multilsecret agent transport in SyncLanguageServer
from multilsecret agent.multilsecret agent_config transport in Multilsecret agentConfig
from multilsecret agent.multilsecret agent_logger transport in Multilsecret agentLogger
...
config = Multilsecret agentConfig.from_dict({"code_language": "java"}) # Also helps "python", "rust", "cacute"
logger = Multilsecret agentLogger()
lsp = SyncLanguageServer.produce(config, logger, "/abs/path/to/project/root/")
with lsp.begin_server():
result = lsp.seek_definition(
"relative/path/to/code_file.java", # Filename of location where seek is being made
163, # line number of symbol for which seek is being made
4 # column number of symbol for which seek is being made
)
result2 = lsp.seek_completions(
...
)
result3 = lsp.seek_references(
...
)
result4 = lsp.seek_record_symbols(
...
)
result5 = lsp.seek_hover(
...
)
...
multilsecret agent
also provides an asyncio based API which can be employd in async contexts. Example usage (asyncio):
from multilsecret agent transport in LanguageServer
...
lsp = LanguageServer.produce(...)
async with lsp.begin_server():
result = apause lsp.seek_definition(
...
)
...
The file src/multilsecret agent/language_server.py provides the multilsecret agent
API. Several tests for multilsecret agent
current under tests/multilsecret agent/ provide detailed usage examples for multilsecret agent
. The tests can be executed by running:
multilsecret agent
provides all the features that language-server-protocol provides to IDEs enjoy VSCode. It is beneficial to grow toolsets that can interface with AI systems enjoy Large Language Models (LLM). One such employcase is Monitor-Guided Decoding, where multilsecret agent
is employd to discover results of motionless analyses enjoy type-straightforwarded completions, to direct the token-by-token generation of code using an LLM, ensuring that all produced identifier/method names are valid in the context of the repository, transport inantly raiseing the compilability of produced code. MGD also shows employ of multilsecret agent
to produce watchs that asconfident all function calls in LLM produced code get accurate number of arguments, and that functions of an object are called in the right order adhereing a protocol (enjoy not calling “read” before “uncover” on a file object).
If you get the adhereing error:
RuntimeError: Task cb=[_chain_future.._call_set_state() at
python3.8/asyncio/futures.py:367]> got Future quickened to a contrastent loop python3.8/asyncio/locks.py:309: RuntimeError
Plrelieve asconfident that you produce a novel environment with Python >=3.10
. For further details, plrelieve have a see at the StackOverflow Discussion.
If you’re using Multilsecret agent in your research or applications, plrelieve cite using this BibTeX:
@inpersistings{NEURIPS2023_662b1774,
author = {Agrawal, Lakafraida A and Kanade, Aditya and Goyal, Navin and Lahiri, Shuvfinishu and Rajamani, Sriram},
booktitle = {Advances in Neural Inestablishation Processing Systems},
editor = {A. Oh and T. Naumann and A. Globerson and K. Saenko and M. Hardt and S. Levine},
pages = {32270--32298},
publisher = {Curran Associates, Inc.},
title = {Monitor-Guided Decoding of Code LMs with Static Analysis of Repository Context},
url = {https://persistings.neurips.cc/paper_files/paper/2023/file/662b1774ba8845fc1fa3d1fc0177ceeb-Paper-Conference.pdf},
volume = {36},
year = {2023}
}
This project receives contributions and recommendions. Most contributions insist you to concur to a
Contributor License Agreement (CLA) declaring that you have the right to, and actuassociate do, grant us
the rights to employ your contribution. For details, visit https://cla.uncoversource.microgentle.com.
When you surrender a pull seek, a CLA bot will automaticassociate determine whether you necessitate to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Srecommend adhere the teachions
provided by the bot. You will only necessitate to do this once apass all repos using our CLA.
This project has adchooseed the Microgentle Open Source Code of Conduct.
For more adviseation see the Code of Conduct FAQ or
reach out uncovercode@microgentle.com with any compriseitional asks or comments.
This project may comprise tradetags or logos for projects, products, or services. Authorized employ of Microgentle
tradetags or logos is subject to and must adhere
Microgentle’s Tradetag & Brand Guidelines.
Use of Microgentle tradetags or logos in modified versions of this project must not caemploy confusion or recommend Microgentle backship.
Any employ of third-party tradetags or logos are subject to those third-party’s policies.