(message, function_calls=[], model="gpt-4o")
| 6 | |
| 7 | |
| 8 | def create_mock_response(message, function_calls=[], model="gpt-4o"): |
| 9 | role = message.get("role", "assistant") |
| 10 | content = message.get("content", "") |
| 11 | tool_calls = ( |
| 12 | [ |
| 13 | ChatCompletionMessageToolCall( |
| 14 | id="mock_tc_id", |
| 15 | type="function", |
| 16 | function=Function( |
| 17 | name=call.get("name", ""), |
| 18 | arguments=json.dumps(call.get("args", {})), |
| 19 | ), |
| 20 | ) |
| 21 | for call in function_calls |
| 22 | ] |
| 23 | if function_calls |
| 24 | else None |
| 25 | ) |
| 26 | |
| 27 | return ChatCompletion( |
| 28 | id="mock_cc_id", |
| 29 | created=1234567890, |
| 30 | model=model, |
| 31 | object="chat.completion", |
| 32 | choices=[ |
| 33 | Choice( |
| 34 | message=ChatCompletionMessage( |
| 35 | role=role, content=content, tool_calls=tool_calls |
| 36 | ), |
| 37 | finish_reason="stop", |
| 38 | index=0, |
| 39 | ) |
| 40 | ], |
| 41 | ) |
| 42 | |
| 43 | |
| 44 | class MockOpenAIClient: |
no outgoing calls
searching dependent graphs…