From 1afd53f452e67b263e0e3554c36b2a3e9d57a507 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 13 Oct 2023 15:47:28 -0700 Subject: [PATCH] fix(proxy_server): fix cors issue --- litellm/__pycache__/__init__.cpython-311.pyc | Bin 13679 -> 13679 bytes litellm/__pycache__/main.cpython-311.pyc | Bin 52044 -> 52044 bytes litellm/__pycache__/utils.cpython-311.pyc | Bin 160994 -> 160913 bytes litellm/proxy/api_log.json | 771 +++++++++++++++++++ litellm/proxy/proxy_server.py | 11 + 5 files changed, 782 insertions(+) diff --git a/litellm/__pycache__/__init__.cpython-311.pyc b/litellm/__pycache__/__init__.cpython-311.pyc index a76cace80fb00fb9c08bec596baec5ebb8d861af..a926e70b07ca12ccd9f22dbe4d5061874509d09c 100644 GIT binary patch delta 19 ZcmaE#^*)PhIWI340}z-V-N=<{3IIeV1=j!o delta 19 ZcmaE#^*)PhIWI340}w1cypb!_6aYq~20;J- diff --git a/litellm/__pycache__/main.cpython-311.pyc b/litellm/__pycache__/main.cpython-311.pyc index f8579b52382f639710f316759439722b0294ca30..f25446d36e4017801e793acd4652bfaeb20d014a 100644 GIT binary patch delta 21 bcmX>zjrq(pX0GMDyj%=GV0v^Tm(ytgN%IC` delta 21 bcmX>zjrq(pX0GMDyj%=GaOvYqbnWi#rtbA6K+8;iq?=CLOYBPN^d*}Sl`Of*B zbG~!-=W7wI*CK4YZ8nR*PxHx)S;Yr!dyC0k3%xZxjb1FS&93poXVk6wk%^~A;9s8< z6dRuL3qI2$w4s&6(H~o#>g+ONSNBm^sHY}UEtx^=^wtEE`SE-7>|SG<#c$*xtigb? zp@54Df|wJFN;Eyz6iZ9SxNOlOz0XFMm88-;Lk1coC7FIv(tmOvYa@Kl;9VsqDDl*z zf--0Ay)PU6kfl(8ep9E39?eQd4|9E~&1#-QbkBx$3g{pA`%wpTh!!PXplvysQC1!- zHW+xbAV<<`rKw0)kGYWwk9z`&LGZ=VC~vH&yQp8CM6A2h(QX!m4*u&o z5d3D@N!up6=&uhQZU{(b5FN_0OLq6bAiW&d8zqT{PwdslhZ@ur;g1Njc|x|uLc_*z8||JH zM~{?Q)f-)~QS;9EI|-#cv5uDbx{vL|~``V>q~n#+MMJ z^Q8o(aCcs~d+cn~3tZj19=p(jz)L4T>Rn#gs-%SH#3yHLUJZNjV2L{?v?xFtj=p0ctgsN+{oekL45hLUK_<2>Bhfwa`W77qT2fo(Pbst}lZPS#)S!LS*Hly1H2l7p9DxId`t+sO%l&GsvCphR=t=@)~mY={|7Hwsxn5+Ze6 zl7q8GyvRJccmT{`arsCGUSXp~z(+8j?J2wzZZo^ePP=DKw zMhI$68$N}B4cLKi2u$qmE@bjTSn5aUCnAd#bm9(?iX!i zr&;bndko4_Orn$RmXk|{ z0SRno9=U4ZETsh`*2+tsQA~zL;d{1rDk(H`nlm+|4cMX1uO)|3&(iA1JZtt+BltA` S_qRKszunhb#7@j3$P)Y3n(~R(G}dS%C0UuT%9(UJyRge{HPxBDXYcp_=Y0Qn{`3EL zMUVO09l29IO4m*sM8BCZ!x@&XQD5(ni0aw`j{$;$kb$n) z>roeV!Ah=E)Lr=`pZ;=-Tb(@~K2Z@uCN-}B>7u^LpK$tvwgi({&R=E3u^>o#*+b`? z_Rz{PUc0B?9&*roEA!x_PgD*HNh=}~# zLqRciny7oC*XoX&dSm*>3a#QjhGvslP)w3}7KysU%cJttOSh6Nb#x)DqGXi|=$XmE z81hLr9?2W$StCexjzzk&B3qOT1c6pn=ZK2fmQLL@-YkdY?BJxEW5m%t3KXK~_>K(q zxE-Eo!o2F3z3|-L>FO}?mHg=)Jl7`4-6!e#l#HcyaDkf>IfRg$l~Cf?ZGN@12wu9s zN-WBX({>I>6%-5O=?&A0aD(hokJl29OA==3qIw~ef0C{boxiNO|5zd)(R=Re{J#wOU}MT zUGtZVPuAd1;mS|tik4;5{C|mEp1M9lBBWnSYSe{xL1@r5kQnEU@{PQj&K!bAlE=jJ z!OPy+8A!dx&YVsq3kFTOg2V#*J8p*!}1B zWv@(z8t@>X8{1pRRGDrsja951=i~pK`5k&*fBfkkF^YkG6ena*=TF(u!nVkNvtJLNlR zu=ZBxRsXbU`6!=diV)G=Da=P7s`d;) zG5xGAh$pn~>vn>?W}s^uv&cfwcNz=nk5ip~gMIkdF7JL{$*TrF@!tVgX_u>XzpGTc zJoP5S&EqU}`NGH96N6LA$i9)_U|+?}WgHwDMmRWBW~mG4yT}+B7o{_#|IGE!FC)ZFtJxQ;!1uHwto}+ zB8u6m&A7mm!;Wvk0T^odw_v+v%*+rZsy%{G)1!_25>OVl%jiQ7>{5Meb8 zp90UatamXESk9*JfJ5X0XYWFrh^@^1A&z+QDLeTk8myS5R-eEToMi*Mv5Fwfc6^WX zzykJW4=T;rq+UFWQ}}>&pF=&tGpyoQd}c&9vtEYFh|4TnPxcs5z`AW@y~xwK#7(9G z53!?ZWIZsCE%J~6@Ra(Zm#jkzyTM1M5H6}EgH##u7W*Pd?iO*HU3&!?s)K{g96~-a zp++q#Av;jZzAGUkz|WR9lW&Yk+ q52M^i+JOyf&J400A=Wj6G+9d)>%mL-pXW0%`}t(=couFVLBpT)7fLYz diff --git a/litellm/proxy/api_log.json b/litellm/proxy/api_log.json index 810c5b826b..c2c72092ae 100644 --- a/litellm/proxy/api_log.json +++ b/litellm/proxy/api_log.json @@ -81,5 +81,776 @@ ] } } + }, + "20231013154412334882": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + } + ], + "optional_params": { + "max_tokens_to_sample": 1024, + "temperature": 0.5, + "stream": true + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "44d967c2-456e-4ffa-b7c4-4551e178b0d7", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nAssistant: \", \"max_tokens_to_sample\": 1024, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + } + ], + "optional_params": { + "max_tokens_to_sample": 1024, + "temperature": 0.5, + "stream": true + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "44d967c2-456e-4ffa-b7c4-4551e178b0d7", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": null, + "api_key": null, + "additional_args": {}, + "log_event_type": "post_api_call", + "original_response": "", + "complete_streaming_response": { + "id": "chatcmpl-a569121f-86e3-432a-9e7f-189207791ad2", + "object": "chat.completion.chunk", + "created": 1697237052, + "model": "anthropic.claude-v2", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": " Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app." + }, + "finish_reason": "stop_sequence" + } + ] + } + } + }, + "20231013154448360412": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "b70e6392-90dc-40b0-87bf-9b48c843c847", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" Here is how you can make a FastAPI app CORS compatible:\\n\\n```python\\nfrom fastapi import FastAPI, CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\",\\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \\\"*\\\" allows all methods and headers.\\n\\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\\n\\nSome key points:\\n\\n- The CORSMiddleware should be added before any routers.\\n- The allowed origins can be restricted to your frontend URLs only.\\n- Allow credentials only if needed.\\n- Restrict methods and headers to only required ones if possible.\\n\\nSo this sets up a basic permissive CORS config for a FastAPI app.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "b70e6392-90dc-40b0-87bf-9b48c843c847", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" Here is how you can make a FastAPI app CORS compatible:\\n\\n```python\\nfrom fastapi import FastAPI, CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\",\\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \\\"*\\\" allows all methods and headers.\\n\\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\\n\\nSome key points:\\n\\n- The CORSMiddleware should be added before any routers.\\n- The allowed origins can be restricted to your frontend URLs only.\\n- Allow credentials only if needed.\\n- Restrict methods and headers to only required ones if possible.\\n\\nSo this sets up a basic permissive CORS config for a FastAPI app.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "post_api_call", + "original_response": { + "completion": " Enable CORS in FastAPI", + "stop_reason": "stop_sequence" + } + } + }, + "20231013154450195512": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Response:\n Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\n### Response:\n\n\nGive a short title to describe the above chat session. Do not put quotes around the title. Do not use more than 6 words. The title is: " + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "fd366c97-9868-4c16-995c-a65ef0fd844f", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: ### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Response:\n Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\n### Response:\n\n\nGive a short title to describe the above chat session. Do not put quotes around the title. Do not use more than 6 words. The title is: \n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: ### Instruction:\\napp = FastAPI()\\n\\nmake my fastapi cors compatible\\n### Instruction:\\napp = FastAPI()\\n\\nmake my fastapi cors compatible\\n### Instruction:\\napp = FastAPI()\\n\\nmake my fastapi cors compatible\\n### Response:\\n Here is how you can make a FastAPI app CORS compatible:\\n\\n```python\\nfrom fastapi import FastAPI, CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\",\\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \\\"*\\\" allows all methods and headers.\\n\\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\\n\\nSome key points:\\n\\n- The CORSMiddleware should be added before any routers.\\n- The allowed origins can be restricted to your frontend URLs only.\\n- Allow credentials only if needed.\\n- Restrict methods and headers to only required ones if possible.\\n\\nSo this sets up a basic permissive CORS config for a FastAPI app.\\n### Response:\\n\\n\\nGive a short title to describe the above chat session. Do not put quotes around the title. Do not use more than 6 words. The title is: \\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Response:\n Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\n### Response:\n\n\nGive a short title to describe the above chat session. Do not put quotes around the title. Do not use more than 6 words. The title is: " + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "fd366c97-9868-4c16-995c-a65ef0fd844f", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: ### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Instruction:\napp = FastAPI()\n\nmake my fastapi cors compatible\n### Response:\n Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\n### Response:\n\n\nGive a short title to describe the above chat session. Do not put quotes around the title. Do not use more than 6 words. The title is: \n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: ### Instruction:\\napp = FastAPI()\\n\\nmake my fastapi cors compatible\\n### Instruction:\\napp = FastAPI()\\n\\nmake my fastapi cors compatible\\n### Instruction:\\napp = FastAPI()\\n\\nmake my fastapi cors compatible\\n### Response:\\n Here is how you can make a FastAPI app CORS compatible:\\n\\n```python\\nfrom fastapi import FastAPI, CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\",\\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \\\"*\\\" allows all methods and headers.\\n\\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\\n\\nSome key points:\\n\\n- The CORSMiddleware should be added before any routers.\\n- The allowed origins can be restricted to your frontend URLs only.\\n- Allow credentials only if needed.\\n- Restrict methods and headers to only required ones if possible.\\n\\nSo this sets up a basic permissive CORS config for a FastAPI app.\\n### Response:\\n\\n\\nGive a short title to describe the above chat session. Do not put quotes around the title. Do not use more than 6 words. The title is: \\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "post_api_call", + "original_response": { + "completion": " Making FastAPI CORS Compatible", + "stop_reason": "stop_sequence" + } + } + }, + "20231013154547274601": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "assistant", + "content": " Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app." + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask" + } + ], + "optional_params": { + "max_tokens_to_sample": 1024, + "temperature": 0.5, + "stream": true + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "4f2c1100-7441-45a9-affa-9687de013bc9", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nAssistant: Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\n\nHuman: just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nAssistant: Here is how you can make a FastAPI app CORS compatible:\\n\\n```python\\nfrom fastapi import FastAPI, CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\",\\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \\\"*\\\" allows all methods and headers.\\n\\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\\n\\nSome key points:\\n\\n- The CORSMiddleware should be added before any routers.\\n- The allowed origins can be restricted to your frontend URLs only.\\n- Allow credentials only if needed.\\n- Restrict methods and headers to only required ones if possible.\\n\\nSo this sets up a basic permissive CORS config for a FastAPI app.\\n\\nHuman: just do something like this: \\nfrom flask import Flask\\nfrom flask_cors import CORS\\n\\napp = Flask(__name__)\\nCORS(app)\\n\\nbut for flask\\n\\nAssistant: \", \"max_tokens_to_sample\": 1024, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + } + }, + "20231013154549261702": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" To enable CORS in Flask, you can use the Flask-CORS extension.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "3987d37c-194b-462c-9803-53f2001a6712", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" To enable CORS in Flask, you can use the Flask-CORS extension.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" To enable CORS in Flask, you can use the Flask-CORS extension.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" To enable CORS in Flask, you can use the Flask-CORS extension.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "3987d37c-194b-462c-9803-53f2001a6712", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" To enable CORS in Flask, you can use the Flask-CORS extension.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" To enable CORS in Flask, you can use the Flask-CORS extension.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "post_api_call", + "original_response": { + "completion": " Enable CORS in Flask with Flask-CORS", + "stop_reason": "stop_sequence" + } + } + }, + "20231013154552224346": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "assistant", + "content": " Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app." + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask" + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for fastapi" + } + ], + "optional_params": { + "max_tokens_to_sample": 1024, + "temperature": 0.5, + "stream": true + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "14690436-4133-4ccf-a70f-aa289a967f8a", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nAssistant: Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\n\nHuman: just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask\n\nHuman: just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for fastapi\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nAssistant: Here is how you can make a FastAPI app CORS compatible:\\n\\n```python\\nfrom fastapi import FastAPI, CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\",\\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \\\"*\\\" allows all methods and headers.\\n\\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\\n\\nSome key points:\\n\\n- The CORSMiddleware should be added before any routers.\\n- The allowed origins can be restricted to your frontend URLs only.\\n- Allow credentials only if needed.\\n- Restrict methods and headers to only required ones if possible.\\n\\nSo this sets up a basic permissive CORS config for a FastAPI app.\\n\\nHuman: just do something like this: \\nfrom flask import Flask\\nfrom flask_cors import CORS\\n\\napp = Flask(__name__)\\nCORS(app)\\n\\nbut for flask\\n\\nHuman: just do something like this: \\nfrom flask import Flask\\nfrom flask_cors import CORS\\n\\napp = Flask(__name__)\\nCORS(app)\\n\\nbut for fastapi\\n\\nAssistant: \", \"max_tokens_to_sample\": 1024, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "assistant", + "content": " Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app." + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask" + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for fastapi" + } + ], + "optional_params": { + "max_tokens_to_sample": 1024, + "temperature": 0.5, + "stream": true + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "14690436-4133-4ccf-a70f-aa289a967f8a", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": null, + "api_key": null, + "additional_args": {}, + "log_event_type": "post_api_call", + "original_response": "", + "complete_streaming_response": { + "id": "chatcmpl-32a68738-46c4-45ff-94c2-25d8fc0ea3f0", + "object": "chat.completion.chunk", + "created": 1697237152, + "model": "anthropic.claude-v2", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": " To enable CORS in FastAPI, you can use the CORSMiddleware similar to how it is done in Flask:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\", \n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware, \n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe main differences compared to Flask:\n\n- Import CORSMiddleware from fastapi.middleware.cors\n- Use app.add_middleware() instead of CORS()\n- Specify the middleware before routes just like in Flask\n\nOtherwise the usage is similar - define allowed origins, set allow_credentials, allow_methods, allow_headers etc.\n\nSo this will enable CORS in your FastAPI app for the specified origins and allowed options." + }, + "finish_reason": "stop_sequence" + } + ] + } + } + }, + "20231013154602476284": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" To enable CORS in FastAPI, you can use the CORSMiddleware similar to how it is done in Flask:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\", \n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware, \n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe main differences compared to Flask:\n\n- Import CORSMiddleware from fastapi.middleware.cors\n- Use app.add_middleware() instead of CORS()\n- Specify the middleware before routes just like in Flask\n\nOtherwise the usage is similar - define allowed origins, set allow_credentials, allow_methods, allow_headers etc.\n\nSo this will enable CORS in your FastAPI app for the specified origins and allowed options.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "6b158a57-2c7f-4eb7-87a4-a6fe4fc546ae", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" To enable CORS in FastAPI, you can use the CORSMiddleware similar to how it is done in Flask:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\", \n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware, \n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe main differences compared to Flask:\n\n- Import CORSMiddleware from fastapi.middleware.cors\n- Use app.add_middleware() instead of CORS()\n- Specify the middleware before routes just like in Flask\n\nOtherwise the usage is similar - define allowed origins, set allow_credentials, allow_methods, allow_headers etc.\n\nSo this will enable CORS in your FastAPI app for the specified origins and allowed options.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" To enable CORS in FastAPI, you can use the CORSMiddleware similar to how it is done in Flask:\\n\\n```python\\nfrom fastapi import FastAPI\\nfrom fastapi.middleware.cors import CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\", \\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware, \\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThe main differences compared to Flask:\\n\\n- Import CORSMiddleware from fastapi.middleware.cors\\n- Use app.add_middleware() instead of CORS()\\n- Specify the middleware before routes just like in Flask\\n\\nOtherwise the usage is similar - define allowed origins, set allow_credentials, allow_methods, allow_headers etc.\\n\\nSo this will enable CORS in your FastAPI app for the specified origins and allowed options.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" To enable CORS in FastAPI, you can use the CORSMiddleware similar to how it is done in Flask:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\", \n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware, \n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe main differences compared to Flask:\n\n- Import CORSMiddleware from fastapi.middleware.cors\n- Use app.add_middleware() instead of CORS()\n- Specify the middleware before routes just like in Flask\n\nOtherwise the usage is similar - define allowed origins, set allow_credentials, allow_methods, allow_headers etc.\n\nSo this will enable CORS in your FastAPI app for the specified origins and allowed options.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "6b158a57-2c7f-4eb7-87a4-a6fe4fc546ae", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" To enable CORS in FastAPI, you can use the CORSMiddleware similar to how it is done in Flask:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\", \n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware, \n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe main differences compared to Flask:\n\n- Import CORSMiddleware from fastapi.middleware.cors\n- Use app.add_middleware() instead of CORS()\n- Specify the middleware before routes just like in Flask\n\nOtherwise the usage is similar - define allowed origins, set allow_credentials, allow_methods, allow_headers etc.\n\nSo this will enable CORS in your FastAPI app for the specified origins and allowed options.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" To enable CORS in FastAPI, you can use the CORSMiddleware similar to how it is done in Flask:\\n\\n```python\\nfrom fastapi import FastAPI\\nfrom fastapi.middleware.cors import CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\", \\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware, \\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThe main differences compared to Flask:\\n\\n- Import CORSMiddleware from fastapi.middleware.cors\\n- Use app.add_middleware() instead of CORS()\\n- Specify the middleware before routes just like in Flask\\n\\nOtherwise the usage is similar - define allowed origins, set allow_credentials, allow_methods, allow_headers etc.\\n\\nSo this will enable CORS in your FastAPI app for the specified origins and allowed options.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "post_api_call", + "original_response": { + "completion": " Enabling CORS in FastAPI", + "stop_reason": "stop_sequence" + } + } + }, + "20231013154610735962": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "assistant", + "content": " Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app." + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask" + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for fastapi" + }, + { + "role": "user", + "content": "just allow all origins " + } + ], + "optional_params": { + "max_tokens_to_sample": 1024, + "temperature": 0.5, + "stream": true + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "1cc72768-9cfc-424d-98be-062a2871b6f8", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nHuman: app = FastAPI()\n\nmake my fastapi cors compatible\n\nAssistant: Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app.\n\nHuman: just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask\n\nHuman: just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for fastapi\n\nHuman: just allow all origins \n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nHuman: app = FastAPI()\\n\\nmake my fastapi cors compatible\\n\\nAssistant: Here is how you can make a FastAPI app CORS compatible:\\n\\n```python\\nfrom fastapi import FastAPI, CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\n \\\"http://localhost.tiangolo.com\\\",\\n \\\"https://localhost.tiangolo.com\\\",\\n \\\"http://localhost\\\",\\n \\\"http://localhost:8080\\\",\\n]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \\\"*\\\" allows all methods and headers.\\n\\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\\n\\nSome key points:\\n\\n- The CORSMiddleware should be added before any routers.\\n- The allowed origins can be restricted to your frontend URLs only.\\n- Allow credentials only if needed.\\n- Restrict methods and headers to only required ones if possible.\\n\\nSo this sets up a basic permissive CORS config for a FastAPI app.\\n\\nHuman: just do something like this: \\nfrom flask import Flask\\nfrom flask_cors import CORS\\n\\napp = Flask(__name__)\\nCORS(app)\\n\\nbut for flask\\n\\nHuman: just do something like this: \\nfrom flask import Flask\\nfrom flask_cors import CORS\\n\\napp = Flask(__name__)\\nCORS(app)\\n\\nbut for fastapi\\n\\nHuman: just allow all origins \\n\\nAssistant: \", \"max_tokens_to_sample\": 1024, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "user", + "content": "app = FastAPI()\n\nmake my fastapi cors compatible" + }, + { + "role": "assistant", + "content": " Here is how you can make a FastAPI app CORS compatible:\n\n```python\nfrom fastapi import FastAPI, CORSMiddleware\n\napp = FastAPI()\n\norigins = [\n \"http://localhost.tiangolo.com\",\n \"https://localhost.tiangolo.com\",\n \"http://localhost\",\n \"http://localhost:8080\",\n]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThis enables CORS for the specified origins. The allow_credentials=True allows sending cookies from the frontend. The allow_methods and allow_headers set to \"*\" allows all methods and headers.\n\nYou can also set more restrictive CORS settings by specifying only the required origins, methods, headers etc.\n\nSome key points:\n\n- The CORSMiddleware should be added before any routers.\n- The allowed origins can be restricted to your frontend URLs only.\n- Allow credentials only if needed.\n- Restrict methods and headers to only required ones if possible.\n\nSo this sets up a basic permissive CORS config for a FastAPI app." + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for flask" + }, + { + "role": "user", + "content": "just do something like this: \nfrom flask import Flask\nfrom flask_cors import CORS\n\napp = Flask(__name__)\nCORS(app)\n\nbut for fastapi" + }, + { + "role": "user", + "content": "just allow all origins " + } + ], + "optional_params": { + "max_tokens_to_sample": 1024, + "temperature": 0.5, + "stream": true + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "1cc72768-9cfc-424d-98be-062a2871b6f8", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": null, + "api_key": null, + "additional_args": {}, + "log_event_type": "post_api_call", + "original_response": "", + "complete_streaming_response": { + "id": "chatcmpl-e074b9c9-b64d-458c-a20c-5db299ebd44c", + "object": "chat.completion.chunk", + "created": 1697237170, + "model": "anthropic.claude-v2", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": " Here is how to enable CORS for all origins in FastAPI:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\"*\"]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe key points:\n\n- Set origins to [\"*\"] to allow all origins\n- Enable allow_credentials if you want to allow sending cookies\n- Allow all methods and headers with [\"*\"]\n\nThis enables CORS access from any origin to the FastAPI app.\n\nDo note that allowing all origins is not suitable for production applications. It's better to restrict origins to your specific frontend URLs for security.\n\nBut for development, allowing all origins is a quick way to enable CORS in FastAPI." + }, + "finish_reason": "stop_sequence" + } + ] + } + } + }, + "20231013154630846250": { + "pre_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" Here is how to enable CORS for all origins in FastAPI:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\"*\"]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe key points:\n\n- Set origins to [\"*\"] to allow all origins\n- Enable allow_credentials if you want to allow sending cookies\n- Allow all methods and headers with [\"*\"]\n\nThis enables CORS access from any origin to the FastAPI app.\n\nDo note that allowing all origins is not suitable for production applications. It's better to restrict origins to your specific frontend URLs for security.\n\nBut for development, allowing all origins is a quick way to enable CORS in FastAPI.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "658cf642-541f-4461-be7b-e3e48d591bdf", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" Here is how to enable CORS for all origins in FastAPI:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\"*\"]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe key points:\n\n- Set origins to [\"*\"] to allow all origins\n- Enable allow_credentials if you want to allow sending cookies\n- Allow all methods and headers with [\"*\"]\n\nThis enables CORS access from any origin to the FastAPI app.\n\nDo note that allowing all origins is not suitable for production applications. It's better to restrict origins to your specific frontend URLs for security.\n\nBut for development, allowing all origins is a quick way to enable CORS in FastAPI.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" Here is how to enable CORS for all origins in FastAPI:\\n\\n```python\\nfrom fastapi import FastAPI\\nfrom fastapi.middleware.cors import CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\\"*\\\"]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThe key points:\\n\\n- Set origins to [\\\"*\\\"] to allow all origins\\n- Enable allow_credentials if you want to allow sending cookies\\n- Allow all methods and headers with [\\\"*\\\"]\\n\\nThis enables CORS access from any origin to the FastAPI app.\\n\\nDo note that allowing all origins is not suitable for production applications. It's better to restrict origins to your specific frontend URLs for security.\\n\\nBut for development, allowing all origins is a quick way to enable CORS in FastAPI.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "pre_api_call" + }, + "post_api_call": { + "model": "anthropic.claude-v2", + "messages": [ + { + "role": "system", + "content": "\" Here is how to enable CORS for all origins in FastAPI:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\"*\"]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe key points:\n\n- Set origins to [\"*\"] to allow all origins\n- Enable allow_credentials if you want to allow sending cookies\n- Allow all methods and headers with [\"*\"]\n\nThis enables CORS access from any origin to the FastAPI app.\n\nDo note that allowing all origins is not suitable for production applications. It's better to restrict origins to your specific frontend URLs for security.\n\nBut for development, allowing all origins is a quick way to enable CORS in FastAPI.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:" + } + ], + "optional_params": { + "max_tokens_to_sample": 20, + "temperature": 0.5 + }, + "litellm_params": { + "return_async": false, + "api_key": null, + "force_timeout": 600, + "logger_fn": null, + "verbose": false, + "custom_llm_provider": "bedrock", + "api_base": null, + "litellm_call_id": "658cf642-541f-4461-be7b-e3e48d591bdf", + "model_alias_map": {}, + "completion_call_id": null, + "metadata": null, + "stream_response": {} + }, + "input": "\n\nHuman: \n\nHuman: \" Here is how to enable CORS for all origins in FastAPI:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\norigins = [\"*\"]\n\napp.add_middleware(\n CORSMiddleware,\n allow_origins=origins,\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)\n```\n\nThe key points:\n\n- Set origins to [\"*\"] to allow all origins\n- Enable allow_credentials if you want to allow sending cookies\n- Allow all methods and headers with [\"*\"]\n\nThis enables CORS access from any origin to the FastAPI app.\n\nDo note that allowing all origins is not suitable for production applications. It's better to restrict origins to your specific frontend URLs for security.\n\nBut for development, allowing all origins is a quick way to enable CORS in FastAPI.\"\n\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\n\nAssistant: ", + "api_key": "", + "additional_args": { + "complete_input_dict": "{\"prompt\": \"\\n\\nHuman: \\n\\nHuman: \\\" Here is how to enable CORS for all origins in FastAPI:\\n\\n```python\\nfrom fastapi import FastAPI\\nfrom fastapi.middleware.cors import CORSMiddleware\\n\\napp = FastAPI()\\n\\norigins = [\\\"*\\\"]\\n\\napp.add_middleware(\\n CORSMiddleware,\\n allow_origins=origins,\\n allow_credentials=True,\\n allow_methods=[\\\"*\\\"],\\n allow_headers=[\\\"*\\\"],\\n)\\n```\\n\\nThe key points:\\n\\n- Set origins to [\\\"*\\\"] to allow all origins\\n- Enable allow_credentials if you want to allow sending cookies\\n- Allow all methods and headers with [\\\"*\\\"]\\n\\nThis enables CORS access from any origin to the FastAPI app.\\n\\nDo note that allowing all origins is not suitable for production applications. It's better to restrict origins to your specific frontend URLs for security.\\n\\nBut for development, allowing all origins is a quick way to enable CORS in FastAPI.\\\"\\n\\nPlease write a short title summarizing the message quoted above. Use no more than 10 words:\\n\\nAssistant: \", \"max_tokens_to_sample\": 20, \"temperature\": 0.5}" + }, + "log_event_type": "post_api_call", + "original_response": { + "completion": " Enable CORS in FastAPI for all origins", + "stop_reason": "stop_sequence" + } + } } } \ No newline at end of file diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 18f31133e8..d1152e370e 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -20,6 +20,7 @@ except ImportError: import fastapi import tomli as tomllib import appdirs + import random list_of_messages = [ @@ -64,11 +65,21 @@ import litellm from fastapi import FastAPI, Request from fastapi.routing import APIRouter from fastapi.responses import StreamingResponse, FileResponse +from fastapi.middleware.cors import CORSMiddleware import json import logging app = FastAPI() router = APIRouter() +origins = ["*"] + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) user_api_base = None user_model = None