alarv commited on
Commit
cb0c01b
·
1 Parent(s): 6e330b3

fix: hardcode versions so they work properly for ever

Browse files
Files changed (3) hide show
  1. CLAUDE.md +42 -11
  2. app.py +20 -9
  3. requirements.txt +8 -8
CLAUDE.md CHANGED
@@ -21,24 +21,55 @@ QSARion is a chemical agent application built to predict molecular properties gi
21
 
22
  ### Key Dependencies
23
 
24
- - **smolagents**: Core agent framework for multi-step reasoning
25
- - **jaqpot-python-sdk**: QSAR modeling and prediction capabilities
26
- - **gradio**: Web interface framework
27
- - **pubchempy**: Chemical compound data retrieval
28
- - **rdkit**: Chemical informatics toolkit
29
- - **opentelemetry**: Observability and tracing (Langfuse integration)
 
30
 
31
- ## Development Commands
32
 
33
- ### Running the Application
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ```bash
36
- # Install dependencies
37
  pip install -r requirements.txt
38
-
39
- # Run the main application
40
  python app.py
41
  ```
 
42
 
43
  ### Key Configuration
44
 
 
21
 
22
  ### Key Dependencies
23
 
24
+ - **smolagents==1.9.2**: Core agent framework for multi-step reasoning
25
+ - **jaqpot-python-sdk==6.1.0**: QSAR modeling and prediction capabilities
26
+ - **gradio**: Web interface framework (installed via smolagents)
27
+ - **pubchempy==1.0.4**: Chemical compound data retrieval
28
+ - **rdkit==2024.3.3**: Chemical informatics toolkit
29
+ - **opentelemetry==1.24.0**: Observability and tracing (Langfuse integration)
30
+ - **openinference-instrumentation-smolagents==2.0.2**: Compatible instrumentation for smolagents
31
 
32
+ **Important**: All versions are pinned to ensure compatibility. The OpenTelemetry instrumentation requires specific version combinations to work with smolagents.
33
 
34
+ ## Deployment (Hugging Face Spaces)
35
 
36
+ This application runs on Hugging Face Spaces using the configuration in `README.md` header:
37
+ - **Runtime**: Python 3.11
38
+ - **Framework**: Gradio 5.32.1
39
+ - **Entry point**: `app.py`
40
+
41
+ ### Version Management
42
+
43
+ All dependencies in `requirements.txt` are pinned to prevent compatibility issues in the HF Spaces environment:
44
+ - OpenTelemetry instrumentation requires specific smolagents version compatibility
45
+ - RDKit versions affect molecular property calculations
46
+ - Pinned versions ensure consistent behavior across Space rebuilds
47
+
48
+ ### Space Configuration
49
+
50
+ Environment variables required:
51
+ - `LANGFUSE_PUBLIC_KEY`: For OpenTelemetry tracing
52
+ - `LANGFUSE_SECRET_KEY`: For OpenTelemetry tracing
53
+
54
+ ### Common Issues
55
+
56
+ 1. **Space startup fails with OpenTelemetry errors:**
57
+ - Application includes error handling to continue without tracing
58
+ - Check Space logs for "✓ OpenTelemetry instrumentation successfully enabled" or warning messages
59
+
60
+ 2. **Agent fails on simple molecules (e.g., ethane):**
61
+ - PubChem API connectivity issues
62
+ - QSAR model availability varies by compound type
63
+ - Agent should retry with different approaches automatically
64
+
65
+ ### Local Development
66
+
67
+ If forking for local development:
68
  ```bash
 
69
  pip install -r requirements.txt
 
 
70
  python app.py
71
  ```
72
+ Ensure environment variables `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` are set for tracing.
73
 
74
  ### Key Configuration
75
 
app.py CHANGED
@@ -17,16 +17,27 @@ LANGFUSE_AUTH=base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".en
17
  os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
18
  os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
19
 
20
- from opentelemetry.sdk.trace import TracerProvider
 
 
 
 
 
21
 
22
- from openinference.instrumentation.smolagents import SmolagentsInstrumentor
23
- from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
24
- from opentelemetry.sdk.trace.export import SimpleSpanProcessor
25
-
26
- trace_provider = TracerProvider()
27
- trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
28
-
29
- SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
 
 
 
 
 
 
30
 
31
  jaqpot = JaqpotApiClient()
32
 
 
17
  os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # EU data region
18
  os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
19
 
20
+ # OpenTelemetry tracing setup with error handling
21
+ try:
22
+ from opentelemetry.sdk.trace import TracerProvider
23
+ from openinference.instrumentation.smolagents import SmolagentsInstrumentor
24
+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
25
+ from opentelemetry.sdk.trace.export import SimpleSpanProcessor
26
 
27
+ trace_provider = TracerProvider()
28
+ trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))
29
+
30
+ # Try to instrument smolagents, but continue if it fails
31
+ try:
32
+ SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
33
+ print("✓ OpenTelemetry instrumentation successfully enabled")
34
+ except (AttributeError, ImportError) as e:
35
+ print(f"⚠️ OpenTelemetry instrumentation failed: {e}")
36
+ print("ℹ️ Continuing without instrumentation...")
37
+
38
+ except ImportError as e:
39
+ print(f"⚠️ OpenTelemetry packages not available: {e}")
40
+ print("ℹ️ Continuing without tracing...")
41
 
42
  jaqpot = JaqpotApiClient()
43
 
requirements.txt CHANGED
@@ -1,11 +1,11 @@
1
- markdownify
2
  smolagents==1.9.2
3
  smolagents[openai]
4
- pandas
5
  jaqpot-python-sdk==6.1.0
6
- opentelemetry-sdk
7
- opentelemetry-exporter-otlp
8
- openinference-instrumentation-smolagents
9
- rdkit
10
- pubchempy
11
- duckduckgo-search
 
1
+ markdownify==2.12.1
2
  smolagents==1.9.2
3
  smolagents[openai]
4
+ pandas==2.2.2
5
  jaqpot-python-sdk==6.1.0
6
+ opentelemetry-sdk==1.24.0
7
+ opentelemetry-exporter-otlp==1.24.0
8
+ openinference-instrumentation-smolagents==2.0.2
9
+ rdkit==2024.3.3
10
+ pubchempy==1.0.4
11
+ duckduckgo-search==6.2.13