MCPcopy Create free account
hub / github.com/agentset-ai/agentset / pythonExample

Function pythonExample

apps/web/src/lib/code-examples/playground.ts:53–86  ·  view source on GitHub ↗
(apiKey?: string)

Source from the content-addressed store, hash-verified

51});
52console.log(result);
53`;
54
55export const pythonExample = (apiKey?: string) => /* python */ `
56from agentset import Agentset
57from openai import OpenAI
58
59client = Agentset(
60 namespace_id="{{namespace}}",
61 token="${apiKey ?? "YOUR_API_KEY"}",${pythonSdkApiUrlOption}
62)
63
64openai = OpenAI()
65
66query = "What are the key findings?"
67
68# Search for relevant context
69results = client.search.execute(query=query)
70context = "\\n\\n".join([r.text for r in results.data])
71
72# Generate a response
73response = openai.responses.create(
74 model="gpt-4.1",
75 input=[
76 {
77 "role": "system",
78 "content": f"Answer questions based on the following context:\n\n{context}",
79 },
80 {
81 "role": "user",
82 "content": query,
83 },
84 ],
85)
86
87print(response)
88`;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected