sunholo 0.89.1__tar.gz → 0.89.4__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.
- {sunholo-0.89.1 → sunholo-0.89.4}/PKG-INFO +2 -2
- {sunholo-0.89.1 → sunholo-0.89.4}/setup.py +1 -1
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/dispatch_to_qa.py +18 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/flask/vac_routes.py +46 -11
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/langfuse/evals.py +18 -6
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo.egg-info/PKG-INFO +2 -2
- {sunholo-0.89.1 → sunholo-0.89.4}/LICENSE.txt +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/MANIFEST.in +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/README.md +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/setup.cfg +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/flask/qna_routes.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/langserve.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/route.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/agents/swagger.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/archive/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/archive/archive.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/auth/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/auth/refresh.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/auth/run.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/azure/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/azure/auth.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/azure/blobs.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/bots/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/bots/discord.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/bots/webapp.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/azure.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/images.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/publish.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/cli.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/configs.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/deploy.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/embedder.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/swagger.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/cli/vertex.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/components/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/components/llm.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/components/retriever.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/custom_logging.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/alloydb.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/database.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/lancedb.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/database/uuid.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/excel/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/excel/plugin.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/genai/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/genai/init.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/genai/safety.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/invoke/async_class.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/patches/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/patches/langchain/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/patches/langchain/lancedb.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/patches/langchain/vertexai.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/qna/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/qna/parsers.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/qna/retry.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/tools/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/api_key.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/big_context.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/config.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/config_class.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/gcp.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/parsers.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/utils/version.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/init.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/safety.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/tests/test_chat_history.py +0 -0
- {sunholo-0.89.1 → sunholo-0.89.4}/tests/test_config.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.89.
|
|
3
|
+
Version: 0.89.4
|
|
4
4
|
Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
|
|
5
5
|
Home-page: https://github.com/sunholo-data/sunholo-py
|
|
6
|
-
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.89.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.89.4.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -20,6 +20,12 @@ from .langserve import prepare_request_data
|
|
|
20
20
|
|
|
21
21
|
from .route import route_endpoint
|
|
22
22
|
|
|
23
|
+
try:
|
|
24
|
+
from langfuse import Langfuse
|
|
25
|
+
langfuse = Langfuse()
|
|
26
|
+
except ImportError:
|
|
27
|
+
langfuse = None
|
|
28
|
+
|
|
23
29
|
def prep_request_payload(user_input, chat_history, vector_name, stream, **kwargs):
|
|
24
30
|
"""
|
|
25
31
|
Prepares the request payload for sending a query to the QA system.
|
|
@@ -79,9 +85,21 @@ def prep_request_payload(user_input, chat_history, vector_name, stream, **kwargs
|
|
|
79
85
|
|
|
80
86
|
if 'vector_name' not in qna_data:
|
|
81
87
|
qna_data['vector_name'] = vector_name
|
|
88
|
+
|
|
89
|
+
qna_data['trace_id'] = add_langfuse_trace(qna_endpoint)
|
|
82
90
|
|
|
83
91
|
return qna_endpoint, qna_data
|
|
84
92
|
|
|
93
|
+
def add_langfuse_trace(qna_endpoint):
|
|
94
|
+
if not langfuse:
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
trace = langfuse.trace(name = f'auto/{qna_endpoint}')
|
|
98
|
+
|
|
99
|
+
log.info('Adding langfuse trace {trace.id}')
|
|
100
|
+
|
|
101
|
+
return trace.id
|
|
102
|
+
|
|
85
103
|
def send_to_qa(user_input, vector_name, chat_history, stream=False, **kwargs):
|
|
86
104
|
"""
|
|
87
105
|
Sends a query to the QA system synchronously.
|
|
@@ -2,6 +2,7 @@ import json
|
|
|
2
2
|
import traceback
|
|
3
3
|
import datetime
|
|
4
4
|
import uuid
|
|
5
|
+
import random
|
|
5
6
|
|
|
6
7
|
from ...agents import extract_chat_history, handle_special_commands
|
|
7
8
|
from ...qna.parsers import parse_output
|
|
@@ -18,12 +19,12 @@ from datetime import timedelta
|
|
|
18
19
|
try:
|
|
19
20
|
from flask import request, jsonify, Response
|
|
20
21
|
except ImportError:
|
|
21
|
-
pass
|
|
22
|
+
pass
|
|
22
23
|
|
|
23
24
|
try:
|
|
24
|
-
from
|
|
25
|
+
from ..pubsub import PubSubManager
|
|
25
26
|
except ImportError:
|
|
26
|
-
|
|
27
|
+
PubSubManager = None
|
|
27
28
|
|
|
28
29
|
# Cache dictionary to store validated API keys
|
|
29
30
|
api_key_cache = {}
|
|
@@ -161,7 +162,7 @@ if __name__ == "__main__":
|
|
|
161
162
|
|
|
162
163
|
|
|
163
164
|
def handle_stream_vac(self, vector_name):
|
|
164
|
-
observed_stream_interpreter =
|
|
165
|
+
observed_stream_interpreter = self.stream_interpreter
|
|
165
166
|
prep = self.prep_vac(request, vector_name)
|
|
166
167
|
log.info(f"Processing prep: {prep}")
|
|
167
168
|
trace = prep["trace"]
|
|
@@ -221,11 +222,41 @@ if __name__ == "__main__":
|
|
|
221
222
|
generation.end(output=response)
|
|
222
223
|
span.end(output=response)
|
|
223
224
|
trace.update(output=response)
|
|
225
|
+
self.langfuse_eval_response(trace.id, all_input.get('eval_percent', 0.01))
|
|
224
226
|
|
|
225
227
|
return response
|
|
228
|
+
|
|
229
|
+
def langfuse_eval_response(trace_id, eval_percent=0.01):
|
|
230
|
+
"""
|
|
231
|
+
Sends an evaluation message based on a probability defined by eval_percent.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
eval_percent (float): The probability (0 to 1) of triggering the evaluation.
|
|
235
|
+
trace_id (str): The trace identifier for the evaluation.
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
None
|
|
239
|
+
"""
|
|
240
|
+
if eval_percent > 1 or eval_percent < 0:
|
|
241
|
+
raise ValueError("eval_percent must be a float between 0 and 1.")
|
|
242
|
+
|
|
243
|
+
# Generate a random float between 0 and 1
|
|
244
|
+
random_value = random.random()
|
|
245
|
+
|
|
246
|
+
# Check if evaluation should be triggered
|
|
247
|
+
if random_value < eval_percent:
|
|
248
|
+
if PubSubManager:
|
|
249
|
+
try:
|
|
250
|
+
pubsub_manager = PubSubManager("langfuse_evals", pubsub_topic="topicid-to-langfuse-eval")
|
|
251
|
+
the_data = {"trace_id": trace_id}
|
|
252
|
+
pubsub_manager.publish_message(the_data)
|
|
253
|
+
except Exception as e:
|
|
254
|
+
log.warning(f"Could not publish message for 'langfuse_evals' to topicid-to-langfuse-eval - {str(e)}")
|
|
255
|
+
else:
|
|
256
|
+
log.info(f"Did not do Langfuse eval due to random sampling not passed: {eval_percent=}")
|
|
226
257
|
|
|
227
258
|
def handle_process_vac(self, vector_name):
|
|
228
|
-
observed_vac_interpreter =
|
|
259
|
+
observed_vac_interpreter = self.vac_interpreter
|
|
229
260
|
prep = self.prep_vac(request, vector_name)
|
|
230
261
|
log.debug(f"Processing prep: {prep}")
|
|
231
262
|
trace = prep["trace"]
|
|
@@ -268,6 +299,7 @@ if __name__ == "__main__":
|
|
|
268
299
|
if trace:
|
|
269
300
|
span.end(output=jsonify(bot_output))
|
|
270
301
|
trace.update(output=jsonify(bot_output))
|
|
302
|
+
self.langfuse_eval_response(trace.id, all_input.get('eval_percent', 0.01))
|
|
271
303
|
|
|
272
304
|
# {'answer': 'output'}
|
|
273
305
|
return jsonify(bot_output)
|
|
@@ -365,7 +397,7 @@ if __name__ == "__main__":
|
|
|
365
397
|
"kwargs": data
|
|
366
398
|
}
|
|
367
399
|
|
|
368
|
-
observed_stream_interpreter =
|
|
400
|
+
observed_stream_interpreter = self.stream_interpreter
|
|
369
401
|
|
|
370
402
|
response_id = str(uuid.uuid4())
|
|
371
403
|
|
|
@@ -416,7 +448,7 @@ if __name__ == "__main__":
|
|
|
416
448
|
return Response(generate_response_content(), content_type='text/plain; charset=utf-8')
|
|
417
449
|
|
|
418
450
|
try:
|
|
419
|
-
observed_vac_interpreter =
|
|
451
|
+
observed_vac_interpreter = self.vac_interpreter
|
|
420
452
|
bot_output = observed_vac_interpreter(
|
|
421
453
|
question=user_message,
|
|
422
454
|
vector_name=vector_name,
|
|
@@ -437,7 +469,7 @@ if __name__ == "__main__":
|
|
|
437
469
|
return self.make_openai_response(user_message, vector_name, f'ERROR: {str(err)}')
|
|
438
470
|
|
|
439
471
|
|
|
440
|
-
def create_langfuse_trace(self, request, vector_name):
|
|
472
|
+
def create_langfuse_trace(self, request, vector_name, trace_id):
|
|
441
473
|
try:
|
|
442
474
|
from langfuse import Langfuse
|
|
443
475
|
langfuse = Langfuse()
|
|
@@ -451,11 +483,12 @@ if __name__ == "__main__":
|
|
|
451
483
|
message_source = request.headers.get("X-Message-Source")
|
|
452
484
|
|
|
453
485
|
package_version = sunholo_version()
|
|
454
|
-
tags = [package_version]
|
|
486
|
+
tags = [package_version, "autogenerated"]
|
|
455
487
|
if message_source:
|
|
456
488
|
tags.append(message_source)
|
|
457
489
|
|
|
458
490
|
return langfuse.trace(
|
|
491
|
+
id=trace_id,
|
|
459
492
|
name = f"/vac/{vector_name}",
|
|
460
493
|
user_id = user_id,
|
|
461
494
|
session_id = session_id,
|
|
@@ -464,8 +497,6 @@ if __name__ == "__main__":
|
|
|
464
497
|
)
|
|
465
498
|
|
|
466
499
|
def prep_vac(self, request, vector_name):
|
|
467
|
-
trace = self.create_langfuse_trace(request, vector_name)
|
|
468
|
-
span = None
|
|
469
500
|
|
|
470
501
|
if request.content_type.startswith('application/json'):
|
|
471
502
|
data = request.get_json()
|
|
@@ -490,6 +521,10 @@ if __name__ == "__main__":
|
|
|
490
521
|
|
|
491
522
|
log.info(f"vac/{vector_name} got data: {data}")
|
|
492
523
|
|
|
524
|
+
trace_id = data.get('trace_id')
|
|
525
|
+
trace = self.create_langfuse_trace(request, vector_name, trace_id)
|
|
526
|
+
span = None
|
|
527
|
+
|
|
493
528
|
config, _ = load_config("config/llm_config.yaml")
|
|
494
529
|
vac_configs = config.get("vac")
|
|
495
530
|
if vac_configs:
|
|
@@ -29,18 +29,30 @@ def pubsub_to_evals(data: dict, eval_funcs: list=[eval_length]) -> dict:
|
|
|
29
29
|
|
|
30
30
|
if 'trace_id' not in message_data:
|
|
31
31
|
raise ValueError('No trace_id found in message data')
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
trace_id = message_data.pop('trace_id', None)
|
|
34
|
+
|
|
35
|
+
return do_evals(trace_id, eval_funcs, **message_data)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def direct_langfuse_evals(data, eval_funcs: list=[eval_length]):
|
|
39
|
+
if 'trace_id' not in data:
|
|
40
|
+
raise ValueError('No trace_id found in data')
|
|
41
|
+
trace_id = data.pop('trace_id', None)
|
|
42
|
+
|
|
43
|
+
return do_evals(trace_id, eval_funcs, **data)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def do_evals(trace_id, eval_funcs: list=[eval_length], **kwargs) -> dict:
|
|
33
47
|
# Initialize Langfuse with environment variables
|
|
34
48
|
langfuse = Langfuse(
|
|
35
49
|
secret_key=os.environ["LANGFUSE_SECRET_KEY"],
|
|
36
50
|
public_key=os.environ["LANGFUSE_PUBLIC_KEY"],
|
|
37
51
|
host=os.environ["LANGFUSE_HOST"]
|
|
38
52
|
)
|
|
39
|
-
|
|
40
|
-
trace_id = message_data.pop('trace_id', None)
|
|
41
53
|
|
|
42
54
|
# Fetch the latest trace (or modify as needed to fetch a specific trace)
|
|
43
|
-
trace = langfuse.
|
|
55
|
+
trace = langfuse.get_trace(id=trace_id)
|
|
44
56
|
|
|
45
57
|
if trace.output is None:
|
|
46
58
|
raise ValueError("Trace {trace.name} had no generated output, it was skipped")
|
|
@@ -53,7 +65,7 @@ def pubsub_to_evals(data: dict, eval_funcs: list=[eval_length]) -> dict:
|
|
|
53
65
|
|
|
54
66
|
eval_name = eval_func.__name__
|
|
55
67
|
|
|
56
|
-
if 'score'
|
|
68
|
+
if 'score' and 'reason' not in eval_result:
|
|
57
69
|
raise ValueError(f"Trace {trace.name} using {eval_name=} did not return a dict with 'score' and 'reason': {eval_result=}")
|
|
58
70
|
|
|
59
71
|
log.info(f"TraceId {trace.id} with name {trace.name} had {eval_name=} with score {eval_result=}")
|
|
@@ -64,7 +76,7 @@ def pubsub_to_evals(data: dict, eval_funcs: list=[eval_length]) -> dict:
|
|
|
64
76
|
name=eval_name, # Use the function name as the evaluation name
|
|
65
77
|
value=eval_result["score"],
|
|
66
78
|
comment=eval_result["reason"],
|
|
67
|
-
**
|
|
79
|
+
**kwargs
|
|
68
80
|
)
|
|
69
81
|
|
|
70
82
|
return {"trace_id": trace.id, "eval_results": eval_results}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.89.
|
|
3
|
+
Version: 0.89.4
|
|
4
4
|
Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
|
|
5
5
|
Home-page: https://github.com/sunholo-data/sunholo-py
|
|
6
|
-
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.89.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.89.4.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|