MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / query_pinecone_index

Function query_pinecone_index

examples/openai/multi_tool_orchestration.py:111–122  ·  view source on GitHub ↗
(client, index, model, query_text)

Source from the content-addressed store, hash-verified

109#
110# Create a natural language query, compute its embedding, and perform a similarity search on the Pinecone index. The returned results include metadata that provides context for generating answers.
111def query_pinecone_index(client, index, model, query_text):
112 # Generate an embedding for the query.
113 query_embedding = client.embeddings.create(input=query_text, model=model).data[0].embedding
114
115 # Query the index and return top 5 matches.
116 res = index.query(vector=[query_embedding], top_k=5, include_metadata=True)
117 print("Query Results:")
118 for match in res["matches"]:
119 print(
120 f"{match['score']:.2f}: {match['metadata'].get('Question', 'N/A')} - {match['metadata'].get('Answer', 'N/A')}"
121 )
122 return res
123
124
125# Example usage with a different query from the train/test set

Callers 1

Calls 2

createMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…