olca 0.2.36__py3-none-any.whl → 0.2.38__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- olca/olcacli.py +34 -5
- olca/tracing.py +9 -2
- {olca-0.2.36.dist-info → olca-0.2.38.dist-info}/METADATA +1 -1
- olca-0.2.38.dist-info/RECORD +11 -0
- olca-0.2.36.dist-info/RECORD +0 -11
- {olca-0.2.36.dist-info → olca-0.2.38.dist-info}/LICENSE +0 -0
- {olca-0.2.36.dist-info → olca-0.2.38.dist-info}/WHEEL +0 -0
- {olca-0.2.36.dist-info → olca-0.2.38.dist-info}/entry_points.txt +0 -0
- {olca-0.2.36.dist-info → olca-0.2.38.dist-info}/top_level.txt +0 -0
olca/olcacli.py
CHANGED
@@ -5,6 +5,7 @@ import dotenv
|
|
5
5
|
from langchain import hub
|
6
6
|
import argparse
|
7
7
|
import yaml
|
8
|
+
import fusewill_utils as fu
|
8
9
|
|
9
10
|
#jgwill/olca1
|
10
11
|
#olca1_prompt = hub.pull("jgwill/olca1") #Future use
|
@@ -135,11 +136,19 @@ def extract_extra_directories_from_olca_config_system_and_user_input(system_inst
|
|
135
136
|
|
136
137
|
def print_stream(stream):
|
137
138
|
for s in stream:
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
try:
|
140
|
+
# Handle different response formats
|
141
|
+
if isinstance(s, dict) and "messages" in s:
|
142
|
+
message = s["messages"][-1]
|
143
|
+
else:
|
144
|
+
message = s
|
145
|
+
|
146
|
+
if isinstance(message, tuple):
|
147
|
+
print(message)
|
148
|
+
else:
|
149
|
+
print(message.content)
|
150
|
+
except Exception as e:
|
151
|
+
print(s)
|
143
152
|
|
144
153
|
def prepare_input(user_input, system_instructions,append_prompt=True, human=False):
|
145
154
|
appended_prompt = system_instructions + SYSTEM_PROMPT_APPEND if append_prompt else system_instructions
|
@@ -168,10 +177,22 @@ def _parse_args():
|
|
168
177
|
|
169
178
|
from olca.tracing import TracingManager
|
170
179
|
|
180
|
+
def load_environment():
|
181
|
+
# Load .env from current directory
|
182
|
+
dotenv.load_dotenv(dotenv_path=os.path.join(os.getcwd(), ".env"))
|
183
|
+
|
184
|
+
# Try loading from home directory if keys are missing
|
185
|
+
if not all([os.getenv(key) for key in ["LANGFUSE_PUBLIC_KEY", "LANGFUSE_SECRET_KEY", "LANGFUSE_HOST",
|
186
|
+
"LANGCHAIN_API_KEY", "OPENAI_API_KEY"]]):
|
187
|
+
dotenv.load_dotenv(dotenv_path=os.path.expanduser("~/.env"))
|
188
|
+
|
171
189
|
def main():
|
172
190
|
args = _parse_args()
|
173
191
|
olca_config_file = 'olca.yml'
|
174
192
|
|
193
|
+
# Load environment variables first
|
194
|
+
load_environment()
|
195
|
+
|
175
196
|
if args.init:
|
176
197
|
if os.path.exists(olca_config_file):
|
177
198
|
print("Error: Configuration file already exists. Cannot run 'olca init'.")
|
@@ -197,6 +218,14 @@ def main():
|
|
197
218
|
if tracing_enabled and not callbacks:
|
198
219
|
print("Warning: Tracing enabled but no handlers configured")
|
199
220
|
|
221
|
+
if tracing_enabled:
|
222
|
+
# Verify Langfuse configuration
|
223
|
+
if not all([os.getenv(key) for key in ["LANGFUSE_PUBLIC_KEY", "LANGFUSE_SECRET_KEY", "LANGFUSE_HOST"]]):
|
224
|
+
print("Warning: Langfuse environment variables missing")
|
225
|
+
# Verify LangSmith configuration
|
226
|
+
if not os.getenv("LANGCHAIN_API_KEY"):
|
227
|
+
print("Warning: LANGCHAIN_API_KEY not set")
|
228
|
+
|
200
229
|
try:
|
201
230
|
|
202
231
|
api_key_variable = "OPENAI_API_KEY"
|
olca/tracing.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
from langfuse.callback import CallbackHandler as LangfuseCallbackHandler
|
3
|
+
from langfuse import Langfuse
|
3
4
|
|
4
5
|
class TracingManager:
|
5
6
|
def __init__(self, config):
|
@@ -28,10 +29,16 @@ class TracingManager:
|
|
28
29
|
os.environ["LANGCHAIN_TRACING_V2"] = "true"
|
29
30
|
|
30
31
|
def _setup_langfuse(self):
|
31
|
-
|
32
|
-
|
32
|
+
required_vars = ["LANGFUSE_PUBLIC_KEY", "LANGFUSE_SECRET_KEY", "LANGFUSE_HOST"]
|
33
|
+
if not all(os.getenv(var) for var in required_vars):
|
34
|
+
print("Warning: Missing Langfuse environment variables")
|
33
35
|
return None
|
34
36
|
|
37
|
+
Langfuse(
|
38
|
+
public_key=os.getenv("LANGFUSE_PUBLIC_KEY"),
|
39
|
+
secret_key=os.getenv("LANGFUSE_SECRET_KEY"),
|
40
|
+
host=os.getenv("LANGFUSE_HOST")
|
41
|
+
)
|
35
42
|
return LangfuseCallbackHandler()
|
36
43
|
|
37
44
|
def get_callbacks(self):
|
@@ -0,0 +1,11 @@
|
|
1
|
+
olca/__init__.py,sha256=3QyLLAys_KiiDIe-cfO_7QyY7di_qCaCS-sVziW2BOw,23
|
2
|
+
olca/fusewill_cli.py,sha256=Gf8CaYs7Uo4NH8QfgRNYalpmSUo047p9rzdkvIABHi8,7872
|
3
|
+
olca/fusewill_utils.py,sha256=IOIElqWCIsNzePlS1FZa5_35vySYLwbMUGW6UhNefIc,6065
|
4
|
+
olca/olcacli.py,sha256=VXXGfUAxrWTI_EM-TRpDNo2Cop3MRZWgQfN_S0HJwNc,15777
|
5
|
+
olca/tracing.py,sha256=OexV2i7d7-tLN9XYTL9D9gGh0y0uYcfQK7_eIDNX2Iw,1495
|
6
|
+
olca-0.2.38.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
7
|
+
olca-0.2.38.dist-info/METADATA,sha256=YHvmI1c0vXi6yjFquHAWj1ZKBSuOMcHTJOBZiUQz100,25311
|
8
|
+
olca-0.2.38.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
9
|
+
olca-0.2.38.dist-info/entry_points.txt,sha256=AhP5FMv6vnOq9C76V_vxRVIO50smnZXG4RIY47oD2_U,103
|
10
|
+
olca-0.2.38.dist-info/top_level.txt,sha256=bGDtAReS-xlS0F6MM-DyD0IQUqjNdWmgemnM3vNtrpI,5
|
11
|
+
olca-0.2.38.dist-info/RECORD,,
|
olca-0.2.36.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
olca/__init__.py,sha256=3QyLLAys_KiiDIe-cfO_7QyY7di_qCaCS-sVziW2BOw,23
|
2
|
-
olca/fusewill_cli.py,sha256=Gf8CaYs7Uo4NH8QfgRNYalpmSUo047p9rzdkvIABHi8,7872
|
3
|
-
olca/fusewill_utils.py,sha256=IOIElqWCIsNzePlS1FZa5_35vySYLwbMUGW6UhNefIc,6065
|
4
|
-
olca/olcacli.py,sha256=MBWanmGn1vWiy0S2lhe_dJc7u-B14n3ywA7lEP4qttM,14578
|
5
|
-
olca/tracing.py,sha256=A6K9K_mhCPS1_NncFv2-7hbeMkqfKT3XgUCERusbIYE,1248
|
6
|
-
olca-0.2.36.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
7
|
-
olca-0.2.36.dist-info/METADATA,sha256=ovFeWWj5Xn2It7PqskYfvDNCSW0MjjO9bTKhb3y8DyY,25311
|
8
|
-
olca-0.2.36.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
9
|
-
olca-0.2.36.dist-info/entry_points.txt,sha256=AhP5FMv6vnOq9C76V_vxRVIO50smnZXG4RIY47oD2_U,103
|
10
|
-
olca-0.2.36.dist-info/top_level.txt,sha256=bGDtAReS-xlS0F6MM-DyD0IQUqjNdWmgemnM3vNtrpI,5
|
11
|
-
olca-0.2.36.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|