mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-21 05:33:12 +00:00
upgraded ollama
This commit is contained in:
parent
79077ce242
commit
d970f80325
@ -117,7 +117,7 @@ class AudioRecorder:
|
||||
except:
|
||||
self.lollmsCom.error("No audio input found!")
|
||||
|
||||
def _record(self, indata, frames, time, status):
|
||||
def _record(self, indata, frames, time_, status):
|
||||
first_recording = True # Flag to track the first recording
|
||||
silence_duration = 5
|
||||
non_silent_start = None
|
||||
|
@ -61,10 +61,6 @@ def list_personalities(category:str):
|
||||
ASCIIColors.error(f"No personalities found. Using default one {ex}")
|
||||
return personalities
|
||||
|
||||
@router.get("/list_mounted_personalities")
|
||||
def list_mounted_personalities():
|
||||
return lollmsElfServer.config.personalities
|
||||
|
||||
@router.get("/get_all_personalities")
|
||||
def get_all_personalities():
|
||||
ASCIIColors.yellow("Listing all personalities")
|
||||
@ -161,9 +157,9 @@ def get_all_personalities():
|
||||
def list_mounted_personalities():
|
||||
ASCIIColors.yellow("- Listing mounted personalities")
|
||||
return {"status": True,
|
||||
"personalities":lollmsElfServer.config["personalities"],
|
||||
"active_personality_id":lollmsElfServer.config["active_personality_id"]
|
||||
}
|
||||
"personalities":lollmsElfServer.config["personalities"],
|
||||
"active_personality_id":lollmsElfServer.config["active_personality_id"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -348,7 +344,7 @@ def remount_personality(data:PersonalityMountingInfos):
|
||||
return {"status": False, "error":f"Personality not found @ {pth}"}
|
||||
|
||||
|
||||
@router.post("/remount_personality")
|
||||
@router.post("/unmount_personality")
|
||||
def unmount_personality(data:PersonalityMountingInfos):
|
||||
print("- Unmounting personality ...")
|
||||
category = data.category
|
||||
|
@ -2,6 +2,8 @@
|
||||
# This script installs Ollama on Linux.
|
||||
# It detects the current operating system architecture and installs the appropriate version of Ollama.
|
||||
|
||||
cd ~/
|
||||
|
||||
set -eu
|
||||
|
||||
status() { echo ">>> $*" >&2; }
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd ~/
|
||||
|
||||
# Set the OLLAMA_HOST address
|
||||
OLLAMA_HOST="0.0.0.0:11434"
|
||||
|
||||
@ -9,7 +11,7 @@ OLLAMA_MODELS=~/ollama/models ollama serve &
|
||||
# Check if models.txt exists
|
||||
if [ ! -f models.txt ]; then
|
||||
# Create models.txt and add "mixtral" to it
|
||||
echo "mistral" > models.txt
|
||||
echo "mistral" > ~/models.txt
|
||||
fi
|
||||
|
||||
# Read the models from the file
|
||||
@ -17,7 +19,7 @@ while IFS= read -r model
|
||||
do
|
||||
# Run each model in the background
|
||||
ollama run "$model" &
|
||||
done < models.txt
|
||||
done < ~/models.txt
|
||||
|
||||
# Wait for all background processes to finish
|
||||
wait
|
||||
|
@ -30,8 +30,26 @@ import asyncio
|
||||
|
||||
import ctypes
|
||||
import io
|
||||
import urllib
|
||||
|
||||
def file_path_to_url(file_path):
|
||||
"""
|
||||
This function takes a file path as an argument and converts it into a URL format. It first removes the initial part of the file path until the "outputs" string is reached, then replaces backslashes with forward slashes and quotes each segment with urllib.parse.quote() before joining them with forward slashes to form the final URL.
|
||||
|
||||
:param file_path: str, the file path in the format of a Windows system
|
||||
:return: str, the converted URL format of the given file path
|
||||
"""
|
||||
|
||||
url = "/"+file_path[file_path.index("outputs"):].replace("\\","/")
|
||||
return "/".join([urllib.parse.quote(p, safe="") for p in url.split("/")])
|
||||
|
||||
|
||||
|
||||
def is_asyncio_loop_running():
|
||||
"""
|
||||
# This function checks if an AsyncIO event loop is currently running. If an event loop is running, it returns True. If not, it returns False.
|
||||
:return: bool, indicating whether or not an AsyncIO event loop is currently running
|
||||
"""
|
||||
try:
|
||||
return asyncio.get_event_loop().is_running()
|
||||
except RuntimeError: # This gets raised if there's no running event loop
|
||||
@ -57,8 +75,16 @@ def run_async(func):
|
||||
try:
|
||||
asyncio.run(func())
|
||||
except:
|
||||
func()
|
||||
func()
|
||||
|
||||
|
||||
def terminate_thread(thread):
|
||||
"""
|
||||
This function is used to terminate a given thread if it's currently running. If the thread is not alive, an informational message will be displayed and the function will return without raising any error. Otherwise, it sets the thread's exception to `SystemExit` using `ctypes`, which causes the thread to exit. The function collects the garbage after terminating the thread, and raises a `SystemError` if it fails to do so.
|
||||
:param thread: thread object to be terminated
|
||||
:return: None if the thread was successfully terminated or an error is raised
|
||||
:raises SystemError: if the thread could not be terminated
|
||||
"""
|
||||
if thread:
|
||||
if not thread.is_alive():
|
||||
ASCIIColors.yellow("Thread not alive")
|
||||
@ -76,6 +102,16 @@ def terminate_thread(thread):
|
||||
ASCIIColors.yellow("Canceled successfully")
|
||||
|
||||
def convert_language_name(language_name):
|
||||
"""
|
||||
Convert a language name string to its corresponding ISO 639-1 code.
|
||||
If the given language name is not supported, returns "unsupported".
|
||||
|
||||
Parameters:
|
||||
- language_name (str): A lowercase and dot-free string representing the name of a language.
|
||||
|
||||
Returns:
|
||||
- str: The corresponding ISO 639-1 code for the given language name or "unsupported" if it's not supported.
|
||||
"""
|
||||
# Remove leading and trailing spaces
|
||||
language_name = language_name.strip()
|
||||
|
||||
@ -83,13 +119,12 @@ def convert_language_name(language_name):
|
||||
language_name = language_name.lower().replace(".","")
|
||||
|
||||
# Define a dictionary mapping language names to their codes
|
||||
language_codes = {
|
||||
"english": "en",
|
||||
"spanish": "es",
|
||||
"french": "fr",
|
||||
"german": "de",
|
||||
# Add more language names and codes as needed
|
||||
}
|
||||
language_codes = {
|
||||
"english": "en", "spanish": "es", "french": "fr", "german": "de",
|
||||
"italian": "it", "portuguese": "pt", "russian": "ru", "mandarin": "zh-CN",
|
||||
"korean": "ko", "japanese": "ja", "dutch": "nl", "polish": "pl",
|
||||
"hindi": "hi", "arabic": "ar", "bengali": "bn", "swedish": "sv", "thai": "th", "vietnamese": "vi"
|
||||
}
|
||||
|
||||
# Return the corresponding language code if found, or None otherwise
|
||||
return language_codes.get(language_name,"en")
|
||||
|
Loading…
Reference in New Issue
Block a user