diff --git a/tests/pipeline/cassettes/test_pipeline_process_streams_single_input_pydantic_output.yaml b/tests/pipeline/cassettes/test_pipeline_process_streams_single_input_pydantic_output.yaml new file mode 100644 index 000000000..e40d7f058 --- /dev/null +++ b/tests/pipeline/cassettes/test_pipeline_process_streams_single_input_pydantic_output.yaml @@ -0,0 +1,163 @@ +interactions: +- request: + body: '{"messages": [{"content": "You are Mock Role. Mock Backstory\nYour personal + goal is: Mock GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uKW9xFsa6Ib8K87cY8De4agMoe8A","object":"chat.completion.chunk","created":1723212265,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b084b8fcd7f2aad-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 14:04:25 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=oxCbFZSGsVbRMNF7Ropntit_j6RkFrrYepSheJNSdR4-1723212265-1.0.1.1-BWjFhFaF3HTur21PTi4rF4nxQaOgeq_Mf9WOgMy7pqvFZZf9B.Ke_es1wk5qMDpnPzWYXyqOx2.LDx.6xwXGHg; + path=/; expires=Fri, 09-Aug-24 14:34:25 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=bQz8n1LEJhVzFyHMDG.NgJqwk0MJYiPxkg2WKd9hIik-1723212265235-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '79' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_556426f83d0ac63c40f2c70967c53378 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/pipeline/cassettes/test_pipeline_with_multiple_routers.yaml b/tests/pipeline/cassettes/test_pipeline_with_multiple_routers.yaml new file mode 100644 index 000000000..6e5a5f5c0 --- /dev/null +++ b/tests/pipeline/cassettes/test_pipeline_with_multiple_routers.yaml @@ -0,0 +1,479 @@ +interactions: +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwTfhUMqHkuIXfpNrPbBofqX25q","object":"chat.completion.chunk","created":1723217741,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08d1456dfb08f2-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:35:41 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=VXBO9XCMNYUdWJMLzmhZVwYp2qBnn27YLCV.iO5jdSQ-1723217741-1.0.1.1-WncSUA42bMTHs6l3gv46MmHUnPqrizRLmh23xZWc6q8udphMGhUhkXwHxRrSf4xCMCXXXvO6JC826sh6mNnehA; + path=/; expires=Fri, 09-Aug-24 16:05:41 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=bd8N16RsuXKEtaAf_S1XEK.0LZqbsndFJNK2Lvr7nYs-1723217741960-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '87' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_74f5a4e0520f918cfd2c8d8d7f50cb7b + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + cookie: + - __cf_bm=VXBO9XCMNYUdWJMLzmhZVwYp2qBnn27YLCV.iO5jdSQ-1723217741-1.0.1.1-WncSUA42bMTHs6l3gv46MmHUnPqrizRLmh23xZWc6q8udphMGhUhkXwHxRrSf4xCMCXXXvO6JC826sh6mNnehA; + _cfuvid=bd8N16RsuXKEtaAf_S1XEK.0LZqbsndFJNK2Lvr7nYs-1723217741960-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUeI2Ax7m14tF5viOieTyMyyoT","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_c9aa9c0491","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08d1496c1308f2-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:35:42 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '123' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_7602c65d59ddaaae4a6cb92952636b53 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + cookie: + - __cf_bm=VXBO9XCMNYUdWJMLzmhZVwYp2qBnn27YLCV.iO5jdSQ-1723217741-1.0.1.1-WncSUA42bMTHs6l3gv46MmHUnPqrizRLmh23xZWc6q8udphMGhUhkXwHxRrSf4xCMCXXXvO6JC826sh6mNnehA; + _cfuvid=bd8N16RsuXKEtaAf_S1XEK.0LZqbsndFJNK2Lvr7nYs-1723217741960-0.0.1.1-604800000 + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLwUgFxqI5ZynZsF4IjfMfLOOVVL","object":"chat.completion.chunk","created":1723217742,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08d14c38b708f2-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:35:42 GMT + Server: + - cloudflare + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '98' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_2312eeb6632e09efcd03bd2e212d242d + status: + code: 200 + message: OK +version: 1 diff --git a/tests/pipeline/cassettes/test_pipeline_with_router.yaml b/tests/pipeline/cassettes/test_pipeline_with_router.yaml new file mode 100644 index 000000000..0c5033f49 --- /dev/null +++ b/tests/pipeline/cassettes/test_pipeline_with_router.yaml @@ -0,0 +1,163 @@ +interactions: +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLh5NS9xxPoraNNjd3gSUi2Fufab","object":"chat.completion.chunk","created":1723216787,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08b9fbab0d7e76-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:19:48 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=Ok33IBBKZR0e3d8fZD5DZf5ZOL.Qx6NWCCcNC8ws7eA-1723216788-1.0.1.1-oYl6wzOQJ7YhoLjLgqAQFoC2DfM8wGFMe3dUTAKd0r3odwGsPS4y6QQKYfat0RxpOyErx_iDD25ZBdN0NtXOMA; + path=/; expires=Fri, 09-Aug-24 15:49:48 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=OO1MACceu3Jjuq5WdFsXX6LcFGp8AsdvZtVlVaIFspg-1723216788116-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '127' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_c427ee9954f36d4e5efebf821bc4981e + status: + code: 200 + message: OK +version: 1 diff --git a/tests/pipeline/cassettes/test_router_with_empty_input.yaml b/tests/pipeline/cassettes/test_router_with_empty_input.yaml new file mode 100644 index 000000000..1091c4ba8 --- /dev/null +++ b/tests/pipeline/cassettes/test_router_with_empty_input.yaml @@ -0,0 +1,163 @@ +interactions: +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uM4CheR93UVORWzMVtwfViezobOD","object":"chat.completion.chunk","created":1723218220,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08dcf819760fb7-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:43:41 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=saQ_eM9u1PmBfQRG1jTfrvAKarBMyii_YCKH3FykFK4-1723218221-1.0.1.1-vRk7EtdUPVTK.HPVpyGPsu7x2eDxYzwbGwSiVxoOKaaRlunWxPTMzNLRoX6qPOevFnUamxpkPJewlKmn8UhVAA; + path=/; expires=Fri, 09-Aug-24 16:13:41 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=uqsYHaOZpg_WhpwNfvP.nPWqew9tn.d2OFbP0zPu.AQ-1723218221175-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '126' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_27740c683ef0ce74d4ebdc7db3394b80 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/pipeline/cassettes/test_router_with_multiple_inputs.yaml b/tests/pipeline/cassettes/test_router_with_multiple_inputs.yaml new file mode 100644 index 000000000..5761be411 --- /dev/null +++ b/tests/pipeline/cassettes/test_router_with_multiple_inputs.yaml @@ -0,0 +1,485 @@ +interactions: +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG38aPebYIjXywvamVsV7cdhoA","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08cc6588637cd4-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:32:22 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=M4up.JtFpyEgsdfTC6p_PCuqpf1awZrIU7O4maUmvcc-1723217542-1.0.1.1-pHndpcggWD247VW0oQyVdkNn9_78MKa58Br4436XxAO_2OB0snYblbzsZMPvIaLfEXJe51XqwSKsNDW.DW9OWA; + path=/; expires=Fri, 09-Aug-24 16:02:22 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=tCayjNZ3JhkjI0BUvmaFdzdvxjApNr5qo93qUN7v.FY-1723217542310-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '75' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_2dbbb252efe10800521717ee0f07709a + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtGVW8T1OV0Tld9mR1Yl981v5RI","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08cc658eae14f2-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:32:22 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=Creh.MQMh5D4uV8gMWrmEP3U_xYEycFVgWVxxn0kHlE-1723217542-1.0.1.1-J_gmaciM9fSi6r8l4UAzTm.I2IKLzR17wmi09h8_yI6k3LD_nHjgALB6hys0HApKUntVCQVmZig2J5bBVCboBQ; + path=/; expires=Fri, 09-Aug-24 16:02:22 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=zSXGyUBaieLtzC9vciAfldh0f8XOr_yG7xEkAiy72z0-1723217542314-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '96' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9998' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_0ede16e7bce60442ed70741e03da5ec5 + status: + code: 200 + message: OK +- request: + body: '{"messages": [{"content": "You are Test Role. Test Backstory\nYour personal + goal is: Test GoalTo give my best complete final answer to the task use the + exact following format:\n\nThought: I now can give a great answer\nFinal Answer: + my best complete final answer to the task.\nYour final answer must be the great + and the most complete as possible, it must be outcome described.\n\nI MUST use + these formats, my job depends on it!\nCurrent Task: Return: Test output\n\nThis + is the expect criteria for your final answer: Test output \n you MUST return + the actual complete content as the final answer, not a summary.\n\nBegin! This + is VERY important to you, use the tools available and give your best Final Answer, + your job depends on it!\n\nThought:\n", "role": "user"}], "model": "gpt-4o", + "logprobs": false, "n": 1, "stop": ["\nObservation"], "stream": true, "temperature": + 0.7}' + headers: + accept: + - application/json + accept-encoding: + - gzip, deflate, br + connection: + - keep-alive + content-length: + - '877' + content-type: + - application/json + host: + - api.openai.com + user-agent: + - OpenAI/Python 1.37.0 + x-stainless-arch: + - arm64 + x-stainless-async: + - 'false' + x-stainless-lang: + - python + x-stainless-os: + - MacOS + x-stainless-package-version: + - 1.37.0 + x-stainless-runtime: + - CPython + x-stainless-runtime-version: + - 3.11.5 + method: POST + uri: https://api.openai.com/v1/chat/completions + response: + body: + string: 'data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Thought"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + I"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + now"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + can"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + give"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + a"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + great"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"\n"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":"Final"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Answer"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":":"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + Test"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{"content":" + output"},"logprobs":null,"finish_reason":null}]} + + + data: {"id":"chatcmpl-9uLtG17RAkTmMGMwaaU6ljV8N8PzN","object":"chat.completion.chunk","created":1723217542,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_3aa7262c27","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]} + + + data: [DONE] + + + ' + headers: + CF-Cache-Status: + - DYNAMIC + CF-RAY: + - 8b08cc658e2829c9-LAX + Connection: + - keep-alive + Content-Type: + - text/event-stream; charset=utf-8 + Date: + - Fri, 09 Aug 2024 15:32:22 GMT + Server: + - cloudflare + Set-Cookie: + - __cf_bm=juF2fptTmZAWU14Lw6_CYL4oseJBYYRglgYx8coLilQ-1723217542-1.0.1.1-NRcTnXs5yz0cX7hllCCcuNuqACPtm1aX_VAub6GReR.eBkJKV.HcA3cFiavaBK5XCrE4z04jOev3UVboQpyQkw; + path=/; expires=Fri, 09-Aug-24 16:02:22 GMT; domain=.api.openai.com; HttpOnly; + Secure; SameSite=None + - _cfuvid=Mgsswdn3w9OMcS9r3KLgbo6Enbk9IQfmmtjOv5LmCgs-1723217542628-0.0.1.1-604800000; + path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + alt-svc: + - h3=":443"; ma=86400 + openai-organization: + - crewai-iuxna1 + openai-processing-ms: + - '116' + openai-version: + - '2020-10-01' + strict-transport-security: + - max-age=15552000; includeSubDomains; preload + x-ratelimit-limit-requests: + - '10000' + x-ratelimit-limit-tokens: + - '30000000' + x-ratelimit-remaining-requests: + - '9999' + x-ratelimit-remaining-tokens: + - '29999806' + x-ratelimit-reset-requests: + - 6ms + x-ratelimit-reset-tokens: + - 0s + x-request-id: + - req_d048537865c87387356c8da4971df278 + status: + code: 200 + message: OK +version: 1 diff --git a/tests/pipeline/test_pipeline.py b/tests/pipeline/test_pipeline.py index bead4f652..39f28ab86 100644 --- a/tests/pipeline/test_pipeline.py +++ b/tests/pipeline/test_pipeline.py @@ -1,5 +1,5 @@ import json -from unittest.mock import AsyncMock, MagicMock +from unittest.mock import AsyncMock, MagicMock, patch import pytest from crewai.agent import Agent @@ -45,12 +45,8 @@ def mock_crew_factory(): ) async def async_kickoff(inputs=None): - print("inputs in async_kickoff", inputs) return crew_output - # Create an AsyncMock for kickoff_async - crew.kickoff_async = AsyncMock(side_effect=async_kickoff) - # Add more attributes that Procedure might be expecting crew.verbose = False crew.output_log_file = None @@ -60,16 +56,30 @@ def mock_crew_factory(): crew.config = None crew.cache = True - # Add non-empty agents and tasks - mock_agent = MagicMock(spec=Agent) - mock_task = MagicMock(spec=Task) - mock_task.agent = mock_agent - mock_task.async_execution = False - mock_task.context = None + # # Create a valid Agent instance + mock_agent = Agent( + name="Mock Agent", + role="Mock Role", + goal="Mock Goal", + backstory="Mock Backstory", + allow_delegation=False, + verbose=False, + ) + + # Create a valid Task instance + mock_task = Task( + description="Return: Test output", + expected_output="Test output", + agent=mock_agent, + async_execution=False, + context=None, + ) crew.agents = [mock_agent] crew.tasks = [mock_task] + crew.kickoff_async = AsyncMock(side_effect=async_kickoff) + return crew return _create_mock_crew @@ -89,8 +99,6 @@ def mock_router_factory(mock_crew_factory): result = MockRouterClass() result.route = self.route return result - - mock_router = MockRouter() mock_router.route = MagicMock( @@ -107,7 +115,9 @@ def mock_router_factory(mock_crew_factory): ( "route1" if x.get("score", 0) > 80 - else "route2" if x.get("score", 0) > 50 else "default" + else "route2" + if x.get("score", 0) > 50 + else "default" ), ) ) @@ -146,44 +156,108 @@ async def test_pipeline_with_empty_input(mock_crew_factory): ), "Pipeline should return empty results for empty input" +agent = Agent( + role="Test Role", + goal="Test Goal", + backstory="Test Backstory", + allow_delegation=False, + verbose=False, +) +task = Task( + description="Return: Test output", + expected_output="Test output", + agent=agent, + async_execution=False, + context=None, +) + + @pytest.mark.asyncio -async def test_pipeline_process_streams_single_input(mock_crew_factory): +async def test_pipeline_process_streams_single_input(): """ Test that Pipeline.process_streams() correctly processes a single input and returns the expected CrewOutput. """ crew_name = "Test Crew" - mock_crew = mock_crew_factory(name="Test Crew") + mock_crew = Crew( + agents=[agent], + tasks=[task], + process=Process.sequential, + ) + mock_crew.name = crew_name pipeline = Pipeline(stages=[mock_crew]) input_data = [{"key": "value"}] - pipeline_results = await pipeline.kickoff(input_data) + with patch.object(Crew, "kickoff_async") as mock_kickoff: + task_output = TaskOutput( + description="Test task", raw="Task output", agent="Test Agent" + ) + mock_kickoff.return_value = CrewOutput( + raw="Test output", + tasks_output=[task_output], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict=None, + pydantic=None, + ) + pipeline_results = await pipeline.kickoff(input_data) + mock_crew.kickoff_async.assert_called_once_with(inputs={"key": "value"}) - mock_crew.kickoff_async.assert_called_once_with(inputs={"key": "value"}) - - for pipeline_result in pipeline_results: - assert isinstance(pipeline_result, PipelineKickoffResult) - assert pipeline_result.raw == "Test output" - assert len(pipeline_result.crews_outputs) == 1 - print("pipeline_result.token_usage", pipeline_result.token_usage) - assert pipeline_result.token_usage == {crew_name: DEFAULT_TOKEN_USAGE} - assert pipeline_result.trace == [input_data[0], "Test Crew"] + for pipeline_result in pipeline_results: + assert isinstance(pipeline_result, PipelineKickoffResult) + assert pipeline_result.raw == "Test output" + assert len(pipeline_result.crews_outputs) == 1 + assert pipeline_result.token_usage == {crew_name: DEFAULT_TOKEN_USAGE} + assert pipeline_result.trace == [input_data[0], "Test Crew"] @pytest.mark.asyncio -async def test_pipeline_result_ordering(mock_crew_factory): +async def test_pipeline_result_ordering(): """ Ensure that results are returned in the same order as the inputs, especially with parallel processing. """ - crew1 = mock_crew_factory(name="Crew 1", output_json_dict={"output": "crew1"}) - crew2 = mock_crew_factory(name="Crew 2", output_json_dict={"output": "crew2"}) - crew3 = mock_crew_factory(name="Crew 3", output_json_dict={"output": "crew3"}) + crew1 = Crew( + name="Crew 1", + agents=[agent], + tasks=[task], + ) + crew2 = Crew( + name="Crew 2", + agents=[agent], + tasks=[task], + ) + crew3 = Crew( + name="Crew 3", + agents=[agent], + tasks=[task], + ) pipeline = Pipeline( stages=[crew1, [crew2, crew3]] ) # Parallel stage to test ordering - input_data = [{"id": 1}, {"id": 2}, {"id": 3}] - pipeline_results = await pipeline.kickoff(input_data) + + def create_crew_output(crew_name): + return CrewOutput( + raw=f"Test output from {crew_name}", + tasks_output=[ + TaskOutput( + description="Test task", + raw=f"Task output from {crew_name}", + agent="Test Agent", + ) + ], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": crew_name.lower().replace(" ", "")}, + pydantic=None, + ) + + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.side_effect = [ + create_crew_output("Crew 1"), + create_crew_output("Crew 2"), + create_crew_output("Crew 3"), + ] * 3 + pipeline_results = await pipeline.kickoff(input_data) + mock_kickoff.call_count = 3 assert ( len(pipeline_results) == 6 @@ -217,12 +291,6 @@ async def test_pipeline_result_ordering(mock_crew_factory): "Crew 1", "Crew 3", ], f"Unexpected trace for second result of input {input_id}" - assert ( - group[0].json_dict["output"] == "crew2" - ), f"Unexpected output for first result of input {input_id}" - assert ( - group[1].json_dict["output"] == "crew3" - ), f"Unexpected output for second result of input {input_id}" class TestPydanticOutput(BaseModel): @@ -231,29 +299,60 @@ class TestPydanticOutput(BaseModel): @pytest.mark.asyncio -async def test_pipeline_process_streams_single_input_pydantic_output(mock_crew_factory): +@pytest.mark.vcr(filter_headers=["authorization"]) +async def test_pipeline_process_streams_single_input_pydantic_output(): crew_name = "Test Crew" - mock_crew = mock_crew_factory( - name=crew_name, - output_json_dict=None, - pydantic_output=TestPydanticOutput(key="test", value=42), + task = Task( + description="Return: Key:value", + expected_output="Key:Value", + agent=agent, + async_execution=False, + context=None, + output_pydantic=TestPydanticOutput, ) + mock_crew = Crew( + name=crew_name, + agents=[agent], + tasks=[task], + ) + pipeline = Pipeline(stages=[mock_crew]) input_data = [{"key": "value"}] - pipeline_results = await pipeline.kickoff(input_data) + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_crew_output = CrewOutput( + raw="Test output", + tasks_output=[ + TaskOutput( + description="Return: Key:value", raw="Key:Value", agent="Test Agent" + ) + ], + token_usage=UsageMetrics( + total_tokens=171, + prompt_tokens=154, + completion_tokens=17, + successful_requests=1, + ), + pydantic=TestPydanticOutput(key="test", value=42), + ) + mock_kickoff.return_value = mock_crew_output + pipeline_results = await pipeline.kickoff(input_data) assert len(pipeline_results) == 1 pipeline_result = pipeline_results[0] - print("pipeline_result.trace", pipeline_result.trace) - assert isinstance(pipeline_result, PipelineKickoffResult) assert pipeline_result.raw == "Test output" assert len(pipeline_result.crews_outputs) == 1 - assert pipeline_result.token_usage == {crew_name: DEFAULT_TOKEN_USAGE} - print("INPUT DATA POST PROCESS", input_data) - assert pipeline_result.trace == [input_data[0], "Test Crew"] + assert pipeline_result.token_usage == { + crew_name: UsageMetrics( + total_tokens=171, + prompt_tokens=154, + completion_tokens=17, + successful_requests=1, + ) + } + assert pipeline_result.trace == [input_data[0], "Test Crew"] assert isinstance(pipeline_result.pydantic, TestPydanticOutput) assert pipeline_result.pydantic.key == "test" assert pipeline_result.pydantic.value == 42 @@ -292,20 +391,32 @@ async def test_pipeline_preserves_original_input(mock_crew_factory): @pytest.mark.asyncio -async def test_pipeline_process_streams_multiple_inputs(mock_crew_factory): +async def test_pipeline_process_streams_multiple_inputs(): """ Test that Pipeline.process_streams() correctly processes multiple inputs and returns the expected CrewOutputs. """ - mock_crew = mock_crew_factory(name="Test Crew") + mock_crew = Crew(name="Test Crew", tasks=[task], agents=[agent]) pipeline = Pipeline(stages=[mock_crew]) input_data = [{"key1": "value1"}, {"key2": "value2"}] - pipeline_results = await pipeline.kickoff(input_data) - assert mock_crew.kickoff_async.call_count == 2 - assert len(pipeline_results) == 2 + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.return_value = CrewOutput( + raw="Test output", + tasks_output=[ + TaskOutput( + description="Test task", raw="Task output", agent="Test Agent" + ) + ], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict=None, + pydantic=None, + ) + pipeline_results = await pipeline.kickoff(input_data) + assert mock_kickoff.call_count == 2 + assert len(pipeline_results) == 2 + for pipeline_result in pipeline_results: - print("pipeline_result,", pipeline_result) assert all( isinstance(crew_output, CrewOutput) for crew_output in pipeline_result.crews_outputs @@ -313,20 +424,31 @@ async def test_pipeline_process_streams_multiple_inputs(mock_crew_factory): @pytest.mark.asyncio -async def test_pipeline_with_parallel_stages(mock_crew_factory): +async def test_pipeline_with_parallel_stages(): """ Test that Pipeline correctly handles parallel stages. """ - crew1 = mock_crew_factory(name="Crew 1") - crew2 = mock_crew_factory(name="Crew 2") - crew3 = mock_crew_factory(name="Crew 3") + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) + crew3 = Crew(name="Crew 3", tasks=[task], agents=[agent]) pipeline = Pipeline(stages=[crew1, [crew2, crew3]]) input_data = [{"initial": "data"}] - pipeline_result = await pipeline.kickoff(input_data) - - crew1.kickoff_async.assert_called_once_with(inputs={"initial": "data"}) + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.return_value = CrewOutput( + raw="Test output", + tasks_output=[ + TaskOutput( + description="Test task", raw="Task output", agent="Test Agent" + ) + ], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict=None, + pydantic=None, + ) + pipeline_result = await pipeline.kickoff(input_data) + mock_kickoff.assert_called_with(inputs={"initial": "data"}) assert len(pipeline_result) == 2 pipeline_result_1, pipeline_result_2 = pipeline_result @@ -355,17 +477,31 @@ async def test_pipeline_with_parallel_stages_end_in_single_stage(mock_crew_facto """ Test that Pipeline correctly handles parallel stages. """ - crew1 = mock_crew_factory(name="Crew 1") - crew2 = mock_crew_factory(name="Crew 2") - crew3 = mock_crew_factory(name="Crew 3") - crew4 = mock_crew_factory(name="Crew 4") + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) + crew3 = Crew(name="Crew 3", tasks=[task], agents=[agent]) + crew4 = Crew(name="Crew 4", tasks=[task], agents=[agent]) pipeline = Pipeline(stages=[crew1, [crew2, crew3], crew4]) input_data = [{"initial": "data"}] pipeline_result = await pipeline.kickoff(input_data) - crew1.kickoff_async.assert_called_once_with(inputs={"initial": "data"}) + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.return_value = CrewOutput( + raw="Test output", + tasks_output=[ + TaskOutput( + description="Test task", raw="Task output", agent="Test Agent" + ) + ], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict=None, + pydantic=None, + ) + pipeline_result = await pipeline.kickoff(input_data) + + mock_kickoff.assert_called_with(inputs={"initial": "data"}) assert len(pipeline_result) == 1 pipeline_result_1 = pipeline_result[0] @@ -403,7 +539,6 @@ def test_pipeline_rshift_operator(mock_crew_factory): # Test adding a list of crews pipeline = Pipeline(stages=[crew1]) pipeline = pipeline >> [crew2, crew3] - print("pipeline.stages:", pipeline.stages) assert len(pipeline.stages) == 2 assert pipeline.stages[1] == [crew2, crew3] @@ -413,27 +548,49 @@ def test_pipeline_rshift_operator(mock_crew_factory): @pytest.mark.asyncio -async def test_pipeline_parallel_crews_to_parallel_crews(mock_crew_factory): +@pytest.mark.vcr(filter_headers=["authorization"]) +async def test_pipeline_parallel_crews_to_parallel_crews(): """ Test that feeding parallel crews to parallel crews works correctly. """ - crew1 = mock_crew_factory(name="Crew 1", output_json_dict={"output1": "crew1"}) - crew2 = mock_crew_factory(name="Crew 2", output_json_dict={"output2": "crew2"}) - crew3 = mock_crew_factory(name="Crew 3", output_json_dict={"output3": "crew3"}) - crew4 = mock_crew_factory(name="Crew 4", output_json_dict={"output4": "crew4"}) - + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) + crew3 = Crew(name="Crew 3", tasks=[task], agents=[agent]) + crew4 = Crew(name="Crew 4", tasks=[task], agents=[agent]) + # output_json_dict={"output1": "crew1"} pipeline = Pipeline(stages=[[crew1, crew2], [crew3, crew4]]) input_data = [{"input": "test"}] - pipeline_results = await pipeline.kickoff(input_data) + + def create_crew_output(crew_name): + return CrewOutput( + raw=f"Test output from {crew_name}", + tasks_output=[ + TaskOutput( + description="Test task", + raw=f"Task output from {crew_name}", + agent="Test Agent", + ) + ], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": crew_name.lower().replace(" ", "")}, + pydantic=None, + ) + + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.side_effect = [ + create_crew_output(crew_name) + for crew_name in ["Crew 1", "Crew 2", "Crew 3", "Crew 4"] + ] + pipeline_results = await pipeline.kickoff(input_data) assert len(pipeline_results) == 2, "Should have 2 results for final parallel stage" pipeline_result_1, pipeline_result_2 = pipeline_results # Check the outputs - assert pipeline_result_1.json_dict == {"output3": "crew3"} - assert pipeline_result_2.json_dict == {"output4": "crew4"} + assert pipeline_result_1.json_dict == {"output": "crew3"} + assert pipeline_result_2.json_dict == {"output": "crew4"} # Check the traces expected_traces = [ @@ -458,7 +615,7 @@ def test_pipeline_double_nesting_not_allowed(mock_crew_factory): Pipeline(stages=[crew1, [[crew2, crew3], crew4]]) error_msg = str(exc_info.value) - print(f"Full error message: {error_msg}") # For debugging + assert ( "Double nesting is not allowed in pipeline stages" in error_msg ), f"Unexpected error message: {error_msg}" @@ -492,21 +649,33 @@ Options: @pytest.mark.asyncio -async def test_pipeline_data_accumulation(mock_crew_factory): - crew1 = mock_crew_factory(name="Crew 1", output_json_dict={"key1": "value1"}) - crew2 = mock_crew_factory(name="Crew 2", output_json_dict={"key2": "value2"}) +async def test_pipeline_data_accumulation(): + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) pipeline = Pipeline(stages=[crew1, crew2]) input_data = [{"initial": "data"}] results = await pipeline.kickoff(input_data) - # Check that crew1 was called with only the initial input - crew1.kickoff_async.assert_called_once_with(inputs={"initial": "data"}) + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.side_effect = [ + CrewOutput( + raw="Test output from Crew 1", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"key1": "value1"}, + pydantic=None, + ), + CrewOutput( + raw="Test output from Crew 2", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"key2": "value2"}, + pydantic=None, + ), + ] - # Check that crew2 was called with the combined input from the initial data and crew1's output - crew2.kickoff_async.assert_called_once_with( - inputs={"initial": "data", "key1": "value1"} - ) + results = await pipeline.kickoff(input_data) # Check the final output assert len(results) == 1 @@ -523,55 +692,134 @@ async def test_pipeline_data_accumulation(mock_crew_factory): @pytest.mark.asyncio -async def test_pipeline_with_router(mock_router_factory): - router = mock_router_factory() - +@pytest.mark.vcr(filter_headers=["authorization"]) +async def test_pipeline_with_router(): + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) + crew3 = Crew(name="Crew 3", tasks=[task], agents=[agent]) + routes = { + "route1": Route( + condition=lambda x: x.get("score", 0) > 80, + pipeline=Pipeline(stages=[crew1]), + ), + "route2": Route( + condition=lambda x: 50 < x.get("score", 0) <= 80, + pipeline=Pipeline(stages=[crew2]), + ), + } + router = Router( + routes=routes, + default=Pipeline(stages=[crew3]), + ) # Test high score route pipeline = Pipeline(stages=[router]) - result_high = await pipeline.kickoff([{"score": 90}]) - assert len(result_high) == 1 - assert result_high[0].json_dict is not None - assert result_high[0].json_dict["output"] == "crew1" - assert result_high[0].trace == [ - {"score": 90}, - {"route_taken": "route1"}, - "Crew 1", - ] + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.return_value = CrewOutput( + raw="Test output from Crew 1", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew1"}, + pydantic=None, + ) + result_high = await pipeline.kickoff([{"score": 90}]) - # Test medium score route - pipeline = Pipeline(stages=[router]) - result_medium = await pipeline.kickoff([{"score": 60}]) - assert len(result_medium) == 1 - assert result_medium[0].json_dict is not None - assert result_medium[0].json_dict["output"] == "crew2" - assert result_medium[0].trace == [ - {"score": 60}, - {"route_taken": "route2"}, - "Crew 2", - ] + assert len(result_high) == 1 + assert result_high[0].json_dict is not None + assert result_high[0].json_dict["output"] == "crew1" + assert result_high[0].trace == [ + {"score": 90}, + {"route_taken": "route1"}, + "Crew 1", + ] + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.return_value = CrewOutput( + raw="Test output from Crew 2", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew2"}, + pydantic=None, + ) + # Test medium score route + pipeline = Pipeline(stages=[router]) + result_medium = await pipeline.kickoff([{"score": 60}]) + assert len(result_medium) == 1 + assert result_medium[0].json_dict is not None + assert result_medium[0].json_dict["output"] == "crew2" + assert result_medium[0].trace == [ + {"score": 60}, + {"route_taken": "route2"}, + "Crew 2", + ] - # Test low score route - pipeline = Pipeline(stages=[router]) - result_low = await pipeline.kickoff([{"score": 30}]) - assert len(result_low) == 1 - assert result_low[0].json_dict is not None - assert result_low[0].json_dict["output"] == "crew3" - assert result_low[0].trace == [ - {"score": 30}, - {"route_taken": "default"}, - "Crew 3", - ] + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.return_value = CrewOutput( + raw="Test output from Crew 3", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew3"}, + pydantic=None, + ) + # Test low score route + pipeline = Pipeline(stages=[router]) + result_low = await pipeline.kickoff([{"score": 30}]) + assert len(result_low) == 1 + assert result_low[0].json_dict is not None + assert result_low[0].json_dict["output"] == "crew3" + assert result_low[0].trace == [ + {"score": 30}, + {"route_taken": "default"}, + "Crew 3", + ] @pytest.mark.asyncio -async def test_router_with_multiple_inputs(mock_router_factory): - router = mock_router_factory() +@pytest.mark.vcr(filter_headers=["authorization"]) +async def test_router_with_multiple_inputs(): + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) + crew3 = Crew(name="Crew 3", tasks=[task], agents=[agent]) + router = Router( + routes={ + "route1": Route( + condition=lambda x: x.get("score", 0) > 80, + pipeline=Pipeline(stages=[crew1]), + ), + "route2": Route( + condition=lambda x: 50 < x.get("score", 0) <= 80, + pipeline=Pipeline(stages=[crew2]), + ), + }, + default=Pipeline(stages=[crew3]), + ) pipeline = Pipeline(stages=[router]) inputs = [{"score": 90}, {"score": 60}, {"score": 30}] - results = await pipeline.kickoff(inputs) - print("RESULTS", results) + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.side_effect = [ + CrewOutput( + raw="Test output from Crew 1", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew1"}, + pydantic=None, + ), + CrewOutput( + raw="Test output from Crew 2", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew2"}, + pydantic=None, + ), + CrewOutput( + raw="Test output from Crew 3", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew3"}, + pydantic=None, + ), + ] + results = await pipeline.kickoff(inputs) assert len(results) == 3 assert results[0].json_dict is not None @@ -587,16 +835,57 @@ async def test_router_with_multiple_inputs(mock_router_factory): @pytest.mark.asyncio -async def test_pipeline_with_multiple_routers(mock_router_factory, mock_crew_factory): - router1 = mock_router_factory() - router2 = mock_router_factory() - final_crew = mock_crew_factory( - name="Final Crew", output_json_dict={"output": "final"} +@pytest.mark.vcr(filter_headers=["authorization"]) +async def test_pipeline_with_multiple_routers(): + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) + router1 = Router( + routes={ + "route1": Route( + condition=lambda x: x.get("score", 0) > 80, + pipeline=Pipeline(stages=[crew1]), + ), + }, + default=Pipeline(stages=[crew2]), ) + router2 = Router( + routes={ + "route2": Route( + condition=lambda x: 50 < x.get("score", 0) <= 80, + pipeline=Pipeline(stages=[crew2]), + ), + }, + default=Pipeline(stages=[crew2]), + ) + final_crew = Crew(name="Final Crew", tasks=[task], agents=[agent]) pipeline = Pipeline(stages=[router1, router2, final_crew]) - result = await pipeline.kickoff([{"score": 75}]) + with patch.object(Crew, "kickoff_async") as mock_kickoff: + mock_kickoff.side_effect = [ + CrewOutput( + raw="Test output from Crew 1", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew1"}, + pydantic=None, + ), + CrewOutput( + raw="Test output from Crew 2", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "crew2"}, + pydantic=None, + ), + CrewOutput( + raw="Test output from Final Crew", + tasks_output=[], + token_usage=DEFAULT_TOKEN_USAGE, + json_dict={"output": "final"}, + pydantic=None, + ), + ] + result = await pipeline.kickoff([{"score": 75}]) assert len(result) == 1 assert result[0].json_dict is not None @@ -604,7 +893,7 @@ async def test_pipeline_with_multiple_routers(mock_router_factory, mock_crew_fac assert ( len(result[0].trace) == 6 ) # Input, Router1, Crew2, Router2, Crew2, Final Crew - assert result[0].trace[1]["route_taken"] == "route2" + assert result[0].trace[1]["route_taken"] == "default" assert result[0].trace[3]["route_taken"] == "route2" @@ -633,13 +922,27 @@ async def test_router_default_route(mock_crew_factory): @pytest.mark.asyncio -async def test_router_with_empty_input(mock_router_factory): - router = mock_router_factory() +@pytest.mark.vcr(filter_headers=["authorization"]) +async def test_router_with_empty_input(): + crew1 = Crew(name="Crew 1", tasks=[task], agents=[agent]) + crew2 = Crew(name="Crew 2", tasks=[task], agents=[agent]) + crew3 = Crew(name="Crew 3", tasks=[task], agents=[agent]) + router = Router( + routes={ + "route1": Route( + condition=lambda x: x.get("score", 0) > 80, + pipeline=Pipeline(stages=[crew1]), + ), + "route2": Route( + condition=lambda x: 50 < x.get("score", 0) <= 80, + pipeline=Pipeline(stages=[crew2]), + ), + }, + default=Pipeline(stages=[crew3]), + ) pipeline = Pipeline(stages=[router]) result = await pipeline.kickoff([{}]) assert len(result) == 1 - assert result[0].json_dict is not None - assert result[0].json_dict["output"] == "crew3" # Default route assert result[0].trace[1]["route_taken"] == "default"