ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import threading
|
||||
import flask
|
||||
from aworld.trace.instrumentation.flask import instrument_flask
|
||||
from aworld.trace.instrumentation.requests import instrument_requests
|
||||
from aworld.logs.util import logger, trace_logger
|
||||
import aworld.trace as trace
|
||||
import os
|
||||
from aworld.trace.config import ObservabilityConfig
|
||||
|
||||
os.environ["MONITOR_SERVICE_NAME"] = "otlp_example"
|
||||
os.environ["ANT_OTEL_ENDPOINT"] = "https://antcollector.alipay.com/namespace/aworld/task/aworld/otlp/api/v1/metrics"
|
||||
|
||||
trace.configure(ObservabilityConfig(
|
||||
metrics_provider="otlp",
|
||||
metrics_backend="antmonitor"
|
||||
))
|
||||
instrument_flask()
|
||||
instrument_requests()
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/api/test')
|
||||
def test():
|
||||
return 'Hello, World!'
|
||||
|
||||
|
||||
def invoke_api():
|
||||
import requests
|
||||
response = requests.get('http://localhost:7070/api/test')
|
||||
logger.info(f"invoke_api response={response.text}")
|
||||
|
||||
|
||||
def main():
|
||||
logger.info("main running")
|
||||
with trace.span("test_flask") as span:
|
||||
trace_logger.info("start invoke_api")
|
||||
invoke_api()
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# thread = threading.Thread(target=lambda: app.run(port=7070), daemon=True)
|
||||
# thread.start()
|
||||
# main()
|
||||
# thread.join()
|
||||
Reference in New Issue
Block a user