File tree Expand file tree Collapse file tree 3 files changed +5
-10
lines changed
Expand file tree Collapse file tree 3 files changed +5
-10
lines changed Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- import logging
1615import google .auth
1716import google .auth .transport .requests
1817import grpc
@@ -97,19 +96,20 @@ def setup_opentelemetry() -> None:
9796
9897 # Load instrumentors
9998 SQLite3Instrumentor ().instrument ()
99+ # ADK uses Vertex AI and Google Gen AI SDKs.
100100 VertexAIInstrumentor ().instrument ()
101101 GoogleGenAiSdkInstrumentor ().instrument ()
102102
103103
104104# [END opentelemetry_adk_otel_setup]
105105
106-
106+ # [START opentelemetry_adk_launch_web_interface]
107107def main () -> None :
108108 # Make sure to set:
109109 # OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
110110 # OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
111111 # in order to full prompts and responses and logs messages.
112- # For this sample, these can be set by loading the `main .env` file.
112+ # For this sample, these can be set by loading the `opentelemetry .env` file.
113113 setup_opentelemetry ()
114114
115115 # Call the function to get the FastAPI app instance.
@@ -125,7 +125,9 @@ def main() -> None:
125125 web = SERVE_WEB_INTERFACE ,
126126 )
127127
128+ # Lauch the web interface on port 8080.
128129 uvicorn .run (app , host = "0.0.0.0" , port = int (os .environ .get ("PORT" , 8080 )))
130+ # [END opentelemetry_adk_launch_web_interface]
129131
130132
131133if __name__ == "__main__" :
Original file line number Diff line number Diff line change 1717
1818import sqlite3
1919
20- from opentelemetry import trace
21-
22- # from utils import ask_prompt, console, print_markdown, render_messages
23-
24-
2520SYSTEM_PROMPT = f"""\
2621 You are a helpful AI assistant with a mastery of database design and querying. You have access
2722to an ephemeral sqlite3 database that you can query and modify through some tools. Help answer
Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ class SqlRunResult(TypedDict):
3333 rows : NotRequired [list [tuple [str , ...]]]
3434 """The rows returned by the SQL query"""
3535
36- @tracer .start_as_current_span ("create_database" )
3736def create_database_tool (tool_context : ToolContext ) -> dict [str , Any ]:
3837 """Creates a temporary file in the /tmp directory to hold an ephemeral
3938 sqlite3 database if a database is not found for the current session.
@@ -47,7 +46,6 @@ def create_database_tool(tool_context: ToolContext) -> dict[str, Any]:
4746 return {"resp" : "Created an ephemeral database" }
4847 return {"resp" : f"Skipping database creation, { tool_context .state [SESSION_DB_KEY ]} already exists" }
4948
50- @tracer .start_as_current_span ("run_sql" )
5149def run_sql_tool (sql_query : str , tool_context : ToolContext ) -> dict [str , Any ]:
5250 """Runs a SQLite query. The SQL query can be DDL or DML. Returns the rows if it's a SELECT query."""
5351 current_session_db_path = tool_context .state .get (SESSION_DB_KEY )
You can’t perform that action at this time.
0 commit comments