Swiftide 0.7 - Code reference and definition extraction, experimental query pipeline, Groq support, and more

Published: at by Timon Vonk

Introducing Swiftide 0.7! This release introduces the first version of our experimental query pipeline and restructures the project. This paves the way for using Swiftide as a Rust based alternative for LangChain and LlamaIndex. We want Swiftide to bring your LLM applications from experiment straight to production.

There are still quite a few features missing compared to the alternative solutions and we are working hard to ship more of them. We can only do so much, and if you’re looking for an early stage, cool project to contribute to, take a look at our github issues.

To get started with Swiftide, head over to swiftide.rs or check us out on github.

Experimental Query Pipeline

With the new query pipeline you can query your indexed data, transform both query and the response, and answer the initial query. The same as indexing, it uses a lazy, streaming and parallel pipeline underneath, bringing performance, type safety and a straightforward model to the table. Additionally it uses a strategy pattern that will enable composition of different search strategies in the future.

The feature is in flux and still under heavy development. We have built an API similar to that of Indexing, where instead it is a user query that is transformed, data is retrieved and that retrieval can be used to generate an answer. Here is an example:

let pipeline = query::Pipeline::default()
.then_transform_query(query_transformers::GenerateSubquestions::from_client(
openai_client.clone(),
))
.then_transform_query(query_transformers::Embed::from_client(
openai_client.clone(),
))
.then_retrieve(qdrant.clone())
.then_transform_response(response_transformers::Summary::from_client(
openai_client.clone(),
))
.then_answer(answers::Simple::from_client(openai_client.clone()));
let result = pipeline
.query("What is swiftide?")
.await?;

We are still updating and improving documentation over at swiftide.rs. If you want to take a deep dive, we have an example on github and documentation available on docs.rs

Reference and definition extraction with tree-sitter

We added a transformer that extracts references and definitions from code and adds it as metadata. Both useful as a pre and post chunking step, and has some interesting possibilities when doing graph RAG (which we do not have yet :-)). It uses tree-sitter under the hood and is implemented for all languages that are currently supported.

An example:

let transformer = MetadataRefsDefsCode::try_from_language("rust").unwrap();
let code = r#"
fn main() {
println!("Hello, World!");
}
"#;
let mut node = Node::new(code.to_string());
transformer.transform_node(node);
transformer.metadata.get("Refererences (code)").unwrap()
// "println!"
transformer.metadata.get("Definitions (code)").unwrap()
// "main"

There are some interesting potential future improvements like trying to extract a fully qualified path.

Groq support

Groq is now supported for transformers that use SimplePrompt. The performance is incredible compared to other LLMs and it is hard to ignore.

Bring your own Tera

The template repository can now be extended with your own Tera instance. This allows you to add your own files, functions and partials.

Project restructure and improvements

breaking change Import paths have slightly changed, with indexing and query as the main entry points.

We have restructured the project into multiple crates. This speeds up compilation time and allows development of features like the query pipeline in relative isolation.

Additionally, Metadata on indexing node is now a first class citizen with serde_json::Value as its values. This enables cool things in the future like using metadata programmatically without having to parse it, and keeps the implementation details internal.

What’s next?

Hybrid search with sparse vectors is high on the list, we are also working on a symbol outline with tree-sitter for additional metadata. Other than that; expanding on the query pipeline has our primary focus.

Call for contributors

There is a large list of desired features, and many more unlisted over at our issues page; ranging from great starter issues, to fun, complex challenges.


You can find the full changelog here.

To get started with Swiftide, head over to swiftide.rs or check us out on github.