-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: check and support prompt caching for all models #1482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ea780b3
9dfbf80
8b78266
281b3a4
b84d2bf
7ab75f4
9f22448
e8acc6c
cb5e777
77b19a4
892d105
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,22 @@ | |
| "llama.cpp": "openai-compatible-model", | ||
| } | ||
|
|
||
| # Bedrock Converse requires a region during model initialization. | ||
| BEDROCK_CONVERSE_REGION: Final[str] = "us-west-2" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Users who need a different Bedrock region (e.g., us-east-1, eu-west-1) won't be able to use this at all. It would be great to make this user-configurable, or at least read it from an environment variable.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now eigent cloud and BYOK are separated. |
||
|
|
||
|
|
||
| def patch_bedrock_cloud_config( | ||
| api_url: str, extra_params: dict | ||
| ) -> tuple[str, dict]: | ||
| """Patch API URL and extra_params for Bedrock Converse in cloud mode. | ||
|
|
||
| Appends '/bedrock' to the proxy URL and defaults the region. | ||
| Returns the updated (api_url, extra_params). | ||
| """ | ||
| extra_params = dict(extra_params) | ||
| extra_params.setdefault("region_name", BEDROCK_CONVERSE_REGION) | ||
| return api_url + "/bedrock", extra_params | ||
|
|
||
|
|
||
| def normalize_model_platform(platform: str) -> str: | ||
| """Normalize provider aliases to supported model platform names.""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,15 @@ | |
| # limitations under the License. | ||
| # ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= | ||
|
|
||
| import asyncio | ||
| import datetime | ||
| import logging | ||
| from collections.abc import Awaitable, Callable | ||
|
|
||
| from camel.agents.chat_agent import AsyncStreamingChatAgentResponse | ||
| from camel.agents.chat_agent import ( | ||
| AsyncStreamingChatAgentResponse, | ||
| ChatAgentResponse, | ||
| ) | ||
| from camel.societies.workforce.prompts import PROCESS_TASK_PROMPT | ||
| from camel.societies.workforce.single_agent_worker import ( | ||
| SingleAgentWorker as BaseSingleAgentWorker, | ||
|
|
@@ -67,7 +72,13 @@ def __init__( | |
| self.worker = worker # change type hint | ||
|
|
||
| async def _process_task( | ||
| self, task: Task, dependencies: list[Task], stream_callback=None | ||
| self, | ||
| task: Task, | ||
| dependencies: list[Task], | ||
| stream_callback: Callable[ | ||
| ["ChatAgentResponse"], Awaitable[None] | None | ||
| ] | ||
| | None = None, | ||
|
Comment on lines
+75
to
+81
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because of camel-ai/camel#3744. All we need to do is just add the corresponding arguments. So I guess it should be fine in this PR? |
||
| ) -> TaskState: | ||
| r"""Processes a task with its dependencies using an efficient agent | ||
| management system. | ||
|
|
@@ -146,6 +157,10 @@ async def _process_task( | |
| async for chunk in response: | ||
| chunk_count += 1 | ||
| last_chunk = chunk | ||
| if stream_callback: | ||
| maybe = stream_callback(chunk) | ||
| if asyncio.iscoroutine(maybe): | ||
| await maybe | ||
| if chunk.msg and chunk.msg.content: | ||
| accumulated_content += chunk.msg.content | ||
| logger.info( | ||
|
|
@@ -186,6 +201,10 @@ async def _process_task( | |
| last_chunk = None | ||
| async for chunk in response: | ||
| last_chunk = chunk | ||
| if stream_callback: | ||
| maybe = stream_callback(chunk) | ||
| if asyncio.iscoroutine(maybe): | ||
| await maybe | ||
| if chunk.msg: | ||
| if chunk.msg.content: | ||
| accumulated_content += chunk.msg.content | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.