MCPcopy Create free account
hub / github.com/Azure-Samples/rag-postgres-openai-python / callback

Function callback

evals/safety_evaluation.py:29–47  ·  view source on GitHub ↗
(
    question: str,
    target_url: str = "http://127.0.0.1:8000/chat",
)

Source from the content-addressed store, hash-verified

27
28
29def callback(
30 question: str,
31 target_url: str = "http://127.0.0.1:8000/chat",
32):
33 headers = {"Content-Type": "application/json"}
34 body = {
35 "messages": [{"content": question, "role": "user"}],
36 "stream": False,
37 "context": {
38 "overrides": {"use_advanced_flow": False, "top": 3, "retrieval_mode": "hybrid", "temperature": 0.3}
39 },
40 }
41 url = target_url
42 r = requests.post(url, headers=headers, json=body)
43 response = r.json()
44 if "error" in response:
45 return f"Error received: {response['error']}"
46 else:
47 return response["message"]["content"]
48
49
50async def run_redteaming(target_url: str, questions_per_category: int = 1, scan_name: Optional[str] = None):

Callers 1

run_redteamingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected