Last active
July 30, 2025 17:27
-
-
Save cagataycali/2e225c34bab488eb560e31a0aae2cea1 to your computer and use it in GitHub Desktop.
Strands Agents with Qwen:30b - Telemetry enabled with Langfuse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import base64 | |
from strands import Agent | |
from strands.models.ollama import OllamaModel | |
from strands.telemetry import StrandsTelemetry | |
from strands_tools import shell, editor | |
os.environ["STRANDS_TOOL_CONSOLE_MODE"] = "enabled" | |
def setup_otel() -> None: | |
"""Setup OpenTelemetry if configured.""" | |
otel_host = os.environ.get("LANGFUSE_HOST") | |
if otel_host: | |
public_key = os.environ.get("LANGFUSE_PUBLIC_KEY", "") | |
secret_key = os.environ.get("LANGFUSE_SECRET_KEY", "") | |
if public_key and secret_key: | |
auth_token = base64.b64encode( | |
f"{public_key}:{secret_key}".encode() | |
).decode() | |
otel_endpoint = f"{otel_host}/api/public/otel" | |
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = otel_endpoint | |
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = ( | |
f"Authorization=Basic {auth_token}" | |
) | |
strands_telemetry = StrandsTelemetry() | |
strands_telemetry.setup_otlp_exporter() | |
setup_otel() | |
# Create an Ollama model instance | |
ollama_model = OllamaModel( | |
host="http://localhost:11434", | |
model_id="qwen3:8b" | |
) | |
agent = Agent( | |
model=ollama_model, | |
load_tools_from_directory=True, | |
tools=[shell, editor], | |
) | |
if __name__ == "__main__": | |
while True: | |
q = input("\n> ") | |
if q.lower() == "exit": | |
print("\nGoodbye! 👋") | |
break | |
agent(q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment