im just getting ``Welcome to the Codebase Query Interface!
Type 'exit' to exit the program.


--- Result 1 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/test/java/com/kapture/ticketconfigurationmicroservice/TicketConfigurationMicroserviceApplicationTests.java
Type: function
Code Snippet:
@Test
	void contextLoads() {
	}

--- Result 2 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/test/java/com/kapture/ticketconfigurationmicroservice/TicketConfigurationMicroserviceApplicationTests.java
Type: class
Code Snippet:
@SpringBootTest
class TicketConfigurationMicroserviceApplicationTests {

	@Test
	void contextLoads() {
	}

}

--- Result 3 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/main/java/com/kapture/ticketconfigurationmicroservice/ticket/service/WebHookDataPrivilege.java
Type: function
Code Snippet:
public String getCategory() {
        return category;
    }

--- Result 4 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/main/java/com/kapture/ticketconfigurationmicroservice/ticket/service/WebHookDataPrivilege.java
Type: function
Code Snippet:
public String getKey() {
        return key;
    }

--- Result 5 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/main/java/com/kapture/ticketconfigurationmicroservice/ticket/service/WebHookDataPrivilege.java
Type: function
Code Snippet:
public String getName() {
        return name;
    }

--- Result 1 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/test/java/com/kapture/ticketconfigurationmicroservice/TicketConfigurationMicroserviceApplicationTests.java
Type: function
Code Snippet:
@Test
	void contextLoads() {
	}

--- Result 2 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/test/java/com/kapture/ticketconfigurationmicroservice/TicketConfigurationMicroserviceApplicationTests.java
Type: class
Code Snippet:
@SpringBootTest
class TicketConfigurationMicroserviceApplicationTests {

	@Test
	void contextLoads() {
	}

}

--- Result 3 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/main/java/com/kapture/ticketconfigurationmicroservice/ticket/service/WebHookDataPrivilege.java
Type: function
Code Snippet:
public String getCategory() {
        return category;
    }

--- Result 4 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/main/java/com/kapture/ticketconfigurationmicroservice/ticket/service/WebHookDataPrivilege.java
Type: function
Code Snippet:
public String getKey() {
        return key;
    }

--- Result 5 ---
File: /home/dheena/workspace/microservices/ticket-configuration-microservice/src/main/java/com/kapture/ticketconfigurationmicroservice/ticket/service/WebHookDataPrivilege.java
Type: function
Code Snippet:
public String getName() {
        return name;
    }`` for all queries im getting this output which is totally irrevelant. source code ``#!/usr/bin/env python
# coding: utf-8

import torch
import faiss
from transformers import AutoTokenizer, AutoModel
import json
import numpy as np

# Load the tokenizer and model
model_name = "microsoft/codebert-base"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)

# Optional: Move model to GPU if available
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model.to(device)

# Load the code snippets and metadata
with open('/home/dheena/Downloads/Intiliee/output/code_snippets.json', 'r') as f:
    code_snippets = json.load(f)

with open('/home/dheena/Downloads/Intiliee/output/metadata.json', 'r') as f:
    metadata = json.load(f)

# Ensure code_snippets and metadata are lists
if isinstance(code_snippets, str):
    code_snippets = json.loads(code_snippets)
if isinstance(metadata, str):
    metadata = json.loads(metadata)

# Load the Faiss index
index = faiss.read_index('code_embeddings.index')

def get_embedding(text, max_length=512):
    # Tokenize the text (code snippet or query)
    inputs = tokenizer(
        text,
        return_tensors='pt',
        truncation=True,
        padding='max_length',
        max_length=max_length
    )
    inputs = {key: value.to(device) for key, value in inputs.items()}
    # Generate embeddings without computing gradients
    with torch.no_grad():
        outputs = model(**inputs)
        # Use the embedding of the [CLS] token
        embedding = outputs.last_hidden_state[:, 0, :].cpu().numpy()
    return embedding

def search_codebase(query_embedding, k=5):
    distances, indices = index.search(query_embedding, k)
    retrieved_snippets = []
    for idx in indices[0]:
        snippet = code_snippets[idx]
        meta = metadata[idx]
        retrieved_snippets.append((snippet, meta))
    return retrieved_snippets

def display_results(retrieved_snippets):
    if not retrieved_snippets:
        print("No relevant code snippets found.")
        return
    for i, (snippet, meta) in enumerate(retrieved_snippets):
        print(f"\n--- Result {i+1} ---")
        print(f"File: {meta['file_name']}")
        print(f"Type: {meta['type']}")
        print("Code Snippet:")
        print(snippet)

def main():
    print("Welcome to the Codebase Query Interface!")
    print("Type 'exit' to exit the program.\n")
    while True:
        user_query = input("Enter your query: ")
        if user_query.lower() == 'exit':
            print("Goodbye!")
            break
        # Generate query embedding
        query_embedding = get_embedding(user_query)
        # Perform similarity search
        retrieved_snippets = search_codebase(query_embedding, k=5)
        # Display results
        display_results(retrieved_snippets)

if __name__ == '__main__':
    main()``