-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/6Coders/ChatSQL
- Loading branch information
Showing
15 changed files
with
329 additions
and
329 deletions.
There are no files selected for viewing
29 changes: 22 additions & 7 deletions
29
backend/chatsql/adapter/outcoming/persistance/EmbeddingRepositoryAdapter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
from typing import List | ||
|
||
from chatsql.application.port.outcoming.persistance.BaseEmbeddingRepository import BaseEmbeddingRepository | ||
|
||
import os | ||
import numpy as np | ||
from chatsql.domain.Embedding import Embedding | ||
from chatsql.application.port.outcoming.persistance.BaseEmbeddingRepository import BaseEmbeddingRepository | ||
from chatsql.utils import Exceptions | ||
|
||
class EmbeddingRepositoryAdapter(BaseEmbeddingRepository): | ||
|
||
def __init__(self, folder: str) -> None: | ||
self._folder = folder | ||
|
||
def save(self, filename: str, embeddings: List[Embedding]) -> bool: | ||
raise NotImplementedError() | ||
try: | ||
filepath = os.path.join(self._folder, filename) | ||
np.save(filepath, embeddings) | ||
return True | ||
except Exception as e: | ||
raise Exceptions.FileNotSaved(f"Error while saving embeddings to {filename}: {e}") | ||
|
||
def load(self, filename: str) -> List[Embedding]: | ||
raise NotImplementedError() | ||
try: | ||
filepath = os.path.join(self._folder, filename) | ||
embeddings = np.load(filepath, allow_pickle=True) | ||
return embeddings.tolist() # Convert to list of Embedding objects | ||
except Exception as e: | ||
raise Exceptions.EmbeddingsNotLoaded(f"Error while loading embeddings from {filename}: {e}") | ||
|
||
def remove(self, filename: str) -> bool: | ||
raise NotImplementedError() | ||
|
||
try: | ||
filepath = os.path.join(self._folder, filename) | ||
os.remove(filepath) | ||
return True | ||
except Exception as e: | ||
raise Exceptions.FileNotRemoved(f"Error while removing embeddings file {filename}: {e}. Check if permissions are correct.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,52 @@ | ||
<template ref="Toast"> | ||
<div class="toast align-items-center text-white bg-primary border-0" role="alert" aria-live="assertive" aria-atomic="true"> | ||
<div class="d-flex"> | ||
<div class="toast-body"> | ||
{{ Message }} | ||
<template> | ||
<div ref="toast" class="toast align-items-center text-white bg-primary border-0" role="alert" aria-live="assertive" aria-atomic="true"> | ||
<div class="d-flex"> | ||
<div class="toast-body"> | ||
{{ Message }} | ||
</div> | ||
<button type="button" class="btn-close btn-close-white me-2 m-auto" aria-label="Close" data-bs-dismiss="toast"></button> | ||
</div> | ||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ref } from 'vue'; | ||
import 'bootstrap/dist/css/bootstrap.min.css'; | ||
import * as bootstrap from 'bootstrap'; | ||
export default { | ||
name: 'ToastPopup', | ||
setup() { | ||
/** | ||
* Represents a reactive reference to a message. | ||
* @type {Ref<string>} | ||
*/ | ||
const Message = ref(''); | ||
name: 'ToastPopup', | ||
setup() { | ||
/** | ||
* Represents a reactive reference to a message. | ||
* @type {Ref<string>} | ||
*/ | ||
const Message = ref(''); | ||
/** | ||
* Shows a toast notification. | ||
*/ | ||
function showToast() { | ||
const toastEl = document.querySelector('.toast'); | ||
/** | ||
* Shows a toast message. | ||
*/ | ||
function showToast() { | ||
const toastEl = document.querySelector('.toast'); | ||
if (toastEl) { | ||
const toast = new bootstrap.Toast(toastEl); | ||
toast.show(); | ||
} | ||
} | ||
/** | ||
* Sets the value of the Message variable to the specified message. | ||
* | ||
* @param {string} message - The message to set. | ||
*/ | ||
function setTest(message){ | ||
Message.value=message; | ||
} | ||
return{ | ||
showToast, | ||
setTest, | ||
Message | ||
} | ||
/** | ||
* Sets the value of the Message variable to the specified message. | ||
* | ||
* @param {string} message - The message to set the Message variable to. | ||
*/ | ||
function setTest(message) { | ||
Message.value = message; | ||
} | ||
} | ||
</script> | ||
return { | ||
showToast, | ||
setTest, | ||
Message | ||
}; | ||
} | ||
}; | ||
</script> |
10 changes: 0 additions & 10 deletions
10
frontend/tests/unit/__snapshots__/sendrequestbutton.spec.js.snap
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
frontend/tests/unit/__snapshots__/viewgeneratedprompts.spec.js.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.