mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-04-24 04:55:44 +00:00
enhanced function claling
This commit is contained in:
parent
4bfe2eb258
commit
8579bcb455
@ -475,7 +475,8 @@ async def open_code_in_vs_code(vs_code_data: VSCodeData):
|
||||
trace_exception(ex)
|
||||
lollmsElfServer.error(ex)
|
||||
return {"status": False, "error": str(ex)}
|
||||
|
||||
class ClientAuthentication(BaseModel):
|
||||
client_id: str = Field(...)
|
||||
|
||||
class DiscussionFolderRequest(BaseModel):
|
||||
client_id: str = Field(...)
|
||||
@ -535,6 +536,61 @@ async def open_discussion_folder(request: DiscussionFolderRequest):
|
||||
}
|
||||
|
||||
|
||||
|
||||
@router.post("/open_custom_function_calls_folder")
|
||||
async def open_custom_function_calls_folder(request: ClientAuthentication):
|
||||
"""
|
||||
Opens custom function calls folder.
|
||||
|
||||
:param request: The HTTP request object.
|
||||
:return: A JSON response with the status of the operation.
|
||||
"""
|
||||
client = check_access(lollmsElfServer, request.client_id)
|
||||
|
||||
if lollmsElfServer.config.headless_server_mode:
|
||||
return {
|
||||
"status": False,
|
||||
"error": "Open code folder is blocked when in headless mode for obvious security reasons!",
|
||||
}
|
||||
|
||||
if (
|
||||
lollmsElfServer.config.host != "localhost"
|
||||
and lollmsElfServer.config.host != "127.0.0.1"
|
||||
):
|
||||
return {
|
||||
"status": False,
|
||||
"error": "Open code folder is blocked when the server is exposed outside for very obvious reasons!",
|
||||
}
|
||||
|
||||
if lollmsElfServer.config.turn_on_open_file_validation:
|
||||
if not show_yes_no_dialog(
|
||||
"Validation", "Do you validate the opening of a folder?"
|
||||
):
|
||||
return {"status": False, "error": "User refused the opeining folder!"}
|
||||
|
||||
try:
|
||||
ASCIIColors.info("Opening folder:")
|
||||
# Create a temporary file.
|
||||
root_folder = lollmsElfServer.lollms_paths.custom_functions_zoo_path
|
||||
root_folder.mkdir(parents=True, exist_ok=True)
|
||||
if platform.system() == "Windows":
|
||||
subprocess.Popen(f'explorer "{root_folder}"')
|
||||
elif platform.system() == "Linux":
|
||||
subprocess.run(["xdg-open", str(root_folder)], check=True)
|
||||
elif platform.system() == "Darwin":
|
||||
subprocess.run(["open", str(root_folder)], check=True)
|
||||
return {"status": True, "execution_time": 0}
|
||||
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
lollmsElfServer.error(ex)
|
||||
return {
|
||||
"status": False,
|
||||
"error": "An error occurred while processing the request",
|
||||
}
|
||||
|
||||
|
||||
|
||||
class PersonalityFolderRequest(BaseModel):
|
||||
client_id: str = Field(...)
|
||||
personality_folder: str = Field(...)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 862fcc594fb364a11f0bb98447f1278b3c0198ec
|
||||
Subproject commit dbe4b2126c7490312b04888771d3870192bb70a1
|
@ -1725,7 +1725,7 @@ Don't forget encapsulate the code inside a markdown code tag. This is mandatory.
|
||||
self.generating = True
|
||||
client.processing = True
|
||||
try:
|
||||
generation_output = self.generate(
|
||||
self.generate(
|
||||
context_details,
|
||||
client_id=client_id,
|
||||
is_continue=is_continue,
|
||||
@ -1733,7 +1733,7 @@ Don't forget encapsulate the code inside a markdown code tag. This is mandatory.
|
||||
)
|
||||
try:
|
||||
if len(context_details.function_calls)>0:
|
||||
codes = self.personality.extract_code_blocks(generation_output)
|
||||
codes = self.personality.extract_code_blocks(client.generated_text)
|
||||
for code in codes:
|
||||
if code["type"]=="function":
|
||||
infos = json.loads(code["content"])
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
web/dist/index.html
vendored
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LoLLMS WebUI</title>
|
||||
<script type="module" crossorigin src="/assets/index-DlQpxWli.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DXnv6_sp.css">
|
||||
<script type="module" crossorigin src="/assets/index-D9m10VKS.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CtEAmk75.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -3171,6 +3171,13 @@ export default {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
},
|
||||
async openCustomFunctionCallsFolder(id){
|
||||
const json = JSON.stringify({ 'client_id': this.$store.state.client_id, 'discussion_id': id.id })
|
||||
await axios.post(`/open_custom_function_calls_folder`, json, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
},
|
||||
async editTitle(newTitleObj) {
|
||||
|
||||
const index = this.discussionsList.findIndex((x) => x.id == newTitleObj.id)
|
||||
|
@ -4485,7 +4485,8 @@
|
||||
<select id="funcCat" @change="update_function_category($event.target.value, refresh)"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||
<option v-for="(item, index) in funcCatgArr" :key="index"
|
||||
:selected="item == this.function_category">{{ item }}</option>
|
||||
:selected="item == function_category">{{ item }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
@ -5051,6 +5052,17 @@ export default {
|
||||
//await socket.on('install_progress', this.progressListener);
|
||||
},
|
||||
methods: {
|
||||
// Update function category
|
||||
update_function_category(category, refresh) {
|
||||
console.log("this.function_category changed to "+category)
|
||||
this.function_category = category;
|
||||
if (refresh) {
|
||||
console.log("Refreshing")
|
||||
// Filter functions based on the default category
|
||||
this.updateFilteredFunctions();
|
||||
this.refreshFunctionsZoo();
|
||||
}
|
||||
},
|
||||
async fetchFunctionCalls() {
|
||||
try {
|
||||
const response = await fetch('/list_function_calls');
|
||||
@ -5106,6 +5118,7 @@ export default {
|
||||
});
|
||||
if (response.data.status) {
|
||||
this.$store.state.messageBox.showMessage('Function mounted successfully', true);
|
||||
func.mounted = false;
|
||||
} else {
|
||||
this.$store.state.messageBox.showMessage('Failed to mount function', false);
|
||||
}
|
||||
@ -5125,11 +5138,11 @@ export default {
|
||||
});
|
||||
if (response.data.status) {
|
||||
await this.$store.dispatch('refreshConfig');
|
||||
this.$store.state.toast.show('Function mounted successfully!', 4, true)
|
||||
this.$store.state.toast.showToast('Function mounted successfully!', 4, true)
|
||||
this.$store.state.messageBox.showMessage('Function unmounted successfully', true);
|
||||
func.mounted = true
|
||||
} else {
|
||||
this.$store.state.toast.show('Failed to unmount function', 4, false)
|
||||
this.$store.state.toast.showToast('Failed to unmount function', 4, false)
|
||||
this.$store.state.messageBox.showMessage('Failed to unmount function', false);
|
||||
}
|
||||
} catch (error) {
|
||||
@ -5156,15 +5169,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// Update function category
|
||||
update_function_category(category, refresh) {
|
||||
console.log("this.function_category")
|
||||
this.function_category = category;
|
||||
if (refresh) {
|
||||
this.refreshFunctionsZoo();
|
||||
}
|
||||
},
|
||||
|
||||
// Refresh functions zoo
|
||||
refreshFunctionsZoo() {
|
||||
this.$store.dispatch('refreshFunctionsZoo');
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2187d1a18760500993e9bd799d77edd0d49be769
|
||||
Subproject commit bff682ef0eb3e0cf5023d9815f4014c7137f52fb
|
Loading…
x
Reference in New Issue
Block a user