ai-microcore 4.0.0.dev9__tar.gz → 4.0.0.dev10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/PKG-INFO +1 -1
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/__init__.py +1 -1
- ai_microcore-4.0.0.dev10/microcore/interactive_setup.py +75 -0
- ai_microcore-4.0.0.dev9/microcore/interactive_setup.py +0 -38
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/LICENSE +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/README.md +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/_env.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/_llm_functions.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/_prepare_llm_args.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/ai_func/__init__.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/ai_func/ai-func.json.j2 +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/ai_func/ai-func.pythonic.j2 +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/ai_modules.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/configuration.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/embedding_db/__init__.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/embedding_db/chromadb.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/file_storage.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/json_parsing.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/__init__.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/_openai_llm_v0.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/_openai_llm_v1.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/anthropic.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/google_genai.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/google_vertex_ai.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/local_llm.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/local_transformers.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/openai_llm.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/llm/shared.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/logging.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/message_types.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/metrics.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/python.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/templating/__init__.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/templating/jinja2.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/text2speech/elevenlabs.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/tokenizing.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/types.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/ui.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/utils.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/wrappers/__init__.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/wrappers/llm_response_wrapper.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/wrappers/prompt_wrapper.py +0 -0
- {ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ai-microcore
|
|
3
|
-
Version: 4.0.0.
|
|
3
|
+
Version: 4.0.0.dev10
|
|
4
4
|
Summary: # Minimalistic Foundation for AI Applications
|
|
5
5
|
Keywords: llm,large language models,ai,similarity search,ai search,gpt,openai
|
|
6
6
|
Author-email: Vitalii Stepanenko <mail@vitalii.in>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from .configuration import EmbeddingDbType, ApiType
|
|
2
|
+
from .ui import ask_choose, ask_non_empty, ask_yn, error, yellow
|
|
3
|
+
from ._env import configure
|
|
4
|
+
from ._llm_functions import llm
|
|
5
|
+
from .utils import file_link
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def interactive_setup(
|
|
9
|
+
file_path: str,
|
|
10
|
+
defaults: dict = None,
|
|
11
|
+
extras: dict | list = None,
|
|
12
|
+
):
|
|
13
|
+
"""
|
|
14
|
+
Interactive setup for LLM API configuration.
|
|
15
|
+
Prompts user for configuration details such as API type, key, model name,
|
|
16
|
+
and base URL. Tests the LLM API with a sample query and saves the configuration
|
|
17
|
+
to a specified file if the user chooses to do so.
|
|
18
|
+
Args:
|
|
19
|
+
file_path (str): Path to the configuration file.
|
|
20
|
+
defaults (dict, optional): Default configuration values.
|
|
21
|
+
If provided, user will not be prompted for those values.
|
|
22
|
+
Additional values for storing in the file can be added to defaults.
|
|
23
|
+
extras (dict | list, optional): Additional configuration fields to prompt for.
|
|
24
|
+
"""
|
|
25
|
+
raw_config = dict(defaults) if defaults else dict()
|
|
26
|
+
if "LLM_API_TYPE" not in raw_config:
|
|
27
|
+
raw_config["LLM_API_TYPE"] = ask_choose(
|
|
28
|
+
"Choose LLM API Type:",
|
|
29
|
+
list(i.value for i in ApiType if not ApiType.is_local(i)),
|
|
30
|
+
)
|
|
31
|
+
if "LLM_API_KEY" not in raw_config:
|
|
32
|
+
raw_config["LLM_API_KEY"] = ask_non_empty("API Key: ")
|
|
33
|
+
if "MODEL" not in raw_config:
|
|
34
|
+
raw_config["MODEL"] = ask_non_empty("Model Name: ")
|
|
35
|
+
if "LLM_API_BASE" not in raw_config:
|
|
36
|
+
raw_config["LLM_API_BASE"] = input("API Base URL (may be empty for some API types): ")
|
|
37
|
+
if extras:
|
|
38
|
+
if isinstance(extras, list):
|
|
39
|
+
extras = {
|
|
40
|
+
i: str(i)
|
|
41
|
+
.replace('_', ' ')
|
|
42
|
+
.capitalize()
|
|
43
|
+
.replace('Llm', 'LLM')
|
|
44
|
+
.replace('Api', 'API')
|
|
45
|
+
for i in extras
|
|
46
|
+
}
|
|
47
|
+
for field, title in extras.items():
|
|
48
|
+
if field not in raw_config:
|
|
49
|
+
raw_config[field] = ask_non_empty(f"{title}: ")
|
|
50
|
+
try:
|
|
51
|
+
configure(
|
|
52
|
+
**{
|
|
53
|
+
**dict(
|
|
54
|
+
USE_DOT_ENV=False,
|
|
55
|
+
EMBEDDING_DB_TYPE=EmbeddingDbType.NONE,
|
|
56
|
+
USE_LOGGING=True,
|
|
57
|
+
),
|
|
58
|
+
**raw_config
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
print("Testing LLM...")
|
|
62
|
+
q = "What is capital of France?\n(!) IMPORTANT: Answer only with one word"
|
|
63
|
+
assert "pari" in llm(q).lower()
|
|
64
|
+
except Exception as e: # pylint: disable=W0718
|
|
65
|
+
error(f"Error testing LLM API: {e}")
|
|
66
|
+
if ask_yn("Restart configuring?"):
|
|
67
|
+
interactive_setup(file_path, defaults, extras)
|
|
68
|
+
return
|
|
69
|
+
|
|
70
|
+
config_body = ''.join(f"{k}={v}\n" for k, v in raw_config.items())
|
|
71
|
+
print(f"Configuration:\n{yellow(config_body)}")
|
|
72
|
+
if ask_yn("Save configuration to file?"):
|
|
73
|
+
print(f"Saved to {file_link(file_path)}")
|
|
74
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
75
|
+
f.write(config_body)
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
from .configuration import EmbeddingDbType, ApiType
|
|
2
|
-
from .ui import ask_choose, ask_non_empty, ask_yn, error, yellow
|
|
3
|
-
from ._env import configure
|
|
4
|
-
from ._llm_functions import llm
|
|
5
|
-
from .utils import file_link
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def interactive_setup(file_path: str):
|
|
9
|
-
raw_config = dict()
|
|
10
|
-
raw_config["LLM_API_TYPE"] = ask_choose(
|
|
11
|
-
"Choose LLM API Type:",
|
|
12
|
-
list(i.value for i in ApiType if not ApiType.is_local(i)),
|
|
13
|
-
)
|
|
14
|
-
raw_config["LLM_API_KEY"] = ask_non_empty("API Key: ")
|
|
15
|
-
raw_config["MODEL"] = ask_non_empty("Model Name: ")
|
|
16
|
-
raw_config["LLM_API_BASE"] = input("API Base URL (may be empty for some API types): ")
|
|
17
|
-
try:
|
|
18
|
-
configure(
|
|
19
|
-
USE_DOT_ENV=False,
|
|
20
|
-
EMBEDDING_DB_TYPE=EmbeddingDbType.NONE,
|
|
21
|
-
USE_LOGGING=True,
|
|
22
|
-
**raw_config
|
|
23
|
-
)
|
|
24
|
-
print("Testing LLM...")
|
|
25
|
-
q = "What is capital of France?\n(!) IMPORTANT: Answer only with one word"
|
|
26
|
-
assert "pari" in llm(q).lower()
|
|
27
|
-
except Exception as e: # pylint: disable=W0718
|
|
28
|
-
error(f"Error testing LLM API: {e}")
|
|
29
|
-
if ask_yn("Restart configuring?"):
|
|
30
|
-
interactive_setup(file_path)
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
config_body = ''.join(f"{k}={v}\n" for k, v in raw_config.items())
|
|
34
|
-
print(f"Configuration:\n{yellow(config_body)}")
|
|
35
|
-
if ask_yn("Save configuration to file?"):
|
|
36
|
-
print(f"Saved to {file_link(file_path)}")
|
|
37
|
-
with open(file_path, "w", encoding="utf-8") as f:
|
|
38
|
-
f.write(config_body)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ai_microcore-4.0.0.dev9 → ai_microcore-4.0.0.dev10}/microcore/wrappers/llm_response_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|